[R] sem: incorrect parameter estimates
John Fox
jfox at mcmaster.ca
Thu Jul 18 15:30:23 CEST 2002
Dear Baxter,
I suspect that there's a numerical problem here in nlm (the minimizer that
sem uses) because of the different magnitudes of the parameters. I found
that sem required 7 iterations even when it is started at the correct solution.
When I tried fitting the model to standardized variables, I got the correct
solution immediately:
> p.sd <- sqrt(diag(p.cov))
> p.cor <- p.cov/outer(p.sd, p.sd)
> p.ram.cor <- matrix(c( 'A->B', 'p1', NA,
+ 'B->C', 'p2', NA,
+ 'B<>B', 'p3', NA,
+ 'D->B', 'p4', NA,
+ 'C<>C', 'p5', NA
+ ), ncol=3, byrow=T)
>
> p.sem.cor <- sem(p.ram.cor, p.cor, 293, fixed.x=c('A','D'))
> p.sem.cor
Model Chisquare = 69.73743 Df = 2
p1 p2 p3 p4 p5
0.78408275 0.76667339 0.30200657 0.06088651 0.41221191
Iterations = 0
This is as it should be, since for this model, the OLS estimates computed
for the start values are the FIML estimates.
It seems to me that there are two issues here: (1) The different magnitudes
of the parameters are causing problems. I may be able to improve the way
sem passes the optimization problem to nlm. I'll take a look at this. (2)
In some cases the start values produced by sem are not good, particularly
for models with unstandardized variables. I've fiddled with this problem a
bit without much success, which is primarily why I've kept sem below
version 1.0. When I have a chance, I'll take another look at the start values.
Thanks for this example,
John
At 10:57 PM 7/17/2002 -0500, Baxter Rogers wrote:
>Hello.
>
>I am getting results from sem that are not correct (that's assuming
>that the results from my AMOS 4.0 software are correct). sem does not
>vary some of the parameters substantially from their starting values,
>and the final estimates of those parameters as well as the model
>chisquare value are incorrect. I've attached some code that
>replicates the problem. The parameters in question are the residual
>variances of the endogenous variables B and C.
>
>A couple of things: the coefficents for the one-headed paths are on a
>much different scale than those for the two-headed paths (1e-1 vs
>1e6). I had to supply starting values, because the automatic ones
>were not reasonable (1e19) and caused a "singular matrix" error. Is
>this possibly just a numerical issue?
>
>Thanks for any help!
>
>Baxter Rogers
>
>
>
>
>======= begin R code =======
>
># 071702 Baxter P. Rogers (rogers at mr.radiology.wisc.edu)
>#
># Self-contained demonstration of the sem package's failure to modify
># covariances from their starting values. (This happens for numerical
># or analytic gradient calculation.) Starting values are supplied
># because the default ones cause a "singular matrix" error.
>
># covariance matrix
>p.cov <- matrix(c( 6330357, 3398673, 3547333, 4764233,
> 3398673, 2618468, 2194462, 2626567,
> 3547333, 2194462, 3128874, 2869895,
> 4764233, 2626567, 2869895, 5171829
> ), ncol=4, byrow=T)
>rownames(p.cov) <- colnames(p.cov) <- c('A','B','C','D')
>
># RAM specification
>p.ram <- matrix(c( 'A->B', 'p1', 0.2,
> 'B->C', 'p2', 0.2,
> 'B<>B', 'p3', 1e6,
> 'D->B', 'p4', 0.2,
> 'C<>C', 'p5', 1e6
> ), ncol=3, byrow=T)
>
>p.sem <- sem(p.ram, p.cov, 293, fixed.x=c('A','D'), debug=T,
>analytic.gradient=F)
>
>print(summary(p.sem))
>
>cat('\n\nFinal parameter values:\n')
>print(p.sem$coeff,digits=2)
>
>cat('\nExpected final values (from AMOS software):\n')
>cat('5.0e-01 8.4e-01 7.9e+05 4.3e-02 1.3e+06\n\n')
>
>cat('\n\nThe chisquare value from the AMOS fit is 69.7.\n')
>
>====== end R code =======
>
>
>--
>Baxter Rogers (rogers at mr.radiology.wisc.edu)
>UW Madison Medical Physics Department, fMRI
>Madison, Wisconsin, USA
>http://zoot.radiology.wisc.edu/~rogers/
>
>
>-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
>r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
>Send "info", "help", or "[un]subscribe"
>(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
>_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
-----------------------------------------------------
John Fox
Department of Sociology
McMaster University
Hamilton, Ontario, Canada L8S 4M4
email: jfox at mcmaster.ca
phone: 905-525-9140x23604
web: www.socsci.mcmaster.ca/jfox
-----------------------------------------------------
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list