Eva Maria Leunissen
2017-Mar-10 04:14 UTC
[R] Negative binomial GAMM using 'by' in factor interactions
I am using a GAMM to model my data (this is as far as I know the only way I can use the negative binomial distribution AND a correlation structure within the model). I measured animal detections (including zero detections) per hour at 3 different locations in an area. location is a factor in my model and the other possible explanatory variables are environmental variables and level of disturbance. I'm expecting the response to be different at the 3 different locations for each variable so have been modelling the terms as interactions with each of the 3 factor levels of location using the 'by' argument in the 'ti' smoothing term, as well as 'location' as a variable by itself. Does it make sense to include the main effect as well as the interaction term? for example for including the variable 'windspeed': if including the term ti(windspeed, by=location), is it necessary to also include s(windspeed)? or would it only make sense to inlcude them in separate models only and compare the models? As far as I understand the 'by' argument calculates a separate smooth for each of the factor levels, so if the effect was the same at each location it wouldn't hurt to use the 'ti' smooth with the 'by' argument if the effect of the variable was the same at each location. The issue I'm having is that by including both terms and then doing model selection gives me many very similar models within a deltaAIC of 6 of the best model, where the differences lie in the inclusion of main effects when the 'interaction' is also there. The inclusion of the interaction term gives bigger changes in AIC compared to the inclusion of the main effect. This brings me to my other question. Is it possible to compare GAMMs with a negative binomial family using AIC? e.g. using AIC(mod$lme). If not, what is the best way to compare them? Thank you very much for your time [[alternative HTML version deleted]]
Bert Gunter
2017-Mar-10 07:10 UTC
[R] Negative binomial GAMM using 'by' in factor interactions
Your queries appear to concern statistical issues. This list is about R programming and related; statistical issues are typically OT here. stats.stackexchange.com or a local statistical expert are probably better places to seek statistical advice. Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Thu, Mar 9, 2017 at 8:14 PM, Eva Maria Leunissen <eva.leunissen at gmail.com> wrote:> I am using a GAMM to model my data (this is as far as I know the only way I > can use the negative binomial distribution AND a correlation structure > within the model). > > I measured animal detections (including zero detections) per hour at 3 > different locations in an area. location is a factor in my model and the > other possible explanatory variables are environmental variables and level > of disturbance. > > I'm expecting the response to be different at the 3 different locations for > each variable so have been modelling the terms as interactions with each of > the 3 factor levels of location using the 'by' argument in the 'ti' > smoothing term, as well as 'location' as a variable by itself. Does it make > sense to include the main effect as well as the interaction term? for > example for including the variable 'windspeed': if including the term > ti(windspeed, by=location), is it necessary to also include s(windspeed)? > or would it only make sense to inlcude them in separate models only and > compare the models? > > As far as I understand the 'by' argument calculates a separate smooth for > each of the factor levels, so if the effect was the same at each location > it wouldn't hurt to use the 'ti' smooth with the 'by' argument if the > effect of the variable was the same at each location. > > The issue I'm having is that by including both terms and then doing model > selection gives me many very similar models within a deltaAIC of 6 of the > best model, where the differences lie in the inclusion of main effects when > the 'interaction' is also there. The inclusion of the interaction term > gives bigger changes in AIC compared to the inclusion of the main effect. > > This brings me to my other question. Is it possible to compare GAMMs with a > negative binomial family using AIC? e.g. using AIC(mod$lme). If not, what > is the best way to compare them? > > Thank you very much for your time > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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.