Hi I am trying to run the following confirmatory factor model in JAGS.
Basically, I want to fix the diagonal elements of phi (a 15 x 15 var-cov
matrix), defined below, to 1 so that my model will be identified and
give standardized factor loadings. However, I want JAGS to estimate the
off-diagonal elements of that matrix. I am sure I have something wrong
because when I run my code I get the following error:
Error in jags.model(file = "measurement_stdyx_fixed.bug", data =
meas.dat) :
RUNTIME ERROR:
Attempt to redefine node phi[1,1]
I've pasted the model below. Thanks for the help!
Chris
model {
for(i in 1:N){
##########################
# measurement equation model
##########################
for(j in 1:P){
y[i,j]~dnorm(mu[i,j],psi[j])
}
##########################
# alp[i] corresponds to the intercepts
##########################
mu[i,1]<-xi[i,1] ## Ext1
mu[i,2]<-lam[2]*xi[i,1]
mu[i,3]<-lam[3]*xi[i,1]
mu[i,4]<-xi[i,2] ## Soc1
mu[i,5]<-lam[5]*xi[i,2]
mu[i,6]<-lam[6]*xi[i,2]
mu[i,7]<-xi[i,3] ## Aca1
mu[i,8]<-lam[8]*xi[i,3]
mu[i,9]<-lam[9]*xi[i,3]
mu[i,10]<-xi[i,4] ## Ext2
mu[i,11]<-lam[11]*xi[i,4]
mu[i,12]<-lam[12]*xi[i,4]
mu[i,13]<-xi[i,5] ## Soc2
mu[i,14]<-lam[14]*xi[i,5]
mu[i,15]<-lam[15]*xi[i,5]
mu[i,16]<-xi[i,6] ## Aca2
mu[i,17]<-lam[17]*xi[i,6]
mu[i,18]<-lam[18]*xi[i,6]
mu[i,19]<-xi[i,7] ## Work2
mu[i,20]<-lam[20]*xi[i,7]
mu[i,21]<-lam[21]*xi[i,7]
mu[i,22]<-xi[i,8] ## Ext3
mu[i,23]<-lam[23]*xi[i,8]
mu[i,24]<-lam[24]*xi[i,8]
mu[i,25]<-xi[i,9] ## Soc3
mu[i,26]<-lam[26]*xi[i,9]
mu[i,27]<-lam[27]*xi[i,9]
mu[i,28]<-xi[i,10] ## Aca3
mu[i,29]<-lam[29]*xi[i,10]
mu[i,30]<-lam[30]*xi[i,10]
mu[i,31]<-xi[i,11] ## Work3
mu[i,32]<-lam[32]*xi[i,11]
mu[i,33]<-lam[33]*xi[i,11]
mu[i,34]<-xi[i,12] ## Ext4
mu[i,35]<-lam[35]*xi[i,12]
mu[i,36]<-lam[36]*xi[i,12]
mu[i,37]<-xi[i,13] ## Soc4
mu[i,38]<-lam[38]*xi[i,13]
mu[i,39]<-lam[39]*xi[i,13]
mu[i,40]<-xi[i,14] ## Aca4
mu[i,41]<-lam[41]*xi[i,14]
mu[i,42]<-lam[42]*xi[i,14]
mu[i,43]<-xi[i,15] ## Work4
mu[i,44]<-lam[44]*xi[i,15]
mu[i,45]<-lam[45]*xi[i,15]
# Priors on Factors
xi[i,1:15]~dmnorm(u[1:15],phi[1:15,1:15])
}
# Prior on Factor Loadings
for(j in 1:45){lam[j]~dnorm(0.8,psi[j])}
# Prior on Residual
for(j in 1:P){
psi[j]~dgamma(6, 10)
}
# Fixed diagonal variances and set prior on off-diagonals.
phi[1,1] <- 1
phi[2,2] <- 1
phi[1,1] <- 1
phi[2,2] <- 1
phi[3,3] <- 1
phi[4,4] <- 1
phi[5,5] <- 1
phi[6,6] <- 1
phi[7,7] <- 1
phi[8,8] <- 1
phi[9,9] <- 1
phi[10,10] <- 1
phi[11,11] <- 1
phi[12,12] <- 1
phi[13,13] <- 1
phi[14,14] <- 1
phi[15,15] <- 1
phi[1,2:15] <- dwish(R[1,2:15], 15)
phi[2,3:15] <- dwish(R[2,3:15], 15)
phi[3,4:15] <- dwish(R[3,4:15], 15)
phi[4,5:15] <- dwish(R[4,5:15], 15)
phi[5,6:15] <- dwish(R[5,6:15], 15)
phi[6,7:15] <- dwish(R[6,7:15], 15)
phi[7,8:15] <- dwish(R[7,8:15], 15)
phi[8,9:15] <- dwish(R[8,9:15], 15)
phi[9,10:15] <- dwish(R[9,10:15], 15)
phi[10,11:15] <- dwish(R[10,11:15], 15)
phi[11,12:15] <- dwish(R[11,12:15], 15)
phi[12,13:15] <- dwish(R[12,13:15], 15)
phi[13,14:15] <- dwish(R[13,14:15], 15)
}
-------------------------------------------------------------------
This list is for discussion of modelling issues and the BUGS software.
For help with crashes and error messages, first mail [log in to unmask]
To mail the BUGS list, mail to [log in to unmask]
Before mailing, please check the archive at www.jiscmail.ac.uk/lists/bugs.html
Please do not mail attachments to the list.
To leave the BUGS list, send LEAVE BUGS to [log in to unmask]
If this fails, mail [log in to unmask], NOT the whole list
|