sem error "no variance or error-variance parameter"

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

sem error "no variance or error-variance parameter"

Jan Schubert
Hi,
I am sorry to post the message again but I really need some advise on that.
I am using the R version 2.11.0 and the version of sem package: sem_0.9-20 under Windows XP.
I read the questions:
http://r.789695.n4.nabble.com/computationally-singular-and-lack-of-variance-parameters-in-SEM-td891081.html#a891082

and

http://r.789695.n4.nabble.com/computationally-singular-and-lack-of-variance-parameters-in-SEM-td891081.html#a891081

but it does not seem to be my problem. I try to replicate the sem model (see the attacheted image) but i got stuck with the problem while computing the estimates of the model:
The error message:

Error in nlm(if (analytic.gradient) objective.2 else objective.1, start,  :
  probable coding error in analytic gradient
In addition: Warning message:
In sem.default(ram = ram, S = S, N = N, param.names = pars, var.names = vars,  :
  The following variables have no variance or error-variance parameter (double-headed arrow):
 Fugural1
The model is almost surely misspecified; check also for missing covariances.

Here is my script:

cov.matrix <- matrix(c(56.21,0,0,0,0,0,0,0,0,31.55,75.55,0,0,0,0,0,0,0,23.27,28.30,44.45,0,0,0,0,0,0,24.48,32.24,22.56,84.64,0,0,0,0,0,22.51,29.54,20.61,57.61,78.93,0,0,0,0,22.65,27.56,15.33,53.57,49.27,73.76,0,0,0,33.24,46.49,31.44,67.81,54.76,54.58,141.77,0,0,32.56,40.37,25.58,55.82,55.33,47.74,98.62,117.33,0,30.32,40.44,27.69,54.78,53.44,59.52,96.95,84.87,106.35),nrow=9,ncol=9,byrow=FALSE)
rownames(cov.matrix) <- colnames(cov.matrix) <- c("IND1","IND2","IND3","FR11","FR12","FR13","FR21","FR22","FR23")

# options(nlm=(check.analyticals = TRUE)); I tried to set the nlm on different option, but did not work either

m1 <- specify.model()
Induction -> IND1, NA, 1
Induction -> IND2, y2, NA
Induction -> IND3, y3, NA
Fugural1 -> FR11, NA, 1
Figural1 -> FR12, y5, NA
Figural1 -> FR13, y6, NA
Figural2 -> FR21, NA, 1
Figural2 -> FR22, y8, NA
Figural2 -> FR23, y9, NA
Induction -> Figural1, x1, NA
Figural1 -> Figural2,x2, NA
Induction -> Figural2, x3, NA
IND1 <-> IND1, e1, NA
IND2 <-> IND2, e2, NA
IND3 <-> IND3, e3, NA
FR11 <-> FR11, e4, NA
FR12 <-> FR12, e5, NA
FR13 <-> FR13, e6, NA
FR21 <-> FR21,e7, NA
FR22 <-> FR22, e8, NA
FR23 <-> FR23, e9, NA
Figural1 <-> Figural1, e10, NA
Figural2 <-> Figural2, e11, NA
Induction <-> Induction, NA, 1

sem1 <- sem(m1,cov.matrix,N=220,debug=T)

# I added the Induction <-> Induction, NA, 1 fixed parametr after reading the help from John Fox, that every variable should have an error variance


Can anybody please advise me what I am doing wrong?
Many thanks!

Jan Schubert
Institute of Social Science
Charles University, Prague
Reply | Threaded
Open this post in threaded view
|

Re: sem error "no variance or error-variance parameter"

Nordlund, Dan (DSHS/RDA)
> -----Original Message-----
> From: [hidden email] [mailto:r-help-bounces@r-
> project.org] On Behalf Of Jan Schubert
> Sent: Tuesday, May 18, 2010 12:51 PM
> To: [hidden email]
> Subject: [R] sem error "no variance or error-variance parameter"
>
>
> Hi,
> I am sorry to post the message again but I really need some advise on
> that.
> I am using the R version 2.11.0 and the version of sem package:
> sem_0.9-20
> under Windows XP.
> I read the questions:
> http://r.789695.n4.nabble.com/computationally-singular-and-lack-of-
> variance-parameters-in-SEM-td891081.html#a891082
>
> and
>
> http://r.789695.n4.nabble.com/computationally-singular-and-lack-of-
> variance-parameters-in-SEM-td891081.html#a891081
>
> but it does not seem to be my problem. I try to replicate the sem model
> (see
> the attacheted image) but i got stuck with the problem while computing
> the
> estimates of the model:
> The error message:
>
> Error in nlm(if (analytic.gradient) objective.2 else objective.1,
> start,  :
>   probable coding error in analytic gradient
> In addition: Warning message:
> In sem.default(ram = ram, S = S, N = N, param.names = pars, var.names =
> vars,  :
>   The following variables have no variance or error-variance parameter
> (double-headed arrow):
>  Fugural1
> The model is almost surely misspecified; check also for missing
> covariances.
>
> Here is my script:
>
> cov.matrix <-
> matrix(c(56.21,0,0,0,0,0,0,0,0,31.55,75.55,0,0,0,0,0,0,0,23.27,28.30,44
> .45,0,0,0,0,0,0,24.48,32.24,22.56,84.64,0,0,0,0,0,22.51,29.54,20.61,57.
> 61,78.93,0,0,0,0,22.65,27.56,15.33,53.57,49.27,73.76,0,0,0,33.24,46.49,
> 31.44,67.81,54.76,54.58,141.77,0,0,32.56,40.37,25.58,55.82,55.33,47.74,
> 98.62,117.33,0,30.32,40.44,27.69,54.78,53.44,59.52,96.95,84.87,106.35),
> nrow=9,ncol=9,byrow=FALSE)
> rownames(cov.matrix) <- colnames(cov.matrix) <-
> c("IND1","IND2","IND3","FR11","FR12","FR13","FR21","FR22","FR23")
>
> # options(nlm=(check.analyticals = TRUE)); I tried to set the nlm on
> different option, but did not work either
>
> m1 <- specify.model()
> Induction -> IND1, NA, 1
> Induction -> IND2, y2, NA
> Induction -> IND3, y3, NA
> Fugural1 -> FR11, NA, 1
> Figural1 -> FR12, y5, NA
> Figural1 -> FR13, y6, NA
> Figural2 -> FR21, NA, 1
> Figural2 -> FR22, y8, NA
> Figural2 -> FR23, y9, NA
> Induction -> Figural1, x1, NA
> Figural1 -> Figural2,x2, NA
> Induction -> Figural2, x3, NA
> IND1 <-> IND1, e1, NA
> IND2 <-> IND2, e2, NA
> IND3 <-> IND3, e3, NA
> FR11 <-> FR11, e4, NA
> FR12 <-> FR12, e5, NA
> FR13 <-> FR13, e6, NA
> FR21 <-> FR21,e7, NA
> FR22 <-> FR22, e8, NA
> FR23 <-> FR23, e9, NA
> Figural1 <-> Figural1, e10, NA
> Figural2 <-> Figural2, e11, NA
> Induction <-> Induction, NA, 1
>
> sem1 <- sem(m1,cov.matrix,N=220,debug=T)
>
> # I added the Induction <-> Induction, NA, 1 fixed parametr after
> reading
> the help from John Fox, that every variable should have an error
> variance
>
>
> Can anybody please advise me what I am doing wrong?
> Many thanks!
>
> Jan Schubert
> Institute of Social Science
> Charles University, Prague
> --

Jan,

I didn't go through your model in detail, but if you look carefully at the error message, you appear to have misspelled Figural1 as Fugural1.  When I corrected that problem, your example ran without error.

Hope this is helpful,

Dan

Daniel J. Nordlund
Washington State Department of Social and Health Services
Planning, Performance, and Accountability
Research and Data Analysis Division
Olympia, WA 98504-5204


______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: sem error "no variance or error-variance parameter"

Jan Schubert
In reply to this post by Jan Schubert
Hi,
many thanks for the help (i would swear I controlled the model specification like 15 times...).
It runs correctly now!

Best wishes,

Jan Schubert
Institute of Social Science
Charles University, Prague