Krantz
Krantz

Reputation: 1493

Estimating DIC for a zoib beta regression model

I have the data and code below and would appreciate your help to estimate DIC (or AIC) for a beta regression model with zoib:

library(zoib)
data("GasolineYield", package = "zoib")
re.md <- zoib(yield ~ temp | 1 | 1, data=GasolineYield, 
joint = FALSE, random=1, EUID=GasolineYield$batch, 
zero.inflation = FALSE, one.inflation = FALSE, 
n.iter=3200, n.thin=15, n.burn=200)
sample2 <- re.md$coeff
summary(sample2)

Following the package's vignette and the article published by the authors, I implemented the code below to get DIC, but I get an error:

dic.samples(sample2, n.iter=201, thin = 1, type="pD")
Error in nchain(model) : Invalid JAGS model object in nchain

I ran the same code with an object from coda.samples {rjags} documentation and it worked:

data(LINE)
LINE$recompile()
LINE.out <- coda.samples(LINE, c("alpha","beta","sigma"), n.iter=1000)
summary(LINE.out)
dic.samples(LINE, n.iter=201, thin = 1, type="pD")

Then I checked the class of each of the objects above LINE, sample2, re.md, and LINE.out, and the output is:

class(LINE)
"jags"
class(re.md)
"list"
class(sample2)
"mcmc.list"
class(LINE.out)
"mcmc.list"

This suggests that my error is probably because the object sample2 is not of class jags.

Therefore, I would appreciate any ideas on how I can get sample2 in a form that can be accepted by dic.samples in order to be able to get DIC (or AIC) for my rd.md model.

Upvotes: 0

Views: 702

Answers (0)

Related Questions