[R] sem vs. LISREL: sem fails
John Fox
jfox at mcmaster.ca
Tue Apr 10 03:46:03 CEST 2007
Dear Dimitri,
You haven't done anything wrong: Your model is a straightforward
confirmatory factor analysis and it is correctly specified. I suspect that
sem() is picking poor start values.
I can get a solution by specifying two alternative models that are
equivalent to yours:
(1) Rescaling the problem by using correlation-matrix input:
sem.anxiety <- sem(model, KM, N=150)
(2) Fixing the variances of the factors (latent variables) rather than using
reference indicators:
model.2 <- specify.model()
ANXIETY -> a1, lam_anx_1, NA
ANXIETY -> a2, lam_anx_2, NA
ANXIETY -> a3, lam_anx_3, NA
DEPRESS -> d1, lam_dep_1, NA
DEPRESS -> d2, lam_dep_2, NA
DEPRESS -> d3, lam_dep_3, NA
FEAR -> f1, lam_fear_1, NA
FEAR -> f2, lam_fear_2, NA
FEAR -> f3, lam_fear_3, NA
a1 <-> a1, theta_a1, NA
a2 <-> a2, theta_a2, NA
a3 <-> a3, theta_a3, NA
d1 <-> d1, theta_d1, NA
d2 <-> d2, theta_d2, NA
d3 <-> d3, theta_d3, NA
f1 <-> f1, theta_f1, NA
f2 <-> f2, theta_f2, NA
f3 <-> f3, theta_f3, NA
ANXIETY <-> ANXIETY,NA, 1
DEPRESS <-> DEPRESS,NA, 1
FEAR <-> FEAR, NA, 1
ANXIETY <-> FEAR, phi_AF, NA
ANXIETY <-> DEPRESS,phi_AD, NA
DEPRESS <-> FEAR, phi_DF, NA
# Running the estimation using sem:
sem.anxiety.2 <- sem(model.2, COVAR, N=150)
A couple of small points unrelated to the problem you experienced: (1) You
didn't need to load the MASS package, since you didn't appear to use
anything in it; (2) comments in R are prefixed by #, not !.
I hope this helps,
John
--------------------------------
John Fox
Department of Sociology
McMaster University
Hamilton, Ontario
Canada L8S 4M4
905-525-9140x23604
http://socserv.mcmaster.ca/jfox
--------------------------------
> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of John Smith
> Sent: Monday, April 09, 2007 5:28 PM
> To: r-help at stat.math.ethz.ch
> Subject: [R] sem vs. LISREL: sem fails
>
> I am new to R.
> I just tried to recreate in R (using sem package and the
> identical input data) a solution for a simple measurment
> model I have found before in LISREL. LISREL had no problems
> and converged in just 3 iterations.
> In sem, I got no solution, just the warning message:
>
> "Could not compute QR decomposition of Hessian.
> Optimization probably did not converge.
> in: sem.default(ram = ram, S = S, N = N, param.names = pars,
> var.names = vars, "
>
> What does it mean? Maybe I am doing something wrong?
>
> I have 3 latent factors (Anxiety, Depression, and Fear) -
> each of them has 3 observed indicators (a1, a2, a3; d1, d2,
> d3, and f1, f2, f3) Below is my script in R:
>
> ! ANALYSIS OF ANXIETY, DEPRESSION, AND FEAR - LISREL P.31
>
> ! Creating the ANXIETY, DEPRESSION, AND FEAR intercorrelation
> matrix (KM):
> KM<-matrix(
> c(1,.8,.83,.2,.21,.19,.18,.18,.18,
> 0,1,.81,.22,.24,.18,.19,.19,.21,
> 0,0,1,.22,.19,.2,.2,.2,.22,
> 0,0,0,1,.84,.82,.22,.22,.21,
> 0,0,0,0,1,.84,.19,.18,.19,
> 0,0,0,0,0,1,.18,.18,.18,
> 0,0,0,0,0,0,1,.84,.82,
> 0,0,0,0,0,0,0,1,.81,
> 0,0,0,0,0,0,0,0,1), 9, 9)
>
> ! Creating the ANXIETY, DEPRESSION, AND FEAR Standard
> Deviations vector (SD):
> SD<-c(1.5, 2.4, 3.2, 2.3, 2.3, 2.6, 4.5, 4.7, 5.6)
>
> ! Calculating the Var-Covar matrix based on correlations and SDs:
> library(MASS)
> COVAR<-outer(SD, SD) * KM
>
> ! Creating variable names
> rownames(COVAR)<-colnames(COVAR)<-c('a1','a2','a3','d1','d2','
> d3','f1','f2','f3')
>
> ! Specifying the measurement model to estimate:
> model<-specify.model()
> ANXIETY -> a1, NA, 1
> ANXIETY -> a2, lam_anx_2, NA
> ANXIETY -> a3, lam_anx_3, NA
> DEPRESS -> d1, NA, 1
> DEPRESS -> d2, lam_dep_2, NA
> DEPRESS -> d3, lam_dep_3, NA
> FEAR -> f1, NA, 1
> FEAR -> f2, lam_fear_2, NA
> FEAR -> f3, lam_fear_3, NA
> a1 <-> a1, theta_a1, NA
> a2 <-> a2, theta_a2, NA
> a3 <-> a3, theta_a3, NA
> d1 <-> d1, theta_d1, NA
> d2 <-> d2, theta_d2, NA
> d3 <-> d3, theta_d3, NA
> f1 <-> f1, theta_f1, NA
> f2 <-> f2, theta_f2, NA
> f3 <-> f3, theta_f3, NA
> ANXIETY <-> ANXIETY, phi_AA, NA
> DEPRESS <-> DEPRESS, phi_DD, NA
> FEAR <-> FEAR, phi_FF, NA
> ANXIETY <-> FEAR, phi_AF, NA
> ANXIETY <-> DEPRESS, phi_AD, NA
> DEPRESS <-> FEAR, phi_DF, NA
>
> ! Running the estimation using sem:
> sem.anxiety<-sem(model, COVAR, N=150)
>
> Thank you very much for your advice!
> Dimitri
>
>
>
> ______________________________________________________________
> ______________________
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
More information about the R-help
mailing list