stan-dev / rstanarm

rstanarm R package for Bayesian applied regression modeling
https://mc-stan.org/rstanarm
GNU General Public License v3.0
385 stars 132 forks source link

stan_lm doesn't work #583

Open acastroaraujo opened 1 year ago

acastroaraujo commented 1 year ago

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:

packageVersion("rstanarm")
# [1] ‘2.21.3’
jttoivon commented 1 year ago

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

acastroaraujo commented 1 year ago

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