Response variable: macro-fauna richness (AKA number of species)
NAP: height of sampling station compared to mean tidal level
Exposure (index). Of multiple environmental conditions. Treated as categorical, as there are three levels
RIKZ data
flowchart TD
A[RIKZ DATA] --> B(Beach 1)
A --> C(Beach 2)
A --> E(Beach 9)
B --> F(site 1)
B --> G(site 2)
B --> H(site 3)
B --> I(site 4)
B --> J(site 5)
C --> K(site 1)
C --> L(site 2)
C --> M(site 3)
C --> N(site 4)
C --> O(site 5)
E --> P(site 1)
E --> Q(site 2)
E --> R(site 3)
E --> S(site 4)
E --> T(site 5)
Let’s work on this example
Objective
flowchart TD
A[RIKZ DATA] --> B(Beach 1)
A --> C(Beach 2)
A --> E(Beach 9)
B --> F(site 1)
B --> G(site 2)
B --> H(site 3)
B --> I(site 4)
B --> J(site 5)
C --> K(site 1)
C --> L(site 2)
C --> M(site 3)
C --> N(site 4)
C --> O(site 5)
E --> P(site 1)
E --> Q(site 2)
E --> R(site 3)
E --> S(site 4)
E --> T(site 5)
c
Exploring whether there is a relationship between richness and the two factors: NAP and exposure
We have an N of 45… but do we?
We have multiple potential alternatives: there is an effect of NAP, an effect of Exposure, an effect of both, of neither
Also… there are mixed effects
Random intercept, random slope, both? –> let’s wait to discuss this
Step 1: Read the data… there is a potential issue
rikz<-read.table(file ="RIKZ.txt", header =TRUE, dec =",")str(rikz)
Step 2: decide our analysis! 🤔 Any ideas? any details?
The data
The data
There seems to be an effect of NAP…
how about… a random effect of beach?
step 3: how do we decide random effects?
step 3: random intercept? Or random slope? Or both? Or non
What do we do?
Exposure is categorical… so no random slope 😃
Model selection with random models
WE CANNOT TEST FIXED AND RANDOM EFFECTS AT THE SAME TIME
Test mixed effects first.
We use the “global” or saturated fixed model
How many models?
Use AIC
What model structure?
Model selection with random models
Four models. Run all with glmmTMB
Fixed effects: NAP*Exposure
Family: Poisson
Model selection based on AICc:
K AICc Delta_AICc AICcWt Cum.Wt LL
Mod1 6 210.94 0.00 0.62 0.62 -98.36
Mod3 7 213.24 2.30 0.20 0.81 -98.10
Mod2 7 213.52 2.59 0.17 0.98 -98.25
Mod4 9 217.81 6.87 0.02 1.00 -97.33
Are the AIC values the same?
Notes on AIC
I recommend using the AICcmodavg package and making a list!
model1<-glm(Richness~NAP*Exposure, data = rikz, family = poisson)model2<-glm(Richness~NAP+Exposure, data = rikz, family = poisson)model3<-glm(Richness~NAP, data = rikz, family = poisson)model4<-glm(Richness~Exposure, data = rikz, family = poisson)model5<-glm(Richness~1, data = rikz, family = poisson)modeltab<-AICcmodavg::aictab(list(model1,model2,model3,model4,model5))modeltab