Copy-paste!

1 / 80
About This Presentation
Title:

Copy-paste!

Description:

Anova(lm(lich.diam~tree.circ*air.q)) Sum Sq Df F value Pr( F) tree.circ 5.355 1 0.9879 0.3245 ... TukeyHSD(aov(log.lich.diam~tree.spec)) diff lwr upr p adj ... – PowerPoint PPT presentation

Number of Views:28
Avg rating:3.0/5.0
Slides: 81
Provided by: didrikvan

less

Transcript and Presenter's Notes

Title: Copy-paste!


1
(No Transcript)
2
Copy-paste! but T H I N K !
3
(No Transcript)
4
(No Transcript)
5
(No Transcript)
6
(No Transcript)
7
Should 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)
9
stripchart(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).

11
m.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
12
Anova 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
13
m.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
14
Anova 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
15
Lichens are smaller close to the road (F54,
plt0.0001, n60).
16
(No Transcript)
17
(No Transcript)
18
(No Transcript)
19
(No Transcript)
20
Should 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)
22
m.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
23
Anova 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
24
Anova 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)
30
m.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)
32
The 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)
35
F-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)
37
Lichen size Tree species
38
Anova 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
39
Post 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)

40
Anova 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
41
Lichen size Tree species
42
(No Transcript)
43
F-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)
45
t-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)
47
Centre 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)
49
t-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)
51
The danger of interpreting main effects in the
presence of interactions?
52
The danger of abline()
53
Maybe use lines() in final plots
54
(No Transcript)
55


2 ? 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
56
One continuous response variable one or more
explanatory variables? General linear model
57
One 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
58
How 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.
59
How 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)
62
AIC 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

63
AIC Akaike Information Criteria
AIC(mod.123479) AIC(mod.268) library(wle) mod.aic
lt-mle.aic(yx1x2x3) summary(mod.aic)
64
How 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)
65
How to build generalized models
family binomial Different families for
different residual distributions!
glm.miblt-glm(yx1x2,binomial) glm.miplt-glm(yx
1x2,poisson)
66
How 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

67
How 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)
68
One 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)
70
Metapopulation ecology
Melitaea cinxia Ängsnätfjäril
71
Metapopulation ecology
72
Incidence 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
73
Project suggestions ?
74
Afternoon mission
75
Afternoon mission
76
Afternoon mission
77
Tomorrows mission
78
Tomorrwos mission II

or
79
Grade
-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)
Write a Comment
User Comments (0)