Lfo-cv update() function for stan_glmer()?

I am adapting this vignette to my context: Approximate leave-future-out cross-validation for Bayesian time series models • loo

I fit a model in rstanarm: fit ← stan_glmer(…)

but then the update() function doesn’t work, as in this line from the vignette:
fit_i ← update(fit, newdata = df[-(i:N), ], recompile = FALSE)

returns an error: “Error: passing unknown arguments: newdata, recompile.”

Suggestions?

packageVersion(“rstanarm”)
[1] ‘2.18.2’
sessionInfo()
R version 3.5.2 (2018-12-20)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Mojave 10.14.2

What happens when you just type update into R?

update
function (object, …)
UseMethod(“update”)
<bytecode: 0x102995490>
<environment: namespace:stats>

OK the update from stats doesn’t accept newdata or recompile, those are rstan instructions.

Why wouldn’t we be using posterior_predict.stanreg in this case?

the code you see in the case study is for brms not for rstanarm. recompile is not required for rstanarm. the rest you will likely find at ?update.stanreg

1 Like

yes, I see that the case study uses brms, not rstanarm. I’m wondering what the equivalent line of code would be with fit from rstanarm. I see that recompile isn’t required, but what is the equivalent to "newdata = "? Thank you!!

Update on update()! thanks for Ben Goodrich:

This works: fit_i ← update(fit, data = df[-(i:N),])

In other words, to switch the update() from brms to stan_glmer:
newdata = → data = , and
remove recompile = .

@bgoodri and @jonah might be able to help you with this. I am not that familiar with many rstanarm details.