Do grazers reduce algal cover in the intertidal?
What happens if you fit this data using * instead of + in the linear model?
Sum Sq | Df | F value | Pr(>F) | |
---|---|---|---|---|
height | 88.97334 | 1 | 0.3213845 | 0.5728570 |
herbivores | 1512.18349 | 1 | 5.4622243 | 0.0227309 |
Residuals | 16887.47793 | 61 | NA | NA |
Test stat Pr(>|Test stat|)
Tukey test -3.3171 0.0009097 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Test stat | Pr(>|Test stat|) | |
---|---|---|
Tukey test | -3.317064 | 0.0009097 |
(Note: This test is typically used when there is no replication within blocks)
Note: You can have as many treatment types as you want (and then 3-way, 4-way, etc. interactions)
You can only see this if you have replication of treatments (grazing) within blocks (tide height)
\[y_{ijk} = \beta_{0} + \sum \beta_{i}x_{i} + \sum \beta_{j}x_{j} + \sum \beta_{ij}x_{ij} + \epsilon_{ijk}\]
\[\epsilon_{ijk} \sim N(0, \sigma^{2} ), \qquad x_{i} = 0,1\]
\[\boldsymbol{Y} = \boldsymbol{\beta X} + \boldsymbol{\epsilon}\]
MS = SS/DF, e.g, \(MS_{W} = \frac{SS_{W}}{n-k}\)
\(F = \frac{MS_{AB}}{MS_{Error}}\) with DF=(j-1)(k-1),n - 1 - (i-1) - (j-1) - (i-1)(j-1)
Sum Sq | Df | F value | Pr(>F) | |
---|---|---|---|---|
height | 88.97334 | 1 | 0.3740858 | 0.5430962 |
herbivores | 1512.18349 | 1 | 6.3579319 | 0.0143595 |
height:herbivores | 2616.95555 | 1 | 11.0029142 | 0.0015486 |
Residuals | 14270.52238 | 60 | NA | NA |
Estimate | Std. Error | t value | Pr(>|t|) | |
---|---|---|---|---|
heightlow | 32.91450 | 3.855532 | 8.536955 | 0.0000000 |
heightmid | 22.48360 | 3.855532 | 5.831516 | 0.0000002 |
herbivoresplus | -22.51075 | 5.452546 | -4.128484 | 0.0001146 |
heightmid:herbivoresplus | 25.57809 | 7.711064 | 3.317064 | 0.0015486 |
Must look at simple effects first
Main effects describe effects of one variable in the complete absence of the other
contrast estimate SE df t.ratio p.value
minus - plus 9.72 3.86 60 2.521 0.0144
Results are averaged over the levels of: height
contrast estimate SE df t.ratio p.value
low - mid -2.36 3.86 60 -0.612 0.5431
Results are averaged over the levels of: herbivores
contrast estimate SE df t.ratio p.value
low minus - mid minus 10.43 5.45 60 1.913 0.0605
low minus - low plus 22.51 5.45 60 4.128 0.0001
low minus - mid plus 7.36 5.45 60 1.350 0.1819
mid minus - low plus 12.08 5.45 60 2.215 0.0305
mid minus - mid plus -3.07 5.45 60 -0.563 0.5758
low plus - mid plus -15.15 5.45 60 -2.778 0.0073
Type I
Df | Sum Sq | Mean Sq | F value | Pr(>F) | |
---|---|---|---|---|---|
height | 1 | 151.8377 | 151.8377 | 0.6380017 | 0.4278712 |
herbivores | 1 | 1384.0999 | 1384.0999 | 5.8158020 | 0.0192485 |
height:herbivores | 1 | 2933.5934 | 2933.5934 | 12.3265653 | 0.0008998 |
Residuals | 55 | 13089.4237 | 237.9895 | NA | NA |
Type II
Sum Sq | Df | F value | Pr(>F) | |
---|---|---|---|---|
height | 77.87253 | 1 | 0.3272099 | 0.5696373 |
herbivores | 1384.09995 | 1 | 5.8158020 | 0.0192485 |
height:herbivores | 2933.59337 | 1 | 12.3265653 | 0.0008998 |
Residuals | 13089.42369 | 55 | NA | NA |
Sum Sq | Df | F value | Pr(>F) | |
---|---|---|---|---|
(Intercept) | 14188.804 | 1 | 59.619447 | 0.0000000 |
height | 1175.967 | 1 | 4.941256 | 0.0303521 |
herbivores | 4242.424 | 1 | 17.826097 | 0.0000915 |
height:herbivores | 2933.593 | 1 | 12.326565 | 0.0008998 |
Residuals | 13089.424 | 55 | NA | NA |
Compare to type II
Sum Sq | Df | F value | Pr(>F) | |
---|---|---|---|---|
height | 77.87253 | 1 | 0.3272099 | 0.5696373 |
herbivores | 1384.09995 | 1 | 5.8158020 | 0.0192485 |
height:herbivores | 2933.59337 | 1 | 12.3265653 | 0.0008998 |
Residuals | 13089.42369 | 55 | NA | NA |
Type I Sums of Squares:
SS for A calculated from a model with A + Intercept versus just Intercept
SS for B calculated from a model with A + B + Intercept versus A + Intercept
SS for A:B calculated from a model with A + B + A:B +Intercept versus A + B + Intercept
This is fine for a balanced design. Variation evenly partitioned.
Type II Sums of Squares:
SS for A calculated from a model with A + B + Intercept versus B + Intercept
SS for B calculated from a model with A + B + Intercept versus A + Intercept
SS for A:B calculated from a model with A + B + A:B +Intercept versus A + B + Intercept
Interaction not incorporated in assessing main effects
Type III Sums of Squares:
SS for A calculated from a model with A + B + A:B + Intercept versus B + A:B + Intercept
SS for B calculated from a model with A + B + A:B + Intercept versus A + A:B + Intercept
SS for A:B calculated from a model with A + B + A:B +Intercept versus A + B + Intercept
Each SS is the unique contribution of a treatment
very conservative
Type I | Type II | ||
Test for A | A v. 1 | A + B v. B | A + B + A:B v B + A:B |
Test for B | A + B v. A | A + B v. A | A + B + A:B v A + A:B |
Test for B | A + B v. A | A + B v. A | A + B + A:B v A + B |
#Likelihood
intertidal_glm <- glm(sqrtarea ~ height * herbivores,
family = gaussian(link = "identity"),
data=algae)
#Bayes
library(brms)
intertidal_banova <- brm(sqrtarea ~ height * herbivores,
family = gaussian(link = "identity"),
data=algae,
file = "intertidal_brms")
Running /Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB foo.c
clang -mmacosx-version-min=10.13 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include/" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/unsupported" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/BH/include" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/src/" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppParallel/include/" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstan/include" -DEIGEN_NO_DEBUG -DBOOST_DISABLE_ASSERTS -DBOOST_PENDING_INTEGER_LOG2_HPP -DSTAN_THREADS -DBOOST_NO_AUTO_PTR -include '/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp' -D_REENTRANT -DRCPP_PARALLEL_USE_TBB=1 "-I/usr/local/opt/llvm/include" -fPIC -Wall -g -O2 -c foo.c -o foo.o
In file included from <built-in>:1:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:13:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/Dense:1:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/Core:88:
/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/src/Core/util/Macros.h:613:1: error: unknown type name 'namespace'
namespace Eigen {
^
/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/src/Core/util/Macros.h:613:16: error: expected ';' after top level declarator
namespace Eigen {
^
;
In file included from <built-in>:1:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:13:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/Dense:1:
/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/Core:96:10: fatal error: 'complex' file not found
#include <complex>
^~~~~~~~~
3 errors generated.
make: *** [foo.o] Error 1