Problem in determining type and dimensions

43 views Asked by At

enter image description here

I am trying to learn Statistical Rethinking by Richard McElreath and am currently at Chapter 8 of the 2015 version of the book. Whilst trying to run R code 8.13, I was unable to run the code and was met with the following message:

Warning in map2stan(alist(log_gdp ~ dnorm(mu, sigma), mu <- a + bR * rugged +  :
  DEPRECATED: map2stan is no longer supported and may behave unpredictably or stop working altogether. Start using ulam instead.

enter image description here

Hence, I tried replacing map2stan with ulam but I met with this error. So my question is how or what can I do to get rid of this problem? Thank you in advance for your input!

1

There are 1 answers

0
Phil On

It looks like you have to do further specifications since 2015, as the alpha object is no longer a recognized object of the package. Try this instead:

m8.2 <- ulam(
  alist(
    y ~ dnorm(mu, sigma),
    mu ~ dnorm(0 , 10), # New
    sigma ~ dexp(1) # New
  ),
  data = list(y = y), 
  start = list(mu = 0, sigma = 1), # New
  chains = 2, iter = 4000, warmup = 1000
)

summary(m8.2)
       mean   sd  5.5% 94.5% n_eff Rhat4
mu    -0.01 1.29 -1.94  1.92  1409     1
sigma  1.61 0.86  0.68  3.23  1504     1