I have a question regarding whether it is possible to do post hoc tests on a
model fit with GAM {mgcv}. My response variable is abundance (no.
individuals per plot), and I have one continuous predictor (light) and one
factor (height) which includes 7 levels.
> mod2=gam(log_abundance~s(light)+height+te(light,by=height)+s(long)+s(lat))
The relationship between log_abundance and light at the seven levels of
height all differ significantly from the overall relationship between
log_abundance and light, and relationships at most of the 7 levels are not
linear. I would like to do some kind of multiple comparison or post hoc
test to determine whether the relationship between log_abundance and light
differs significantly among the different levels of height (i.e., is the
relationship at 200 m different from that at 400 m)? Is there any way to do
this?
Thanks in advance, and I apologize if this is a stupid question – I am new
to R.
--
View this message in context: http://r.789695.n4.nabble.com/multiple-comparisons-for-GAMs-tp4638935.html
Sent from the R help mailing list archive at Nabble.com.
______________________________________________
R-h...@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.
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.
______________________________________________