[R] How to use pakcage SEM

Mitsuo Igarashi mitsu5 at ruby.famille.ne.jp
Tue May 20 09:37:27 CEST 2003


Hi.

I have tried to use Package "SEM".

As a learning, I try to convert a program running well of EQS 
which is as follows to SEM:

###  EQS  ###
/SPECIFICATION
CAS=100; VAR=5 MAT=COR; ANA=COR;
/EQUATIONS
V1=*F1+E1; V2=*F1+E2; V3=*F1+*F2+E3; V4=**F1+*F2*E4;
V5=*F2+E5;
/VAR
E1 TO E5=*; F1*1.0; F2=1.0;
/COV
E1,E2=*; F1,F2=*:
/PRINT
FIT ALL;
/MATRIX ......
/END

This is the converted SEM program.
###
data.mh<-matrix(c(
1.00,0,0,0, 0,
0.38,1.00,0,0, 0,
0.52,0.28,1.00,0,0,
0.55,0.32,0.38,1.00,0,
0.36,0.40,0.48,0.31,1.00
),ncol=5,byrow=T)

model.mh<-matrix(c(
	'F1 -> V1', 'a1',NA,
	'F1 -> V3', 'a3',NA,
	'F1 -> V4', 'a4',NA,
	'F2 -> V2', 'b2',NA,
	'F2 -> V3', 'b3',NA,
	'F2 -> V4', 'b4',NA,
	'F2 -> V5', 'b5',NA,
	'V1 <-> V1','e1', 1,
	'V2 <-> V2','e2', 1,
	'V3 <-> V3','e3', 1,
	'V4 <-> V4','e4', 1,
	'V5 <-> V5','e5', 1,
	'F1 <-> F1','d1', 1,
	'F2 <-> F2','d2', 1,
	'F1 <-> F2','c12',NA,
	'V1 <-> V2','cv1', NA,
),ncol=3,byrow=T)
obs.vars.mh <- c('V1','V2','V3','V4','V5')
rownames(data.mh) <- colnames(data.mh) <- obs.vars.mh

sem.mh <- sem(model.mh, data.mh, 100)
###

At this stage, everything looks going well.
By debug mode of "sem()" it finishes with no error.
However,the process of "summary(sem.mh)" produces an error.

> summary(sem.mh)
Error in optim(0, function(lam) ((1 - conf.level)/2 - pchisq(chisq, df,  : 
        Function cannot be evaluated at initial parameters
In addition: Warning message: 
NaNs produced in: sqrt(diag(object$cov)) 

It seems to me that there is something wrong at the conversion of 
"E1 TO E5=*;"  to " 'V1 <-> V2','cv1', NA ".

Could anyone explain me how to manage this trouble?

Thanks.

--------========----------
Mitsuo Igarashi
mitsu5 at ruby.famille.ne.jp




More information about the R-help mailing list