[R] Interactions in GAM

Simon Wood s.wood at bath.ac.uk
Fri Sep 3 16:38:01 CEST 2010


> My main doubts are:
> 1.	Is the use of "by" and "te" right with the negative binomial
> distribution and with the binomial distribution? 
-- yes! These things specify the `linear predictor' of the model --- the 
correctness of the linear predictor does not usually  depend on the   
response distribution. 

> 2.	Do these interactions 
> have the same meaning that the interaction "factor*continuous covariate"
> and "continuous covariate* continuous covariate" used in the GLM?
-- Only at a rather general level. The factor*continuous case uses a separate 
smooth function of the continuous variable for each level of the factor 
(although you can force all the smoothing parameter to be the same). The 
continuous*continous interaction uses a single smooth function of both 
continuous  variables as the interaction.

> 3.	Is 
> right to introduce in the model the continuous covariates and the factor
> moreover their interactions?
-- Your models all look potentially sensible, with the continuous and factor 
variables dealt with in reasonable ways (of course I can't tell whether they 
are actually appropriate for the data you have).

best,
Simon

On Friday 03 September 2010 15:06, Lucia Cañas wrote:
> Hello R users,
>
> I am working with the GAM to inspect the effect of some factors (year,
> area) and continuous variables (length, depth, latitude and longitude) on
> the intensity and prevalence of the common parasite Anisakis. I would like
> introduce interaction in my models, both "continuous variables-continuous
> variables" and "continuous variables-factor". I have read some
> questions-answers regard to this subject but I still have doubts. The
> solution that I have seen to introduce an interaction "continuous
> covariate-factor" is using "by" (explained in ?gam.models). Below, I show
> an example of my model with the interactions using "by" both to prevalence
> (distribution=binomial) and to intensity (distribution=negative binomial):
>
> gam(prevalence~s(length)+factor(year)+factor(area)+s(length,by=area)+s(leng
>th,by=year), family=binomial,data=X)
>
> gam(intensity~s(length)+factor(year)+factor(area)+s(length,by=area)+s(lengt
>h,by=year), family=negbin(c(1,10)),data=X)
>
>
> The solution that I have seen to introduce an interaction "continuous
> covariate- continuous covariate" is using the function "te". Below, I show
> an example of my model with the interactions using "te" both to prevalence
> (distribution=binomial) and to intensity (distribution=negative binomial):
>
> gam(prevalence~s(length)+s(depth)+s(latitude)+s(longitude)+te(depth,length)
>+ te(latitude,length)+ te(longitude,length),family=binomial,data=X)
> gam(intensity~s(length)+s(depth)+s(latitude)+s(longitude)+te(depth,length)+
> te(latitude,length)+ te(longitude,length),family= negbin(c(1,10)),data=X)
>
>
>

>
>
> Thanks in advance.
>
> Best regards,
>
> Lucía Cañás
>
> Lucía Cañás Ferreiro
> Instituto Español de Oceanografía
> Centro Oceanográfico de A Coruña
> Paseo Marítimo Alcalde Francisco Vázquez, nº 10
> 15001 - A Coruña, SPAIN
> e-mail: lucia.canas at co.ieo.es
> Tel: +34981205362; Fax: +34981229077
> http://www.ieo.es
>
>
>
> 	[[alternative HTML version deleted]]

-- 
> Simon Wood, Mathematical Sciences, University of Bath, Bath, BA2 7AY UK
> +44 1225 386603  www.maths.bath.ac.uk/~sw283 



More information about the R-help mailing list