[R] multiple comparisons for GAMs
Bird_Girl
sonyarichmond at hotmail.com
Tue Aug 7 18:48:01 CEST 2012
I have looked into using glht (‘multcomp’ package) to do multiple comparisons
for a model fit with GAM {mgcv} but after reading the description of the
‘multcomp’ package, I believe this method only applies to parametric models
and linear hypotheses. When I ran the code glht(model,linfct….) I got an
error message (see below), but I am not sure if that was the result of my
data being input in the incorrect format or the result of the test not
working on the type of model I used. Does anyone know if there is an
equivalent procedure for non-parametric models, or one that can be used to
test for significant differences in curves modeled using GAMs?
I have included a highly simplified, mini dataset that approximates the
shape of the relationships exhibited by my own much larger data set, as well
as the code I used. In a nutshell, I would like to test whether the shape
of the relationship between light and log_abundance at a height of 200m is
significantly different from the relationship between light and
log_abundance at a height of 400m.
> require (lattice)
> require (mgcv)
> require(multcomp)
> species=read.csv("Book1.csv", header=TRUE, sep=",", quote="\"",fill=TRUE)
> attach(species)
> names(species)
> species
height light log_abundance
1 200m 0.15 0.20
2 200m 0.23 0.28
3 200m 0.38 0.30
4 200m 0.41 0.47
5 200m 0.52 0.48
6 200m 0.63 0.42
7 200m 0.71 0.37
8 200m 0.85 0.35
9 200m 0.96 0.40
10 200m 1.05 0.45
11 200m 1.16 0.37
12 200m 1.23 0.30
13 200m 1.39 0.26
14 200m 1.47 0.15
15 400m 0.12 0.10
16 400m 0.25 0.09
17 400m 0.36 0.12
18 400m 0.42 0.14
19 400m 0.60 0.24
20 400m 0.65 0.28
21 400m 0.74 0.37
22 400m 0.86 0.40
23 400m 0.93 0.35
24 400m 1.06 0.25
25 400m 1.15 0.15
26 400m 1.24 0.18
27 400m 1.37 0.40
28 400m 1.48 0.57
>coplot(log_abundance~light|height)
> model1=gam(log_abundance~s(light)+height+te(light,by=height,k=6))
> plot(model1,trans=function(x)exp(x)/(1+exp(x)),shade=T,pages=1)
> summary (model1)
> glht(model1,linfct=mcp(height="Tukey"))
Error in linfct[[nm]] %*% C :
requires numeric/complex matrix/vector arguments
--
View this message in context: http://r.789695.n4.nabble.com/multiple-comparisons-for-GAMs-tp4638935p4639429.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list