1
$\begingroup$

I am starting a mixed-model selection analysis with lme in R. But when I start to fit the full model:

fullmodOver <-  lme(rrF ~ Old_N_dep+Overstory_old+Altitude+MAT+MAP+EIV_R+EIV_F+Overstory_diff+SCA_old+SCA_diff, data = regdata, random = ~ 1|PlotNR, method = "REML")

I get the following error:

Error in na.fail.default(list(rrF = c(-0.0380393284017694, -0.0110047996186618,  : 
  missing values in object

Therefore I delete all missing value of variables with the following:

regdata <- regdata[!apply(regdata[,c("Overstory_old","Old_N_dep","Altitude","MAT","MAP","EIV_R","EIV_F","Overstory_diff","SCA_old","SCA_diff")], 1, anyNA),]

When I re-fit the model I get again an error:

Error in solve.default(estimates[dimE[1] - (p:1), dimE[2] - (p:1), drop = FALSE]) : 
  system is computationally singular: reciprocal condition number = 7.92883e-17

This looks similar to what described here, where - if I understand correctly - the dependent variable is perfectly correlated to one of the dependent variabes. When I try to fit the same model with lmer it doesn't give me an error, but I get results with coefficients of parameters that are very close to zero, like it happens in the stackoverflow question I linked to you before. However, my dependent and indipendent variables in the full model don't seems correlated. Initial_survey and EIV_N (higly correlated with Old_N_dep and EIV_R, respectively) are excluded from the main formula: enter image description here

Probably good to mention (I don't know if it's relevant): after checking for collinearity and before being included in the model, variables where scaled with the following code (variables considered in the model are all numerical):

###z-normalization of numerical variables
regdata<-regdata%>%
  mutate(Initial_survey = as.numeric(Initial_survey))%>%
  mutate(MAP = as.numeric(MAP))%>%
  mutate(Altitude=as.numeric(Altitude))
regdata$mNdep<-scale(regdata$mNdep)
regdata$mMAT<-scale(regdata$mMAT)
regdata$mMAP<-scale(regdata$mMAP)
regdata$Altitude<-scale(regdata$Altitude)
regdata$MAT<-scale(regdata$MAT)
regdata$MAP<-scale(regdata$MAP)
regdata$Old_N_dep<-scale(regdata$Old_N_dep)
regdata$EIV_L_new<-scale(regdata$EIV_L_new)
regdata$Overstory_new<-scale(regdata$Overstory_new)
regdata$SCA_new<-scale(regdata$SCA_new)
regdata$EIV_L_old<-scale(regdata$EIV_L_old)
regdata$EIV_R<-scale(regdata$EIV_R)
regdata$EIV_N<-scale(regdata$EIV_N)
regdata$EIV_F<-scale(regdata$EIV_F)
regdata$Overstory_old<-scale(regdata$Overstory_old)
regdata$SCA_old<-scale(regdata$SCA_old)
regdata$Overstory_diff<-scale(regdata$Overstory_diff)
regdata$SCA_diff<-scale(regdata$SCA_diff)
regdata$EIV_L_diff<-scale(regdata$EIV_L_diff)
regdata$Initial_survey<-scale(regdata$Initial_survey)

Do you have any clue on what I am missing here? Thanks.

PS: Probably you might want to take a look at the dataset but I don't know how to show you that here, (it's a quite big dataset). But I think I might show it to you if it's necessary.

$\endgroup$
5
  • $\begingroup$ If you want to share the data, you can post a link to your cloud folder (e.g. Google Drive, Box, etc.). $\endgroup$
    – Jon
    Mar 2, 2017 at 19:02
  • $\begingroup$ If your model.matrix is nonsingular, it means there is no inverse. However, I am curious, can you try to fit your model without the random effect, using gls instead? $\endgroup$
    – Jon
    Mar 2, 2017 at 19:04
  • $\begingroup$ I think your question could do with a few more details. Are all your variables numeric, no. of observations, no. of groups, no. of obs within groups. How many obs are there after removing the missing rows dim(na.omit(regdat)). [ a couple of comments on your code: lme has an na.action argument, so you could use na.action=na.omit . $\endgroup$ Mar 5, 2017 at 19:09
  • $\begingroup$ ... Using apply over a dataframe is bad practice as it coerces it to a matrix and if there are any character or factor variables , all will be converted to character: it probably easier just to do regdat <- na.omit(regdata[,c("Overstory_old", "Old_N_dep","Altitude","MAT","MAP","EIV_R","EIV_F","Overstory_diff","SCA_old","SCA_diff")]). scale can be applied over all the data, instead of one ata time: so regdat <- scale(regdat) $\endgroup$ Mar 5, 2017 at 19:09
  • $\begingroup$ Dear all, I was doing a silly mistake in model design: I was using as random effect the individual plots (i.e each row in my dataset was taken individually as a random part). When I used the regions where the plots where taken as random part in the model the error disappear. Sorry to update you just now, I am quite new in mixed-modelling. $\endgroup$ Mar 15, 2017 at 10:10

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.