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


#1

I am adapting this vignette to my context: https://mc-stan.org/loo/articles/loo2-lfo.html

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


#2

What happens when you just type update into R?


#3

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


#4

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?


#5

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


#6

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 = .


#7

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