Zhiyong Zhang's Psychometric Website
 
Home Control Panel Login Register Search Submit Logout About me Contact me
My Research
Google
Web
This Site
Home > WinBUGS codes for latent basis growth curve model
WinBUGS codes for latent basis growth curve model
2006-11-17    Zhang, Z.       Read: 7112 times
Cite this page: Zhang, Z. (2006). WinBUGS codes for latent basis growth curve model. Retrieved December 4, 2024, from https://www.psychstat.org/us/article.php/65.htm.
WinBUGS codes for latent basis growth curve model

Appendix A. WinBUGS program for the latent basis model generated from BAUW

#model specification

model{

  for (i in 1:N){

    LS[i,1:2]~dmnorm(Mu[i,1:2], Inv_cov[1:2,1:2])

    Mu[i,1]<-bL[1]

    Mu[i,2]<-bS[1]

    for (t in 1:T){

      y[i,t]~dnorm(MuY[i,t], Inv_sig_e)

      MuY[i,t]<-LS[i,1]+LS[i,2]*A[t]

    }

  }

#Prior distribution, can be changed to use informative prior

  for (i in 1:1){

    bL[i]~dnorm(0,1.0E-6)

    bS[i]~dnorm(0,1.0E-6)

  }

  A[1]<-0

  for (t in 2:T-1){

    A[t]~dnorm(0,1.0E-6)

  }

  A[T]<-1

  Inv_cov[1:2,1:2]~dwish(R[1:2,1:2], 2)

  R[1,1]<-1

  R[2,2]<-1

  R[2,1]<-R[1,2]

  R[1,2]<-0

  Inv_sig_e~dgamma(.001,.001)

  #Transform the parameters

  Cov[1:2,1:2]<-inverse(Inv_cov[1:2,1:2])

  Sig_L<-Cov[1,1]

  Sig_S<-Cov[2,2]

  rho<-Cov[1,2]/sqrt(Cov[1,1]*Cov[2,2])

  Sig_e<-1/Inv_sig_e

  #all parameter are put into Para

  Para[1]<-Sig_L

  Para[2]<-Sig_S

  Para[3]<-Cov[1,2]

  Para[4]<-rho

  Para[5]<-Sig_e

  Para[6]<-bL[1]

  Para[7]<-bS[1]

  Para[8]<-A[2]

  Para[9]<-A[3]

 } #end of model part

 

#Starting values

#You can change the starting values by yourself here.

 list(Inv_cov= structure(.Data = c(1,0,0,1),.Dim=c(2,2)), Inv_sig_e=1,

  A=c(NA,0.333333,0.666667,NA),

  bL=c(2),bS=c(3))

 

#Data

 

list(N=173,T=4,y = structure(.Data = c(2.6,4.9,5.5,7.2,

......

1.8,3.9,NA,NA), .Dim = c(173,4)))
Submitted by: johnny
Add a comment View comment Add to my favorite Email to a friend Print
If you want to rate, please login first, or click here to register. Or you can use USERNAME: guest and PASSWORD: guest to log in.
Average score 0, based on 0 comments
1 2 3 4 5 6 7 8 9 10
Copyright © 2003-13 Zhiyong Zhang \'s Psychometric Website
Maintained by Zhiyong Zhang