[R] Interactions in GAM

2010-09-08 Thread Lucia Cañas
Thank you so much for your answer, it has been really useful. I have already 
included the interactions in the models and I have obtained better results. 

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.ca...@co.ieo.es
Tel: +34981205362; Fax: +34981229077
http://www.ieo.es



[[alternative HTML version deleted]]

__
R-help@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.


[R] Interactions in GAM

2010-09-03 Thread Lucia Cañas
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(length,by=year),
 family=binomial,data=X)

gam(intensity~s(length)+factor(year)+factor(area)+s(length,by=area)+s(length,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)



My main doubts are: 
1.  Is the use of by and te right with the negative binomial 
distribution and with the binomial distribution?
2.  Do these interactions have the same meaning that the interaction 
factor*continuous covariate and continuous covariate* continuous covariate 
used in the GLM?
3.  Is right to introduce in the model the continuous covariates and the 
factor moreover their interactions?


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.ca...@co.ieo.es
Tel: +34981205362; Fax: +34981229077
http://www.ieo.es



[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] Interactions in GAM

2010-09-03 Thread Simon Wood
 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.ca...@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 

__
R-help@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.