I am creating a Bayesian linear regression model to predict points scored by players in a game using R and JAGS. I have 5 predictors, and the basic linear regression model is of the form:
points = beta0 + (beta1 * x1) + (beta2 * x2) + (beta3 * x3) + (beta4 * x4) + (beta5 * x5)
As each player is unique, I have added a hierarchy using the following JAGS model string:
model {
for ( i in 1:Ntotal ) {
y[i] ~ dnorm( dmu[i], tau )
dmu[i] <- beta0[p[i]] + beta[p[i],1]*x[i,1] + beta[p[i],2]*x[i,2] + beta[p[i],3]*x[i,3]
+ beta[p[i],4]*x[i,4] + beta[p[i],5]*x[i,5]
}
for ( subject_p in 1:n_subjects ) {
beta0[subject_p] ~ dnorm( dmu0 , 1/Var0 )
for ( z in 1:Ncols ) {
beta[subject_p,z] ~ dnorm( mu[z], 1/Var[z] )
}
}
tau ~ dgamma(0.01, 0.01)
"p" in p[i] is the id of a given player.
mu[z] and Var[z] are specified individually, along the lines of:
mu[1] <- 5
Var[1] <- 0.1
By monitoring "beta0" and "beta" I get posterior estimates for beta parameters for each player (beta[1,1], beta[1,2] ...). I also want to extract the value of each beta parameter for the group of players (e.g., beta[1], beta[2]...)
If it helps, suppose beta[1,2] (the coefficient of predictor 2 for player 1) was 2.3, and I interpret this as "for each unit increase in predictor 2, the predicted points for player 1 increases by 2.3 (on average)". I would like to extract the overall beta parameter values so I could say something like "overall, a one unit increase in predictor 2 increases a player's predicted points by x (on average)".
Is this possible? And how would I modify my model string to achieve it?