2

I am attempting to fit a hierarchical negative binomial model with bayesm. Though my data is proprietary, I was able to recreate the same error with the margarine dataset. The error I get is as follows:

> look <- rhierNegbinRw(Data = list(regdata = dat1), Mcmc = list(R = 1000, 
nprint = 100))
Z not specified - using a column of ones instead
Error in alpha <= 0 : 
  comparison (4) is possible only for atomic and list types

I set up the mock data as follows(the regression is completely nonsensical -- just trying to get the thing to work):

data(margarine)
chpr <- margarine$choicePrice
chpr$hhid <- as.factor(chpr$hhid)
N <- nlevels(chpr$hhid)
dat1 <- vector(mode = "list", length = N)
for (i in 1:N) {
  dat1[[i]]$y <- chpr[chpr$hhid==levels(chpr$hhid)[i], "PPk_Stk"]
  dat1[[i]]$X <- model.matrix( ~ choice + PBB_Stk, 
                          data = chpr[chpr$hhid == levels(chpr$hhid)[i], ])  

}

I would greatly appreciate any insight into this issue.

mmmm
  • 21
  • 1

0 Answers0