Title: Copy-paste!
1(No Transcript)
2Copy-paste! but T H I N K !
3(No Transcript)
4(No Transcript)
5(No Transcript)
6(No Transcript)
7Should you log your lichen sizes?
- Does it look so bad that your test may be
incorrect? Naa, probably not. - Does a log transformation improve the model
assumptions? Yes, but very little! - Does it make biological sence with a percent
increase? Well, I guess so. - OK, lets use the logged values!
- or
- Well then let's stick to raw values, they are
easier to understand!
8(No Transcript)
9stripchart(xcontxcat,method"jitter",jitter0.1,
verticalT,pch"") points(xcontjitter(as.numer
ic(xcat),.3), colc("green","gray")xcat,pch1
9)
10- 5 possible models
- Lichen size only depends on the total mean.
- Lichen size depends on what site the lichen
grows (city vs university). - Lichen size depends on the tree size ( age?).
- Lichen size depends both on site AND tree size.
- Lichen size depends on tree size, but the
relationship between tree size and lichen size
differs between the sites (city / univ).
11m.both lt- lich tree air m.int lt- lich
tree air treeair m.both lt- lich tree
air m.xcont lt- lich tree m.both lt- lich
tree air m.xcat lt- lich air m.xcat lt-
lich air m.null lt- lich 1 m.xcont lt-
lich tree m.null lt- lich 1
p 0,998
p lt 0,0001
p 0,60
p lt 0,0001
p 0,38
12Anova table on logged lichens
Anova(lm(log.lichlog.tree.circair.q))
Sum Sq Df F value Pr(gtF) log.tree
0.0179 1 0.2787 0.5996 air.q 3.3048
1 51.3784 1.827e-09 ltreair 5.583e-07 1
8.680e-06 0.9977 Residuals 3.6020 56
13m.both lt- lich tree air m.int lt- lich
tree air treeair m.both lt- lich tree
air m.xcont lt- lich tree m.both lt- lich
tree air m.xcat lt- lich air m.xcat lt-
lich air m.null lt- lich 1 m.xcont lt-
lich tree m.null lt- lich 1
p 0,72
p lt 0,0001
p 0,32
p lt 0,0001
p 0,16
14Anova table on lichens
Anova(lm(lich.diamtree.circair.q))
Sum Sq Df F value Pr(gtF) tree.circ
5.355 1 0.9879 0.3245 air.q 244.703
1 45.1459 1.007e-08 treeair.q 0.721 1
0.1330 0.7167 Residuals 303.535 56
15Lichens are smaller close to the road (F54,
plt0.0001, n60).
16(No Transcript)
17(No Transcript)
18(No Transcript)
19(No Transcript)
20Should you log your lichen sizes?
- Does it look so bad that your test may be
incorrect? Well, maybe. - Does a log transformation improve the model
assumptions? YES!, but still crap! - Does it make biological sence with a percent
increase? Well, I guess so. - OK, lets use the logged values!
21(No Transcript)
22m.both lt- apo lichsize spec m.int lt- apo
lichsize spec lichsizespec m.both lt-
apo lichsize spec m.xcont lt- apo
tree m.both lt- apo lichsize spec m.xcat
lt- apo spec m.xcat lt- apo spec m.null lt-
apo 1 m.xcont lt- apo lichsize m.null
lt- apo 1
p 0,0014
23Anova table on logged values
Anova(lm(log.apolog.sizespec)) Sum
Sq Df F value Pr(gtF) log.size 2.2672 1
25.7371 4.308e-06 spec 0.0116 1
0.1319 0.717744 lsizespec 0.9916 1 11.2569
0.001404 Residuals 5.1092 58
24Anova table on raw values
Anova(lm(aposizespec)) Sum Sq Df F
value Pr(gtF) size 30242.0 1 58.9163
2.145e-10 spec 272.1 1 0.5302
0.46946 sizespec 1778.9 1 3.4657
0.06773 . Residuals 29771.6 58
25(No Transcript)
26(No Transcript)
27(No Transcript)
28(No Transcript)
29(No Transcript)
30m.both lt- apo lichsize spec m.int lt- apo
lichsize spec lichsizespec m.both lt-
apo lichsize spec m.xcont lt- apo
tree m.both lt- apo lichsize spec m.xcat
lt- apo spec m.xcat lt- apo spec m.null lt-
apo 1 m.xcont lt- apo lichsize m.null
lt- apo 1
p 0,0055
31(No Transcript)
32The effect of lichen size on number of apothecia
differs between these two Xanthoria species
(F11, p0.0014, n60). In X. parietina small
specimens have very few apothecia, but large
specimens may have several hundred. There is a
very strong relationship to lichen size (t7.3,
plt0.0001, n29) In X. polycarpa also very small
specimens have many apothecia (20). There is no
strong relationship to lichen size (t0.90,
p0.38, n31), and not even the largest specimens
have more than 100 fruit bodies.
33(No Transcript)
34(No Transcript)
35F-tool (Anova)
library(car) Anova(lm(Lichen.diameterTree.specTr
ee.size)) Sum Sq Df F value
Pr(gtF) Tree.spec 140.171 2
44.7051 8.092e-11 Tree.size 0.471
1 0.3007 0.586563 Tree.specTree.size
25.240 2 8.0499 0.001184 Residuals
61.142 39
36(No Transcript)
37Lichen size Tree species
38Anova table on logged lichens
Anova(lm(log.lich.diamtree.spec)) Response
log.lich.diam Sum Sq Df F value Pr(gtF)
tree.spec 0.6578 2 4.4411 0.01613 Residuals
4.2215 57
39Post Hoc Tests
- Lichens on tree species
- Moss on microsubstrates stones, stumps, and bare
soil - Which differs?
- Why not several t-tests ( 2 group anovas)?
- Use pooled variance!
- Some Bonferroni correction!
- TukeyHSD(yxcat)
40Anova table on logged lichens
TukeyHSD(aov(log.lich.diamtree.spec)) diff
lwr upr p adj maple-birch
0.23552950 0.04443469 0.42662430
0.0120632 oak-birch 0.09037386 -0.13515029
0.31589802 0.6022177 oak-maple -0.14515563
-0.37239582 0.08208456 0.2814361
41Lichen size Tree species
42(No Transcript)
43F-tool (Anova)
library(car) Anova(lm(Lichen.diameterTree.specTr
ee.size)) Sum Sq Df F value
Pr(gtF) Tree.spec 140.171 2
44.7051 8.092e-11 Tree.size 0.471
1 0.3007 0.586563 Tree.specTree.size
25.240 2 8.0499 0.001184 Residuals
61.142 39
44(No Transcript)
45t-tool (estimates)
summary(lm(Lichen.diameterTree.specTree.size))
Estimate Std. Error t
value Pr(gtt) (Intercept)
2.193079 0.972902 2.254 0.0299 Tree.spec
maple -0.678676 1.780117 -0.381
0.7051 Tree.spec oak 1.303768
1.193018 1.093 0.2812 Tree.size
0.007810 0.009344 0.836 0.4084
Tree.spec mapleTree.size 0.045758 0.017817
2.568 0.0142 Tree.spec oakTree.size
-0.014465 0.010051 -1.439 0.1581
46(No Transcript)
47Centre variables
Warning 2. Centre continuous variables if you
want to get the estimated effect of both their
main effects and their interaction! c.moisturelt-m
oisture-mean(moisture) c.nitrogenlt-nitrogen-mean(n
itrogen) Now the means will be zero which is
the same as that the intercept will occur at the
mean. And that means that the main effects will
be evaluated at the means.
48(No Transcript)
49t-tool (centred estimates)
summary(lm(Lichen.diameterTree.specTree.size))
Estimate Std. Error t
value Pr(gtt) (Intercept)
3.127476 0.380355 8.223 4.79e-10
Tree.spec maple 4.796007
0.615270 7.795 1.78e-09 Tree.spec oak
-0.426938 0.526433 -0.811 0.4223
Tree.size2 0.007810 0.009344
0.836 0.4084 Tree.spec mapleTree.size2
0.045758 0.017817 2.568 0.0142
Tree.spec oakTree.size2 -0.014465 0.010051
-1.439 0.1581
50(No Transcript)
51The danger of interpreting main effects in the
presence of interactions?
52The danger of abline()
53Maybe use lines() in final plots
54(No Transcript)
552 ? 2 tables
Logistic regression
Categoric
Melica
1.0
0.8
0.6
Prob. of choosing Melica
0.4
0.2
0.0
Response variable
Luzula
4.5
5.5
6.5
7.5
Ant size
Regression
Anova
Continuous
-
-
Seed size
Continuous
Categoric
Explanatory variable
56One continuous response variable one or more
explanatory variables? General linear model
57One categorical response variable binary
either or one or more explanatory
variables? Generalized linear model
2 ? 2 tables
Logistic regression
Categoric
Response variable
1.0
Melica
0.8
0.6
Prob. of choosing Melica
0.4
0.2
0.0
Luzula
4.5
5.5
6.5
7.5
Ant size
Continuous
Categoric
Explanatory variable
58How general models are made
Minimizing residual sums of squares. For anova
type studies with only categorical factors ?
calculate group means For regression type
studies with slopes ? exactly calculate slope
based on a formula minimising ss ( set
derivate(ss)0) Crawley page 129.
59How generalized models are made
- Maximizing likelihood of the model.
- Iterative search for the maximum likelihood.
- Sometimes you see a log likelihood
- ? you can add log likelihoods
- ? you have to multiply raw likelihoods.
- Maximum likelihood also works for general linear
models! SS is a special case.
60? What is likelihood ?
- Now were going under the hood!
61(No Transcript)
62AIC Akaike Information Criteria
- To reduce models
- You have reduced models with 1 interaction and 2
main effects. - ? Easy shit! Right? Tight? remove non-significant
terms - How to reduce a model with 10 main effects
(i.e., a multiple regression)? - removal order may matter
63AIC Akaike Information Criteria
AIC(mod.123479) AIC(mod.268) library(wle) mod.aic
lt-mle.aic(yx1x2x3) summary(mod.aic)
64How to build generalized models
Under the hood ? Iterative search for the
maximum likelihood. In practice Very easy ?
with glm() instead of lm() glm.milt-glm(yx1x2x1
x2,binomial) glm.milt-glm(yx1x2x1x2,poisson)
65How to build generalized models
family binomial Different families for
different residual distributions!
glm.miblt-glm(yx1x2,binomial) glm.miplt-glm(yx
1x2,poisson)
66How to test general models
perm
- t-test of an estimate (how prob by chance)
- ? e.g., an estimate of a slope or a difference
- ? but also possible for any estimate, e.g.,
an interaction effect estimate - 2. F-test of an Analysis of variation
- variation explained by the explanatory
variable______________________________________ - remaining residual variation
67How to test generalized models
Under the hood VERY hard, and differs between
different families In practice Very easy ?
with Analyses of Deviance anodev anova(glm.mod1
,glm.mod2,testChi)
68One warning for the future
Overdispersion If Residual deviance gtgt than
Degrees of freedom glm.miqlt-glm(yx1x2,quasipois
son) anova(glm.miq,glm.miq2,testF)
69(No Transcript)
70Metapopulation ecology
Melitaea cinxia Ängsnätfjäril
71Metapopulation ecology
72Incidence Function Models
Presence log(Area) connectivity connectivity
Sum of the effect of all other
populations con Source-size e(-distance
a) a 0,69 ? halved importace each km a 1 ?
1 km mean dispersal Simple alternative nearest
pop
73Project suggestions ?
74Afternoon mission
75Afternoon mission
76Afternoon mission
77Tomorrows mission
78Tomorrwos mission II
or
79Grade
-3 Lousy / Usel -2 Bad / Dålig -1 Pretty
bad / Ganska Dålig 0 No opinion, dont know,
so so / Ingen åsikt, vet ej, varken eller 1
Pretty good / Ganska bra 2 Good / Bra 3 The
best / Bäst Write into Excel and then add 4 so
the scale will become 1-7.
80(No Transcript)