[R-sig-ME] interactions with a smoothed term in a gam

Rafael Mares crm53 at cam.ac.uk
Thu Jul 14 16:40:29 CEST 2011


Thank you for the reply Ben.

This is what I am hoping to achieve:

logit(occurrence of foray) ~ f(week) + age + f(week):age + rainfall +
f(week):rainfall

where f(week) is a fixed smoothed function of week (fit by gam()), ie,
there isn't a separate smooth estimated for each interaction, as if I
were to use "by" in s() or a bivariate smooth to accommodate these
interactions.

The above model would be comparable to this:
logit(occurrence of foray) ~ oestrus + age + oestrus:age + rainfall +
oestrus:rainfall
for other seasonal covariates (such as oestrus).

I realize there is a way in gam (mgcv) of incorporating "weighted sums
of the same smooth", but these weights seem to be fixed (see the
documentation for linear.functional.terms from the mgcv package).


Raff

--
Rafael Mares
Large Animal Research Group (LARG)
Department of Zoology
University of Cambridge
Downing Street
Cambridge
CB2 3EJ



On 14 July 2011 13:52, Ben Bolker <bbolker at gmail.com> wrote:
> On 11-07-14 04:00 AM, Rafael Mares wrote:
>> Dear all
>>
>> I am hoping someone can please help me with a gam I'm trying to
>> specify using gamm4 0.1-2 in R, particularly in trying to specify
>> interactions with a smoothed term.
>>
>> I am looking at the occurrence or not of a behaviour (extraterritorial
>> foray) in each week across several years and how this behaviour might
>> be predicted by a series of continuous and categorical variables. I am
>> including week as a predictor variable in my model like so:
>> s(week,bs="cc") - as the behaviour is highly cyclical - , and I would
>> like to allow this smoothed term to interact with my other predictor
>> variables: age of the individual, total rainfall during week and
>> occurrence of an intergroup encounter (yes/no). Is it possible to
>> create a "fixed smoothed term" for week, that I could then allow to
>> interact linearly with each of my other predictor variables?
>
>  What do you mean exactly by "interact linearly with"?  What model do
> you have in mind for the possible change in the (logit probability of)
> occurrence at a given week as a function of differences in age?
>
>> I am
>> trying to avoid specifying interactions as either: s(week, age) or
>> s(week, by = age), because I am interested in multiple interactions
>> and to my understanding, these approaches would create a different
>> smooth for each interaction. My main interest is to see whether other
>> highly seasonal variables (such as oestrus and it's interactions),
>> which are expected to have linear effects, are better predictors than
>> a smooth of week (plus interactions), in explaining whether
>> individuals embark on extraterritorial forays or not.
>>
>> Thank you in advance for any help.
>> All the best,
>>
>> Raff
>> Rafael Mares
>> Large Animal Research Group (LARG)
>> Department of Zoology
>> University of Cambridge
>> Downing Street
>> Cambridge
>> CB2 3EJ
>>
>> _______________________________________________
>> R-sig-mixed-models at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>




More information about the R-sig-mixed-models mailing list