0

I'm writing a model using the ulam function in the rethinking package in rstan. The data list I'm providing it is all numeric (is.numeric returns true for each variable) on its own, but is not as a whole. How can I make it numeric so the model can run? Here's the data list and model code, as well as the full error message:

Data list:

datBIG <- list(
  R = d$R,
  P = d$P,
  I = d$I,
  N = d$N,
  M = d$M,
  B = d$B,
  AID = d$AID)

Model:

mBIG<-ulam(alist(
  V ~ dnorm(mu, sigma),
  mu <- a[AID] + bR*R + bP*P + bI*I + bN*N + bM*M + bB*B,
  a[AID] ~ dnorm(abar, sigma_a),
  abar ~ dnorm(0, 0.2),
  bR ~ dnorm(0, 0.2),
  bP ~ dnorm(0, 0.2),
  bI ~ dnorm(0, 0.2),
  bN ~ dnorm(0, 0.2),
  bM ~ dnorm(0, 0.2),
  bB ~ dnorm(0, 0.2),
  sigma_a ~ dexp(1),
  sigma ~ dexp(1)
), data=datBIG, chains=1, cores=1, log_lik=TRUE)

And the error message:

Error in validObject(.Object) : invalid class “ulam” object: invalid object for slot "coef" in class "ulam": got class "NULL", should be or extend class "numeric"

2 Answers2

0

I got the same error message. I had an index variable that started from 0. It needs to start from 1. Inspect your variable AID if it indexes starting from 0, simply add 1 to each index value so that it counts from 1,2...,k instead from 0,1,2,...,k

user105833
  • 39
  • 3
0

I was getting this error for a while recently (September 2021) and think the problem has to do with any Makevars file you have set up. Try to go to your terminal and run:

rm ~/.R/Makevars

Then re-start R and try to run it all again (assuming everything else is running). This solved a lot of issues for me as I am also running Big Sur 11.3.1 on the M1 macs.