0

I have a script for pgls with caper. I used this exact same script hundreds of times before, and it always worked. Today, I'm getting an error running it:

Error in solve.default(V, tol = .Machine$double.eps) : system is computationally singular: reciprocal condition number = 1.38603e-17

I can't understand that!!!! I've runned this before! I even have results for this model!!! And now it wont run!!

I saw many questions on this kind of error here in stack, mostly related to highly correlated variables... but I have already removed correlated variables. And also, this code runned before. Why not now?

library(caper)

#Defining data for pgls... phylogeny, variables, taxa names...
maxillariinae <- comparative.data(Tree_max, data.2, av_spp_code, vcv=TRUE, vcv.dim=2)

#Fit the model
pgls95a <- pgls(av_X2n ~ av_mT_dayn_rg+ av_Isotherm+   av_T_season+   av_mT_wet_Q+   av_mT_warm_Q+  av_mT_cold_Q+  av_P_season+  
              av_P_wet_Q+    av_P_dry_Q+    av_P_warm_Q+   av_P_cold_Q+   av_elevation+  life_forms+    exc_epiph, maxillariinae)

I've deleted one by one all variables and runned the model again, until I had only one variable, but I got the exact same error each time, no matter which variable I'd excluded.

I have also unloaded all packages and loaded again only the necessary ones, but it didn't get my code to work as it did before. Any tips are welcome

Thai
  • 493
  • 5
  • 15
  • 1
    Your question does not contain a [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve) (MCVE). This makes it hard to understand and answer your question. Please share relevant code, a small excerpt of your data and the expected outcome. You can find detailed information on how to create a goo MCVE for R [here](https://stackoverflow.com/q/5963269/4303162). – Stibu Oct 10 '17 at 18:04
  • you're saying that you had earlier ran this _identical_ model with _identical_ data and now it won't run? or you have collected new data and now it won't run? – rawr Oct 10 '17 at 18:51
  • It's the same data, yes... It is the exact, identical, the very same thing! What makes me more frustrated is that even keeping only two or one variable, I still get the error. How can that be? – Thai Oct 10 '17 at 19:24
  • Actually, @rawr, I'm not sure that the 92 taxa I'm using in the model didn't change at all. I think I may or may not have added some occurrence points, than the mean value for one of that 92 species would have slightly changed. I never thought that this computationally singular issue could be in the sample rather than in the variables. Do you think this can be the problem? How would I find the problem in my sample? – Thai Oct 10 '17 at 19:35
  • 1
    hard to say.. are you working with data that are almost 0? you could do a quick work-around, although it won't address the root of your problem but you may figure out the issue. if you use `pgls <- edit(pgls)`, you can add an argument to the `pgls` function (`tol = .Machine$double.eps`), and use `tol` inside the `Dfun` function which is defined at the top of `pgls`, so change `iCmat <- solve(Cmat)` to `iCmat <- solve(Cmat, tol = tol)`. then you can simply `pgls(..., tol = 1e-18)` or something smaller. If you need, `rm(pgls)` will get you back to the default function – rawr Oct 10 '17 at 21:31

0 Answers0