I guess your code uses somewhere in the second case a singular matrix (i.e. not invertible), and the solve function needs to invert it. This has nothing to do with the size but with the fact that some of your vectors are (probably) colinear.
If you receive the error "Error in solve.default(sigma): system is computationally singular: reciprocal condition number = 0" then we recommend changing the seed by re-running analyze.CumInc.stepp. If this error persists after several runs, then the program cannot provide reliable results. Please try modifying your choices of the two parameters minpatspop(r1) and patspop(r2) that define the subpopulations.
The number of permutations specified in noperm
, the sample size, and the number of subpopulations generated will affect how long analyze.CumInc.stepp takes to execute. The results are stable if 2500 or more permutations are specified. Furthermore, varying the number of subpopulations will affect inference.
----------
Using solve
with a single parameter is a request to invert a matrix. The error message is telling you that your matrix is singular and cannot be inverted.
---------
|
---------------
If it is zero then it is impossible to invert
--
you have just been unlucky with the numbers, or you have reduced the data too much to be able to ensure linear independence. The following links may be of use: m-hikari.com/imf-2010/45-48-2010/kaimakamisIMF45-48-2010.pdf arxiv.org/abs/1010.0601 – James Jul 4 '11 at 14:19
----------
> I am trying to estimate a SAR model with the lagsarlm function:
>
> SAR3nn <- lagsarlm(formula=formula(mod1),listw=list3nn.listw,type="lag",
> method="eigen", data=d)
>
> but I saw this message:
>
> Error in solve.default(inf, tol = tol.solve) :
> system is computationally singular: reciprocal condition number =
> 5.74163e-27
>
> It happens with both a k-nearest-neighbors matrix and with a distance matrix.
> If I opt for a spatial 2sls model, the result is the same. I must say that
> in the formula I have a variable and its square, which are very highly
> correlated (about 0.9). The IV model works if I drop the squared variable,
> while the lagsarlm still tells me that the system is singular.
Please see the details in ?lagsarlm, and also refer to the entry for
argument tol.solve=. It isn't just the high correlation of your variables,
but also their scaling with respect to the response and/or the spatial
coefficient. Using a different method= (say "LU") and using a power trace
vector trs= may get you there too, but re-scaling the variable will also
re-scale its square. The same problem affects the STSLS - re-scale the
variable. If these are say in Euro, use thousand, million or whatever Euro
instead, for example.
Hope this helps,
Roger
----------------
> **I want to estimate the spatial simultaneous autoregressive error model**
>
> res20<-errorsarlm(finalglm1, listw=nb20.w, zero.policy=TRUE)
>
> But here I receive the following error message:
>
> Error in solve.default(asyvar, tol = tol.solve) :
> system is computationally singular: reciprocal condition number = 2.8713e-12
>
> What is happening? What does this message mean?
?errorsarlm says:
The asymptotic standard error of $lambda$ is only computed when
method=eigen, because the full matrix operations involved would be
costly for large n typically associated with the choice of
method="spam" or "Matrix". The same applies to the coefficient
covariance matrix. Taken as the asymptotic matrix from the
literature, it is typically badly scaled, being block-diagonal,
and with the elements involving lambda being very small, while
other parts of the matrix can be very large (often many orders of
magnitude in difference). It often happens that the 'tol.solve'
argument needs to be set to a smaller value than the default, or
the RHS variables can be centred or reduced in range.
My guess would be that the scalings of the variables in finalglm1 are extreme
compared to the fitted lambda. Since you don't have much control over the
RHS, just set tol.solve=1e-12 to get a result. Given that you've manipulated
the data a good deal, I wouldn't rely on the output standard errors for
inference, though.
Roger Bivand
>
> Thanks a lot,
>
> Alberto
-------------------
You are trying to fit onto a matrix which does not have full rank---try excluding some of the variable and/or look for errors. We cannot say much more without your data, or at least a sample.
That's more of a modelling question for Crossvalidated.com than a programming question for StackOverflow.
---------
Let me be very plain: Among all your regressors, one or more are linear combinations of other columns, which implies less than full rank. –
----
To put @DirkEddelbuettel's point another way: When you estimate this via
lm()
, are there variables that get dropped from your regression? If so, then those are precisely the variables that are linear combinations of others in your model. lm()
has no problem with such variables since it contains code that automatically detects such cases. But as soon as you do all this manually, you have to do this yourself, too
--------
'R 데이터 분석' 카테고리의 다른 글
some basic checkpoints on multiple regression using small sample (0) | 2013.09.29 |
---|---|
구글트렌즈로 보는 드러커와 스티브잡스 분석[R 시계열분석] (0) | 2013.09.27 |
twitter access tmp (0) | 2013.08.29 |
[R 분석 연습] 2차원 플롯 : 밀집 영역 플로팅 (0) | 2013.06.14 |
랜덤 포리스트 random forest 응용 [R 마이닝 ] (0) | 2013.06.04 |