[R] SEM - singularity error

nicolette.cagle at duke.edu nicolette.cagle at duke.edu
Thu Sep 20 21:05:51 CEST 2007


Dear John,

Thank you so much for your assistance, it is greatly appreciated. You are
correct in your interpretation of the variables (Moist and Hab are latent, the
other, lower case variables are observed). I've attempted to run the model
again adding Moist <-> Hab (please see code below) and still receive the same
error message:

"Error in solve.default(C) : system is computationally singular: reciprocal
condition number = 6.59035e-17."

Is it possible that something is wrong with the variance-covariance matrix
(please see pasted below r code)? Are extremely small values (e.g., 4e-4)
problematic? Do you have any additional suggestions as to how I might go about
trouble shooting this problem?

I am also attaching the jpeg model diagram, in case it could be of use to you.

Thank you so much for your time.
Best wishes,
Nicki

R CODE USED:
# 20 Sep 2007 SEM of Thamnophis abundance

# LOADING R PACKAGES
library(sem)

# READING IN THE CSV FILES
thsi.2006<-read.csv("thsi_ab_env_space_sem.csv")
thsi<-thsi.2006

# MAKING "RAM" FILE 3
model3.nlc <-specify.model()
Moist->slope, NA, 1
Moist->sand, lamda21, NA
Moist->clay, lamda31, NA
Hab->isol, NA, 1
Hab->edgedist_a, lamda52, NA
Hab->ag10, lamda62, NA
Hab->urb10, lamda72, NA
Hab->rd10, lamda82, NA
Hab->y, lamda92, NA
Moist->this, gamma11, NA
Hab->this, gamma12, NA
slope<->slope, theta11, NA
sand<->sand, theta22, NA
clay<->clay, theta33, NA
isol<->isol, theta44, NA
edgedist_a<->edgedist_a, theta55, NA
ag10<->ag10, theta66, NA
urb10<->urb10, theta77, NA
rd10<->rd10, theta88, NA
y<->y, the99, NA
Moist<->Moist, phi11, NA
Hab<->Hab, phi22, NA
Moist<->Hab, phi21, NA
this<->this, theps11, NA

model3.nlc
end

# MAKING S (COVARIANCE MATRIX)
thsi.var <- var(thsi)

# MAKING UNSCALED SEM MODEL
sem3<-sem(ram=model3.nlc, S=thsi.var, N=22)

VARIANCE-COVARIANCE MATRIX (AKA: thsi.var):
   this
this          8.88528139
edgedist_a   44.91469329
isol       2678.38321991
ag10         -0.38967619
urb10         0.11704827
rd10          0.02132100
slope        -2.25074394
clay        -36.19339827
sand         19.66753247
y            -0.95970602
              edgedist_a
this          44.9146933
edgedist_a 17491.7873712
isol       96122.5594957
ag10          -9.1045614
urb10          1.9439758
rd10           0.5333281
slope         24.4351358
clay       -1360.1102116
sand         619.1507519
y            -15.4852253
                    isol
this          2678.38322
edgedist_a   96122.55950
isol       4167108.48214
ag10          -347.26757
urb10           91.79339
rd10            25.71996
slope         -392.44092
clay        -42236.76039
sand         19461.19308
y             -868.20597
                    ag10
this         -0.38967619
edgedist_a   -9.10456137
isol       -347.26756672
ag10          0.05167298
urb10        -0.01314388
rd10         -0.00297957
slope         0.06923224
clay          3.17604271
sand         -1.61043719
y             0.11896881
                  urb10
this        0.117048268
edgedist_a  1.943975810
isol       91.793388529
ag10       -0.013143880
urb10       0.003733677
rd10        0.000784747
slope      -0.039094302
clay       -0.907067141
sand        0.491619654
y          -0.034343332
                    rd10
this        0.0213209957
edgedist_a  0.5333280831
isol       25.7199633947
ag10       -0.0029795700
urb10       0.0007847471
rd10        0.0001987203
slope      -0.0041496227
clay       -0.2726142316
sand        0.1286087229
y          -0.0078502982
                   slope
this       -2.250744e+00
edgedist_a  2.443514e+01
isol       -3.924409e+02
ag10        6.923224e-02
urb10      -3.909430e-02
rd10       -4.149623e-03
slope       2.520968e+00
clay        3.343637e+00
sand       -2.202094e+00
y           3.306712e-01
                    clay
this       -3.619340e+01
edgedist_a -1.360110e+03
isol       -4.223676e+04
ag10        3.176043e+00
urb10      -9.070671e-01
rd10       -2.726142e-01
slope       3.343637e+00
clay        7.962072e+02
sand       -3.410372e+02
y           1.096320e+01
                    sand
this          19.6675325
edgedist_a   619.1507519
isol       19461.1930766
ag10          -1.6104372
urb10          0.4916197
rd10           0.1286087
slope         -2.2020936
clay        -341.0372225
sand         165.1578113
y             -5.4148540
                       y
this       -9.597060e-01
edgedist_a -1.548523e+01
isol       -8.682060e+02
ag10        1.189688e-01
urb10      -3.434333e-02
rd10       -7.850298e-03
slope       3.306712e-01
clay        1.096320e+01
sand       -5.414854e+00
y           3.694397e-01


Quoting John Fox <jfox at mcmaster.ca>:

