[R] negative binomial GAMM with variance structures

Meredith Jantzen mjantzen at uwo.ca
Thu Sep 22 15:59:39 CEST 2011


Hello, 
 
I am having some difficulty converting my gam code to a correct gamm code, and I'm really hoping someone will be able to help me.   
 
I was previously using this script for my overdispersed gam data:
 
M30 <-gam(efuscus~s(mic, k=7) +temp +s(date)+s(For3k, k=7) + pressure+ humidity, family=negbin(c(1,10)), data=efuscus)   
 
My gam.check gave me the attached result.  In order to deal with my heterogeneity, I need to switch over to a gamm structure and use at least one, but possibly multiple, variance structures, and I am starting by applying varPower to my temperature covariate.  (Efuscus is my square root transformed response variable).
  
Here is the code I have for the gamm:
 
K1 <-(efuscus~s(mic, k=7) +temp +s(date)+s(For3k, k=7) + pressure+ humidity+ windspeed + year)
M17.4A <-gamm(K1, method="REML", family=negbin(c(1,10), data=efuscus, weights=varPower(form=~temp)) 
 
With my various versions of the script, the two error messages I have been getting repeatedly are: Error in eval(expr, envir, enclos) : object 'temp' not found, and Error: unexpected symbol in: "M17.4A <-gamm(K1, method="REML", family=negbin(c(1,10), data=efuscus, weights=varPower(form=~temp))" 
 
I know I must be missing something obvious that is causing my script not to work...I've been looking at both Wood (2006) and Zuur's Mixed Models book for examples but none of them are completely the same as my situation, which is causing me to get tripped up.   
 
Am I defining my negative binomial family correctly for the situation?  Do I need to somehow define the variance term before I apply it?    
 
Thank you very much.  I appreciate your time and patience. 
Meredith  


More information about the R-help mailing list