rstanarm
rstanarm copied to clipboard
stan_lm doesn't work
Summary:
The stan_lm() function doesn't work for me.
library(rstanarm)
options(mc.cores = parallel::detectCores())
stan_lm(mpg ~ wt, data = mtcars)
# Error in stopifnot(is.numeric(location)) : 'location' must be specified
More info:
- R version 4.2.1 (2022-06-23)
- rstan (Version 2.21.7)
packageVersion("rstanarm")
# [1] ‘2.21.3’
Hi,
The help page of stan_lm() says the following:
prior | Must be a call to R2 with its location argument specified or NULL, which would indicate a standard uniform prior for the R^2.
The following two examples seem to work:
stan_lm(mpg ~ wt, data = mtcars, prior=NULL)
stan_lm(mpg ~ wt, data = mtcars, prior=R2(0.75, what = "median"))
Jarkko
Thanks!
I do think that this is a bad default, though. I think the only people out there using stan_lm() are early students (outside statistics departments) trying to transition from lm(). Having to specify a prior on R^2 seems too confusing at that level.
Best, Andrés