Hi, I've an issue adding an interaction to a GAMM: My model was of form: gamm1 <- gamm(TOTSR ~ fROT + s(PH) + s(LOI) + s(ASP) + s(SQRT_ELEV) + CANCOV + s(SQRT_TOTCWD) + s(WELLF) + s(WELLN) + s(OLDWDLD) + s(DISTWOOD) + s(Annprec) + s(OLDWDLD:DISTWOOD) + (1|fSITE), family = poisson, data BIOFOR2) with interaction of s(OLDWDLD:DISTWOOD). However I got this error message below but don't know what it means? (my data is composed of info for 150 plots) #I Warning messages: #2: In OLDWDLD:DISTWOOD : # numerical expression has 150 elements: only the first used #3: In OLDWDLD:DISTWOOD : # numerical expression has 150 elements: only the first used Can anyone offer advice on how to include this interaction in GAMM model? Thanks Karen Moore [[alternative HTML version deleted]]
Hi Karen, I think you should decide what you mean for "interaction". s(x:y) is meaningless If you want to fit a surface you should use s(x,y). If you want to fit a varying coefficient model (interaction between a linear and a smooth term) you should use the argument by in s(). The help files of the mgcv package by S. Wood are quite clear and they also include a lot of examples. Hope this helps you vito Karen Moore ha scritto:> Hi, > > I've an issue adding an interaction to a GAMM: > > My model was of form: > > gamm1 <- gamm(TOTSR ~ fROT + s(PH) + s(LOI) + s(ASP) + s(SQRT_ELEV) + CANCOV > + s(SQRT_TOTCWD) + s(WELLF) + s(WELLN) + s(OLDWDLD) + s(DISTWOOD) + > s(Annprec) + s(OLDWDLD:DISTWOOD) + (1|fSITE), family = poisson, data > BIOFOR2) > > with interaction of s(OLDWDLD:DISTWOOD). > > However I got this error message below but don't know what it means? (my > data is composed of info for 150 plots) > > #I Warning messages: > #2: In OLDWDLD:DISTWOOD : > # numerical expression has 150 elements: only the first used > #3: In OLDWDLD:DISTWOOD : > # numerical expression has 150 elements: only the first used > > Can anyone offer advice on how to include this interaction in GAMM model? > Thanks > > Karen Moore > > [[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. >-- ===================================Vito M.R. Muggeo Dip.to Sc Statist e Matem `Vianelli' Universit? di Palermo viale delle Scienze, edificio 13 90128 Palermo - ITALY tel: 091 23895240 fax: 091 485726/485612 http://dssm.unipa.it/vmuggeo
On Jul 21, 2010, at 11:17 AM, Karen Moore wrote:> Hi, > > I've an issue adding an interaction to a GAMM: > > My model was of form:# Package? Probably: require(mgcv)> > gamm1 <- gamm(TOTSR ~ fROT + s(PH) + s(LOI) + s(ASP) + s(SQRT_ELEV) > + CANCOV > + s(SQRT_TOTCWD) + s(WELLF) + s(WELLN) + s(OLDWDLD) + s(DISTWOOD) + > s(Annprec) + s(OLDWDLD:DISTWOOD) + (1|fSITE), family = poisson, > data > BIOFOR2) > > with interaction of s(OLDWDLD:DISTWOOD). > > However I got this error message below but don't know what it means?The documentation for s() says the unnamed arguments must be a list of covariates and I do not think OLDWDLD:DISTWOOD constitutes a list. (On the other hand it appears that the term "list" is being used a bit loosely here, since the examples do not explicitly enclose the covariates in the list() function and when I did so with the example on the te help page I get an error.)> (my > data is composed of info for 150 plots) > > #I Warning messages: > #2: In OLDWDLD:DISTWOOD : > # numerical expression has 150 elements: only the first used > #3: In OLDWDLD:DISTWOOD : > # numerical expression has 150 elements: only the first used > > Can anyone offer advice on how to include this interaction in GAMM > model?Do you have Wood's book? Ch/sect 6.7 has worked examples using the te() function which I believe is the GAM(M) counterpart to linear interactions. He also makes the point that random arguments to gamm() need to be in the list form. (The documentation suggests this has not changes since the book was published.) -- David Winsemius, MD West Hartford, CT
On Wed, 2010-07-21 at 16:17 +0100, Karen Moore wrote:> Hi, > > I've an issue adding an interaction to a GAMM: > > My model was of form: > > gamm1 <- gamm(TOTSR ~ fROT + s(PH) + s(LOI) + s(ASP) + s(SQRT_ELEV) + CANCOV > + s(SQRT_TOTCWD) + s(WELLF) + s(WELLN) + s(OLDWDLD) + s(DISTWOOD) + > s(Annprec) + s(OLDWDLD:DISTWOOD) + (1|fSITE), family = poisson, data > BIOFOR2) > > with interaction of s(OLDWDLD:DISTWOOD). > > However I got this error message below but don't know what it means? (my > data is composed of info for 150 plots)An interaction is formed in a GAMM using a smoother in two or more dimensions, such as s(OLDWDLD, DISTWOOD) or te(OLDWDLD, DISTWOOD), the latter allows for different basis function within the two smoothers and for different inherent scales for the two variables. IIRC the latter allows you to produce strictly nested models for likelihood ratio testing: te(OLDWDLD) + te(DISTWOOD) is nested within te(OLDWDLD, DISTWOOD) HTH G> > #I Warning messages: > #2: In OLDWDLD:DISTWOOD : > # numerical expression has 150 elements: only the first used > #3: In OLDWDLD:DISTWOOD : > # numerical expression has 150 elements: only the first used > > Can anyone offer advice on how to include this interaction in GAMM model? > Thanks > > Karen Moore > > [[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.-- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Dr. Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%