[R] computationally singular and lack of variance parameters in SEM
John Fox
jfox at mcmaster.ca
Sat May 2 01:44:12 CEST 2009
Dear Elizabeth,
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
On
> Behalf Of Elizabeth Pringle
> Sent: May-01-09 6:59 PM
> To: r-help at r-project.org
> Subject: [R] computationally singular and lack of variance parameters in
SEM
>
> Hi all,
>
> I am trying to set up a simple path analysis in the SEM package, but I am
> having some trouble. I keep getting the following error message or
something
> similar with my model, and I'm not sure what I'm doing wrong:
> Error in solve.default(C) :
> system is computationally singular: reciprocal condition number =
2.2449e-
> 20 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):
> Ants, Herbivory
> The model is almost surely misspecified; check also for missing
covariances.
>
> I have tried my data set with both a correlation (cor) and a variance
(var)
> matrix, but both produce the same error, and I'm not sure which one is
> correct. The error message about the variables that have no variance or
> error-variance parameters are for my exogenous variables (or those that I
am
> not listing as "fixed.x=" in the model). I have tried both single and
double
> arrows between ants and coccoids, but neither works. I am not sure that I
> know what it means for the system to be computationally singular
(sometimes
> it says it is exactly singular). I am setting N=80 because I have four
> observed variables with 20 observations each, I hope this is correct. I
have
> attached the path diagram for my model as a jpeg.
>
> My R code is the following:
>
> data<-read.table("ChamelaColonySize.csv",header=TRUE,sep=",")
>
> attach(data)
>
> cor(data,method="spearman")
>
> CorMatrix<-matrix(c(
>
> + 1, 0, 0, 0,
>
> + -0.4974, 1, 0, 0,
>
> + -0.4403, 0.7965, 1, 0,
>
> + 0.1250, 0.2602, 0.1825, 1),ncol=4,byrow=T)
>
> rownames(CorMatrix)<-colnames(CorMatrix)<-c('Herbivory','Ants','Coccoids',
> 'Space')
>
> ramcor<-specify.model()
>
> Coccoids<->Ants, gam12, NA
>
> Space->Ants, gam12, NA
>
> Ants->Herbivory,bet21, NA
>
> ?read.table
>
> sem<-sem(ram=ramcor,S=CorMatrix,N=80,fixed.x=c('Coccoids','Space'))
If Coccoids is exogenous and Ants endogenous, what can the double-headed
arrow linking the two mean? By specifying Coccoids and Space as
fixed-exogenous variables, you automatically include their covariance and
variances as parameters to be estimated (and these estimates will simply be
the corresponding observed covariance and variances, and won't be shown).
Your model, however, has no error-variance parameters for the two endogenous
variables. You also used the same parameter name, gam12, for two parameters,
which will constrain them to be equal; did you really want to do that?
Although I can't be sure, I suspect that what you want to do is
Coccoids -> Ants, gam11, NA
Space -> Ants, gam12, NA
Ants -> Herbivory, bet21, NA
Ants <-> Ants, phi11, NA
Herbivory <-> Herbivory, phi22, NA
If that's correct, then this is an observed-variable recursive model and you
could simply fit each equation by OLS regression using lm().
I hope this helps,
John
>
>
> var(data)
>
> VarMatrix<-matrix(c(
>
> + 0.73, 0, 0, 0,
>
> + -86.11, 35877.52, 0, 0,
>
> + -23.46, 11569.9, 5620.26, 0,
>
> + 0.82, 346.83, 138.21, 34.81),ncol=4,byrow=T)
>
> semVar<-sem(ram=ramcor,S=VarMatrix,N=80,fixed.x=c('Coccoids','Space'))
>
>
> Many thanks for any help.
>
> Beth
>
>
>
>
>
> --
> ****************************************************
> Elizabeth G. Pringle
> Department of Biology
> Stanford University
> Stanford, CA 94305
> (Tel): 650-725-6791
> (Fax): 650-462-5968
> ****************************************************
More information about the R-help
mailing list