> Dear Nicolette and Chuck,
>
> I apologize for not seeing Nicolette's original posting.
>
> The model does appear to be correctly specified (though I didn't see
> the path diagram) and over-identified. I assume that all of the
> variables with lower-case names are observed variables and that "Moist"
> and "Hab" are latent variables. (Simply comparing the number of free
> parameters to the number of unique covariances among observed variables
> provides a necessary but not sufficient condition for identification.
> This model is identified because there more than two unique indicators
> for each latent variable and because the structural submodel relating
> "this" to "Moist" and "Hab" is identified.)
>
> I suspect that the problem here is the restriction that "Moist" and
> "Hab" are uncorrelated, which follows from the lack of a double-headed
> arrow connecting these variables. You might try adding Moist <-> Hab to
> the model.
>
> I hope this helps,
> John
>
>
> On Thu, 20 Sep 2007 12:40:06 -0400
> Chuck Cleland <ccleland at optonline.net> wrote:
>> nicolette.cagle at duke.edu wrote:
>> > Good morning,
>> >
>> > I am trying to develop a structural equation model of snake
>> abundance using
>> > habitat variables. In attempting to estimate the model using the
>> "sem" package
>> > in R version 2.4.0, I receive the following error message:
>> >
>> > "Error in solve.default(C) : system is computationally singular:
>> reciprocal
>> > condition number = 1.75349e-16"
>> >
>> > MAIN PROBLEM: I am hoping to discover why I am receiving the
>> aforementioned
>> > error message and how to successfully estimate the model.
>> >
>> > OTHER INFORMATION:
>> > 1. I believe the model is over-identified rather than
>> under-identified (based on
>> > my understanding of the t-rule). I have observed data for 10
>> variables (9
>> > exogenous, 1 endogenous).
>> >
>> > 2. I am not certain that I have used the proper tool to estimate
>> the covariance
>> > matrix. In this case, I used the "VAR" function.
>> >
>> > 3. I am most concerned that I have improperly coded the RAM file.
>> For example,
>> > in a case where I have three exogenous indicators of one exogenous
>> latent
>> > variable, I specify a start value of 1 for one of the exogenous
>> indicators. I
>> > am not sure if this is proper or necessary.
>> >
>> > 4. I am new to SEM; this is the first model I have ever tried to
>> estimate.
>> >
>> > R CODE: Below is the r-code I have used to estimate the structural
>> equation
>> > model --
>> >
>> > # LOADING R PACKAGES
>> > library(sem)
>> >
>> > # READING IN THE CSV FILES
>> > thsi.2006<-read.csv("thsi_ab_env_space_sem.csv")
>> > thsi<-thsi.2006
>> >
>> > # MAKING "RAM" FILE 2
>> > model2.nlc <-specify.model()
>> > Moist->slope, NA, 1
>> > Moist->sand, lamda21, NA
>> > Moist->clay, lamda31, NA
>> > Hab->isol, NA, 1
>> > Hab->edgedist_a, lamda52, NA
>> > Hab->ag10, lamda62, NA
>> > Hab->urb10, lamda72, NA
>> > Hab->rd10, lamda82, NA
>> > Hab->y, lamda92, NA
>> > Moist->this, gamma11, NA
>> > Hab->this, gamma12, NA
>> > slope<->slope, theta11, NA
>> > sand<->sand, theta22, NA
>> > clay<->clay, theta33, NA
>> > isol<->isol, theta44, NA
>> > edgedist_a<->edgedist_a, theta55, NA
>> > ag10<->ag10, theta66, NA
>> > urb10<->urb10, theta77, NA
>> > rd10<->rd10, theta88, NA
>> > y<->y, the99, NA
>> > Moist<->Moist, phi11, NA
>> > Hab<->Hab, phi22, NA
>> > this<->this, theps11, NA
>> >
>> > model2.nlc
>> > end
>> >
>> > # MAKING S (COVARIANCE MATRIX)
>> > thsi.var <- var(thsi)
>> >
>> > # MAKING UNSCALED SEM MODEL
>> > sem2<-sem(ram=model2.nlc, S=thsi.var, N=22)
>> >
>> > I am also attaching a jpeg diagram of the model I am trying to
>> estimate. Please
>> > let me know if there is any additional information that I should
>> add to this
>> > posting.
>> >
>> > Thank you so much for your time.
>> > Nicolette Cagle
>>
>>   Your specification of the model seems OK and it is over-identified
>> (21
>> free parameters and 34 df).  I suspect the problem is that one or
>> more
>> of your 10 variables is a linear function of the remaining variables.
>> If that is the case, then the following should give the same
>> singularity
>> error:
>>
>> factanal(thsi, factors=1)
>>
>>   You may be able to drop one or more of the 10 variables from
>> consideration and successfully estimate a conceptually similar model.
>>
>> hope this helps,
>>
>> Chuck Cleland
>>
>> >
>>
> ------------------------------------------------------------------------
>> >
>> > ______________________________________________
>> > R-help at r-project.org 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.
>>
>> --
>> Chuck Cleland, Ph.D.
>> NDRI, Inc.
>> 71 West 23rd Street, 8th floor
>> New York, NY 10010
>> tel: (212) 845-4495 (Tu, Th)
>> tel: (732) 512-0171 (M, W, F)
>> fax: (917) 438-0894
>>
>> ______________________________________________
>> R-help at r-project.org 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.
>
> --------------------------------
> John Fox, Professor
> Department of Sociology
> McMaster University
> Hamilton, Ontario, Canada
> http://socserv.mcmaster.ca/jfox/
>



-- 
Ecology Ph.D. Candidate
Duke University
Durham, NC 27708
www.duke.edu/~nlc4


More information about the R-help mailing list