Reputation: 389
I would like to create a plot like this, where y is the observed data and yrep is the predictions using rjags:
I looked at the code from the example here: JAGS and R: Obtain posterior predictive distribution for specific x
but I don't understand why they use:
for(i in 1:3){
yP[i] ~ dt(intercept+slope*xP[i],tau,nu)
}
specifically, why are they using
dt()
If my overall model looks like this:
jagsscript <- cat("
model {
###priors####
alpha.m ~ dunif(1,100);
beta.m ~ dunif(0,1);
s.a.sd ~ dunif(0,3);
s.b.sd ~ dunif(0,3);
sigmaObs ~ dunif(0,2);
for(i in 1:Ndata){
pRR[i] <- alpha[i] * SS[i] * exp(-1*beta[i]*SS[i]);
lRR[i] ~ dnorm(log(pRR[i]) - (pow(sigmaObs,2)/2),pow(sigmaObs,-2));
lalpha[i] <- log(alpha.m) + s.a[stream[i]];
lbeta[i] <- log(beta.m) + s.b[stream[i]];
alpha[i] <- exp(lalpha[i]);
beta[i] <- exp(lbeta[i]);
}
for(SS in 1:Nstream){
s.a[SS] ~ dnorm(0,pow(s.a.sd,-2));
s.b[SS] ~ dnorm(0,pow(s.b.sd,-2));
}
}
}
",
file = here(modelScript.name))
My thought is that I would do something like this:
for(i in 1:Nstream){
yP[i] ~ dt(alpha[i] * SS[i] * exp(-1*beta[i]*SS[i]),XXX,YYY)
}
But I don't understand what would go in place of XXX and YYY like they had in the linked example, or if using dt() is even appropriate.
Upvotes: 0
Views: 279