rstanarm icon indicating copy to clipboard operation
rstanarm copied to clipboard

stan_lm doesn't work

Open acastroaraujo opened this issue 2 years ago • 2 comments

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’

acastroaraujo avatar Jan 16 '23 23:01 acastroaraujo

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

jttoivon avatar Jan 30 '23 16:01 jttoivon

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

acastroaraujo avatar Feb 06 '23 01:02 acastroaraujo