Re: [R] how to add in interaction terms in gamm

From: Simon Wood <s.wood_at_bath.ac.uk>
Date: Wed, 23 Mar 2011 22:46:13 +0000

The usual method for producing interactions of smooths with factors in mgcv is using `by' variables (see ?gam.models for some documentation). For example
if `gender' is a two level factor then

... s(time,by=gender) + gender

would produce a smooth of time for each gender. If you want a different smooth of time for each combination of gender and gene, then I'd recommend producing a factor with a level for each gender gene combination, and using that as the by variable.

Simon

On 23/03/11 18:34, straybird_tx wrote:
> I want to use gamm to generate smoothed trend line for three groups
> identified by dummy variable genea and geneb. My question is how to add in
> an interaction term between the time and another dummy variable such as
> gender?
> fitm<-gamm(change_gfr~
> genea+geneb+s(timea_n,bs="ps")+s(timeb_n,bs="ps")+s(timec_n,bs="ps"),data=mm,random=list(time_n=~1|PID))
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/how-to-add-in-interaction-terms-in-gamm-tp3400243p3400243.html
> Sent from the R help mailing list archive at Nabble.com.
> [[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.
>

-- 
---
Simon Wood, Mathematical Science, University of Bath BA2 7AY UK
+44 (0)1225 386603               http://people.bath.ac.uk/sw283

______________________________________________
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.
Received on Wed 23 Mar 2011 - 22:53:57 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 24 Mar 2011 - 00:40:25 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive