r - Analyzing Effect in a Bayesian Model (Rjags) -


"consider below number of actuarial claims data 3 groups of insurance policyholders,

year: 1 2 3 4 5 grp1: 9 7 6 13 12 grp2: 6 4 2 8 10 grp3: 8 8 3 4 9 

run r , jags apply following hierarchical model analyze data:

yij ∼ poisson(λij ) λij = pijθj θij ∼ ga(α, β) pij ∼ ga(γ, δ) α ∼ ga(5, 5) γ ∼ u(0, 100) β ∼ ga(25, 1) δ ∼ u(0, 100), = 1, 2, 3 , j = 1, . . . , 5.  

what’s conclusion group effect , year effect?"

i have model specifications drafted pulled r using jags. question is, how code in r test effect of group , effect of year separately? i've ever used jags 1 variable.

here cookie-cutter jags code:

library(rjags)    forjags<-list(                  )  inits<-list(                     )  foo<jags.model(file="m2n4.bug",data = forjags,inits=inits)  out<-coda.samples(model=foo, variable.names = c(                ),     n.iter=50000,thin=5)  summary(out) 

here model:

model { (i in 1:3,j in 1:5){ y[i,j] ~ dpois(lambda[i,j]) lambda[i,j] = p[i,j]*theta[i,j] theta[i,j] ~dgamma(alpha,beta) p[i,j] ~ dgamma(gamma,delta) } alpha ~ dgamma(5,5) beta ~ dgamma(25,1) gamma ~ dunif(0,100) delta ~ dunif(0,100) } 

any input informing me of how code such test effects separately huge.

define model as:

model { (j in 1:5){p[j] ~ dgamma(gamma,delta)} (i in 1:3){ for(j in 1:5){ y[i,j] ~ dpois(lambda[i,j]) lambda[i,j] = p[j]*theta[i,j] theta[i,j] ~ dgamma(alpha,beta) } } alpha ~ dgamma(5,5) beta ~ dgamma(25,1) gamma ~ dunif(0,100) delta ~ dunif(0,100) } 

and run:

library(rjags)  y<-rbind(c(9, 7, 6, 13, 12),c( 6 ,4 ,2 ,8 ,10),c(8 ,8, 3, 4, 9))  forjags<-list('y' = y)  foo<-jags.model(file="m2n4.bug",data = forjags)  out<-coda.samples(model=foo, variable.names = c("theta","p"),n.iter=50000,thin=5)  summary(out) 

you able see separate effect p (the year) , single effect (theta)


Comments