-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBENEDICT_Biomass.gls.R
53 lines (31 loc) · 1.69 KB
/
BENEDICT_Biomass.gls.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
library(tidyverse)
library(dplyr)
library(plotrix)
library(nlme)
library(MASS)
library(gridExtra)
#Run models testing the effect of year (factor) and transect and year*transect on phrag abundance. AND a model with the effect of year (linear) and transect and year*transect on phrag abundance
#Run models testing the effect of year (factor) and transect (and phrag abundance) and year*transect on phrag abundance. AND a model with the effect of year (linear) and transect (and phrag abundance) and year*transect on phrag abundance
options(contrasts = c("contr.helmert","contr.poly"))
phragmain <- read.csv("/Users/coleman/Documents/R/LAMARSH/Data/PhragSurvey2017to2022.csv", stringsAsFactors = TRUE)
phragx <- phragmain %>%
filter(!phragmain$Site %in% c('LUMCON 1', 'LUMCON 2', 'Fontainebleau', 'Turtle Cove'), !is.na(Biomass))
View(phragx)
#gls with year and transect
gls1 <- gls(Biomass ~ Site + Year + Transect +Year*Transect + Site*Year, data = phragx)
lme1 <- lme(Biomass ~ Site + Year + Transect + Year*Transect + Site*Year,
random = ~1|Plot, data = phragx)
lmeTA1 <- lme(
Biomass ~ Site + Year + Transect + Year*Transect + Site*Year,
correlation = corAR1(form =~ Year|Plot),
random = ~1|Plot, data = phragx)
glsSA1 <- gls(
Biomass ~ Site + Year + Transect + Year*Transect + Site*Year,
correlation=corSpher(form = ~ Lat+Long|Year, nugget=T),
data = phragx)
anova(gls1, glsSA1,lmeTA1,lme1)
gls2 <- gls(Biomass ~ Site + Year + Transect +Year*Transect + Site*Year + Site*Transect, data = phragx)
lme2 <- lme(Biomass ~ Site + Year + Transect + Year*Transect + Site*Year + Site*Transect,
random = ~1|Plot, data = phragx)
anova(lme2,gls2)
anova(type='marginal', gls2)