[R] structural equations using sem package

Soon Yi soon.yi at ymail.com
Sun Nov 4 20:27:12 CET 2012


Hello

I am using sem to look at the direct effect of one variable on another but i am uncertain if i am progressing correctly.

An example:

covar1<-  matrix(c(0.4,-0.2,3,-0.2 , 0.3,-2 , 3 ,-2 , 60), nrow=3,byrow=T)

rownames(covar1)<-colnames(covar1)<-c("endo","exo","med")

path1<-matrix(c(    "exo -> endo",  "g1", NA,
                          "exo -> med", "g2",  NA,
                          "med -> endo", "g3", NA
                            "med<->med",NA,1,
                            "endo<->endo",NA,1),  ncol=3,byrow=T)

output2<-sem(path1,covar1,N=400,fixed=c("exo"))
summary(output)

With this i can get the direct effect of exo on endo.


 But  if i want 'med' above to be a latent variable that is identified by a number of variables - in the example below i use just one - do i proceed as follows.     

      
##With latent variable
path2<-matrix(c(   "exo -> endo", "g1",NA,
                     "exo -> latent", "g2",  NA,
                     "latent -> endo","g3", NA,
                     "latent -> med", "g4", NA,
                      "med<->med",NA,1,                     "endo<->endo",NA,1  ,
                   "latent<->latent",NA,1), ncol=3,byrow=T)


output2<-sem(path2,covar1,N=400,fixed=c("exo"))   


Is this the correct way to formulate this please?

thanks for any advice      


More information about the R-help mailing list