The chkptstanr R package allows users to start/stop brms models with the function ‘chkpt_brms’. the function specifies that the model can handle multivariate formulas e.g. mvbrmsformulas - see: R: Checkpoint Sampling: brms
I can’t seem to get a multivariate model working though, receiving the error ‘formula must be of class formula or brmsformula’. See a reproducible example below. Any ideas what’s wrong?
The CRAN version of chkptstanr is completely non-functional and and hasn’t been updated in 2 years. I have recently taken up the development from the original creator, and this issue, together with others is fixed here:
If you install the current v0.2.0-alpha release via:
fit1 ← chkpt_brms(count ~ zAge + zBase * Trt + (1|patient),
data = epilepsy,
family = poisson(),
iter_adaptation=1000,
iter_warmup=200,
save_warmup=FALSE,
iter_per_chkpt = 200,
path = ‘checkpoints/epilepsy’)
The programme appeared to run and the *.csv outputs are in the path as specified
But fit1 was not created and error messages shown:
Compiling Stan program…
Initial Warmup (Typical Set)
Chkpt: 1 / 6; Iteration: 200 / 1200 (warmup)
Chkpt: 2 / 6; Iteration: 400 / 1200 (sample)
Chkpt: 3 / 6; Iteration: 600 / 1200 (sample)
Chkpt: 4 / 6; Iteration: 800 / 1200 (sample)
Chkpt: 5 / 6; Iteration: 1000 / 1200 (sample)
Chkpt: 6 / 6; Iteration: 1200 / 1200 (sample)
Checkpointing complete
Error in if (max(save_warmup) == 0L) { :
missing value where TRUE/FALSE needed
In addition: Warning messages:
1: In parse_stancsv_comments(comments) : NAs introduced by coercion
2: In parse_stancsv_comments(comments) : NAs introduced by coercion
3: In parse_stancsv_comments(comments) : NAs introduced by coercion
4: In parse_stancsv_comments(comments) : NAs introduced by coercion
Sampling aborted. You can examine the results or continue sampling by rerunning the same code.
Error in if (max(save_warmup) == 0L) { :
missing value where TRUE/FALSE needed
In addition: Warning messages:
1: In parse_stancsv_comments(comments) : NAs introduced by coercion
2: In parse_stancsv_comments(comments) : NAs introduced by coercion
3: In parse_stancsv_comments(comments) : NAs introduced by coercion
4: In parse_stancsv_comments(comments) : NAs introduced by coercion