[R] Help with lmer

Hugo Mildenberger Hugo.Mildenberger at web.de
Sun Jun 26 21:41:45 CEST 2011


Sophie,

sorry for any possibly duplicate email, my email client currently does not 
work correctly. I understand this snapshot as being a subset of your data only. 
But I do miss the factor "Sitename", which appears in your lmer model as a 
random factor. Also, by looking at the subset, "Presencebsence"  appears be a 
binary response variable. Does your response imply that you tried to call

  (m1<-lmer(Presencebsence~Habitatype*Width+(1|Sitename),family=binomial))

and got the same error? (Note: I previously mispelled "family")

I also observe that many factors in your data appear to be closely correlated, 
e.g. "Habitatype" and "Width", at least in the subset you passed along. I suspect 
this correlation to be the reason for the lmer error. Hence either use "Width"  
or "Habitatype".

Finally I'd propose you to put all your data into a dataframe, e.g.
 
   mydata<-NULL
   mydata$PresenceAbsence <- as.factor(Presencebsence)
   mydata$Habitattype         <- as.factor(Habitatype)
   mydata$Substratetype     <- as.factor(Substratetype)
   mydata$Width                 <- Width      
   mydata$Banktype            <- as.factor(Banktype)    
   mydata$BankIncline         <- BankIncline 
   mydata$Bankheight         <- as.factor(Bankheight)    
   mydata$Waterdepth        <- as.factor(Waterdepth)  
   mydata$Sitename            <- as.factor(Sitename)

and then pass the dataframe to lmer by using data=mydata;  mainly 
because passing a bunch of variables directly from the environment 
hightens the risk of inadvertently using stale copies, but also because 
str(mydata) would then produce a well arranged summary of all your
variables. 


Kind regards

Hugo



On Sunday 26 June 2011 11:26:45 Sophie Higgins wrote:
> 
> Hello Hugo,
> Thank you for your reply.  
> This is a snap shot of what my data looks like:
> 
>  
>  
>  
>  
>  
>  
>   Presencebsence
>   Habitatype
>   Substratetype
>   Width
>   Banktype
>   BankIncline
>   Bankheight
>   Waterdepth
>  
>  
>   0
>   Lake
>   Rocksgravel
>   600
>   Earth
>   0.45
>   less1
>   greater2
>  
>  
>   0
>   Lake
>   Rocksgravel
>   600
>   Earth
>   0.45
>   less1
>   greater2
>  
>  
>   1
>   Lake
>   Rocksgravel
>   600
>   Earth
>   0.45
>   less1
>   greater2
>  
>  
>   0
>   Lake
>   Rocksgravel
>   600
>   Earth
>   0.45
>   less1
>   greater2
>  
>  
>   0
>   Lake
>   Rocksgravel
>   600
>   Earth
>   0.45
>   less1
>   greater2
>  
>  
>   0
>   Stream
>   Rocksgravel
>   1
>   Rocks
>   0.45
>   less1
>   025to05
>  
>  
>   0
>   Stream
>   Rocksgravel
>   1
>   Rocks
>   0.45
>   less1
>   025to05
>  
>  
>   0
>   Stream
>   Rocksgravel
>   1
>   Rocks
>   0.45
>   less1
>   025to05
>  
>  
>   0
> 
> 
> 
>   Stream
>   Rocksgravel
>   1
>   Rocks
>   0.45
>   less1
>   025to05
>  
>  
>   
> 
> 
> 
> 
> 
> 
> 
> 
> 
>   
> 
> 
> 
> 
> 
> 
> 
> I am trying to find out if any off the above factors so substrate type, width, bank type etc have an effect on the presence/absence of the species in 
question.  But as stated below I keep getting an error message up and I have no idea how to fix it in order for me to fun the lmer.
> Sophie 
> > From: Hugo.Mildenberger at web.de
> > To: r-help at r-project.org
> > CC: england116 at hotmail.com
> > Subject: Re: [R] Help with lmer
> > Date: Fri, 24 Jun 2011 17:19:00 +0200
> > 
> > Sophie,
> > 
> > I'm myself quite new to linear mixed effect models, but "PresenceAbsence" sounds like
> > a binary response variable. So  wouldn't be
> > 
> >      m1<-lmer(Presencebsence~Habitatype*Width+(1|Sitename),familiy=binomial)
> > 
> > the first thing to try?  There is also a special mailing list for linear - mixed -effect 
> > models:
> > 
> >       r-sig-mixed-models at r-project.org
> > 
> > But with numeric problems like this one you really should provide a self contained 
> > example (i.e. with data),  at least the output of str(yourdata), if ever possible. 
> > 
> > Kind regards
> > 
> > Hugo
> > 
> > On Friday 24 June 2011 13:11:23 Sophie Higgins wrote:
> > > 
> > > Hey,
> > > I am having trouble with lmer.  I am looking at the presence/absence of water shrews against habitat and other factors e.g
> > > so I used this:
> > > m1<-lmer(Presencebsence~Habitatype*Width+(1|Sitename))summary(m1)
> > > But i keep getting this error up
> > > Error in mer_finalize(ans) : Downdated X'X is not positive definite, 16.> summary(m1)Error in asMethod(object) : matrix is not symmetric [1,2]
> > > What does this mean and now can I fix it?
> > > Sophie 		 	   		  
> > > 	[[alternative HTML version deleted]]
> > > 
> > > ______________________________________________
> > > 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.
>



More information about the R-help mailing list