Pp_validate() error, how to debug

Hi all,
I want to to a prior preditive check for my model (stan_glmer) and came across an error.

I tried to reduce runtime by setting nreps to 2 and using a small subsample of my data (n = 1000). I further restricted the initial values in the original model fit as suggested in the documentation (r_init = 0.5).

Since the error message says something about a value in the “y” variable (I assume it´s my response variable in the model) contains non-int values, I checked it, but there are only integers.

I have no idea left how to approach this error. Has anyone an idea?

y_sim <- pp_validate(M1,
                     nreps = 2,
                     seed = 12345,
                     prior_PD = TRUE)

The resulting error message:

Error in new_CppObject_xp(fields$.module, fields$.pointer, ...) : 
  Exception: int variable contained non-int values; processing stage=data initialization; variable name=y; base type=int  (in 'model_count' at line 12)

failed to create the sampler; sampling not done
Error in check_stanfit(stanfit) : 
  Invalid stanfit object produced please report bug
Error in new_CppObject_xp(fields$.module, fields$.pointer, ...) : 
  Exception: int variable contained non-int values; processing stage=data initialization; variable name=y; base type=int  (in 'model_count' at line 12)

failed to create the sampler; sampling not done
Error in check_stanfit(stanfit) : 
  Invalid stanfit object produced please report bug
Error in new_CppObject_xp(fields$.module, fields$.pointer, ...) : 
  Exception: int variable contained non-int values; processing stage=data initialization; variable name=y; base type=int  (in 'model_count' at line 12)

failed to create the sampler; sampling not done
Error in check_stanfit(stanfit) : 
  Invalid stanfit object produced please report bug
Error in dimnamesGets(x, value) : 
  invalid dimnames given for “dgCMatrix” object

Further information:

starting worker pid=2696 on localhost:11075 at 15:14:43.598
starting worker pid=10640 on localhost:11075 at 15:14:43.768
starting worker pid=9360 on localhost:11075 at 15:14:43.943
starting worker pid=12328 on localhost:11075 at 15:14:44.127

SAMPLING FOR MODEL 'count' NOW (CHAIN 1).
Chain 1: 
Chain 1: Gradient evaluation took 0.001 seconds
Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 10 seconds.
Chain 1: Adjust your expectations accordingly!
Chain 1: 
Chain 1: 
Chain 1: Iteration:    1 / 2000 [  0%]  (Warmup)

SAMPLING FOR MODEL 'count' NOW (CHAIN 2).
Chain 2: 
Chain 2: Gradient evaluation took 0.002 seconds
Chain 2: 1000 transitions using 10 leapfrog steps per transition would take 20 seconds.
Chain 2: Adjust your expectations accordingly!
Chain 2: 
Chain 2: 
Chain 2: Iteration:    1 / 2000 [  0%]  (Warmup)

SAMPLING FOR MODEL 'count' NOW (CHAIN 3).
Chain 3: 
Chain 3: Gradient evaluation took 0.001 seconds
Chain 3: 1000 transitions using 10 leapfrog steps per transition would take 10 seconds.
Chain 3: Adjust your expectations accordingly!
Chain 3: 
Chain 3: 
Chain 3: Iteration:    1 / 2000 [  0%]  (Warmup)

SAMPLING FOR MODEL 'count' NOW (CHAIN 4).
Chain 4: 
Chain 4: Gradient evaluation took 0.001 seconds
Chain 4: 1000 transitions using 10 leapfrog steps per transition would take 10 seconds.
Chain 4: Adjust your expectations accordingly!
Chain 4: 
Chain 4: 
Chain 4: Iteration:    1 / 2000 [  0%]  (Warmup)
Chain 4: Iteration:  200 / 2000 [ 10%]  (Warmup)
.....
Chain 2: Iteration: 1800 / 2000 [ 90%]  (Sampling)
Chain 4: Iteration: 2000 / 2000 [100%]  (Sampling)
Chain 4: 
Chain 4:  Elapsed Time: 52.494 seconds (Warm-up)
Chain 4:                38.552 seconds (Sampling)
Chain 4:                91.046 seconds (Total)
Chain 4: 
Chain 3: Iteration: 1800 / 2000 [ 90%]  (Sampling)
Chain 2: Iteration: 2000 / 2000 [100%]  (Sampling)
Chain 2: 
Chain 2:  Elapsed Time: 57.577 seconds (Warm-up)
Chain 2:                42.598 seconds (Sampling)
Chain 2:                100.175 seconds (Total)
Chain 2: 
Chain 3: Iteration: 2000 / 2000 [100%]  (Sampling)
Chain 3: 
Chain 3:  Elapsed Time: 64.846 seconds (Warm-up)
Chain 3:                37.27 seconds (Sampling)
Chain 3:                102.116 seconds (Total)
Chain 3: 
Chain 1: Iteration: 1600 / 2000 [ 80%]  (Sampling)
Chain 1: Iteration: 1800 / 2000 [ 90%]  (Sampling)
Chain 1: Iteration: 2000 / 2000 [100%]  (Sampling)
Chain 1: 
Chain 1:  Elapsed Time: 59.242 seconds (Warm-up)
Chain 1:                72.455 seconds (Sampling)
Chain 1:                131.697 seconds (Total)
Chain 1: 
  • Operating System: Windows 10
  • rstanarm Version: 2.21.1
  • R version: 4.1.0

Welcome to discourse, and sorry it took us so long to respond!

Can you show us what your model call looks like? Also, did you mean to say “prior predictive check”, or do you want full simulation based calibration, which is what I understand the pp_validate function’s purpose to be.