Home Control Panel Login Register Search Submit Logout About me Contact me
 Web This Site
 Home > The R function to simulate data for the direct autoregressive factor score model
The R function to simulate data for the direct autoregressive factor score model
2006-11-17    Zhang, Z.       Read: 10018 times
Cite this page: Zhang, Z. (2006). The R function to simulate data for the direct autoregressive factor score model. Retrieved December 6, 2023, from https://www.psychstat.org/us/article.php/67.htm.
 The R function to simulate data for the direct autoregressive factor score model dafsar1<-function(n){library(mvtnorm) y<-array(,dim=c(6,n))e<-array(,dim=c(6,n)) f<-array(,dim=c(2,n))v<-array(,dim=c(2,n)) #parameter:f0<-array(c(0,0),dim=c(2,1)) h<-array(c(1,1,1,0,0,0,           0,0,0,1,1,1),dim=c(6,2)) fp<-array(c(.8,0,0,.8),dim=c(2,2))r<-array(c(1,0,0,0,0,0,           0,1,0,0,0,0,           0,0,1,0,0,0,           0,0,0,1,0,0,           0,0,0,0,1,0,           0,0,0,0,0,1),dim=c(6,6))qq<-array(c(.36,.18,.18,.36),dim=c(2,2)) for (i in 1:n){   v[,i]=t(rmvnorm(1,c(0,0),qq))   f[,i]=fp%*%f0+v[,i]   e[,i]=t(rmvnorm(1,c(0,0,0,0,0,0),r))   y[,i]=h%*%f[,i]+e[,i]   f0<-f[,i]}return(list(y=t(y)[1001:n,],f=t(f)[1001:n,],v=t(v)[1001:n,],e=t(e)[1001:n,]))} Submitted by: johnny
 Add a comment View comment Add to my favorite Email to a friend Print