##load required libraries###
library(tidyverse)
## Loading tidyverse: ggplot2
## Loading tidyverse: tibble
## Loading tidyverse: tidyr
## Loading tidyverse: readr
## Loading tidyverse: purrr
## Loading tidyverse: dplyr
## Warning: package 'ggplot2' was built under R version 3.1.3
## Warning: package 'readr' was built under R version 3.1.3
## Warning: package 'dplyr' was built under R version 3.1.3
## Conflicts with tidy packages ----------------------------------------------
## filter(): dplyr, stats
## lag(): dplyr, stats
library(broom)
## Warning: package 'broom' was built under R version 3.1.3
library(readxl)
## Warning: package 'readxl' was built under R version 3.1.3
library(forcats)
library(MASS)
## Warning: package 'MASS' was built under R version 3.1.3
##
## Attaching package: 'MASS'
## The following object is masked from 'package:dplyr':
##
## select
##set plot themes####
source('theme_javier.R')
theme_set(theme_javier(base_size = 8))
sp <- read_excel('InteractionData_07-09-16.xlsx', 1)
###species model negative binomial####
sp_models <- sp %>%
gather(sp, abund,-c(1:6)) %>%
group_by(sp) %>%
do(fit_sp = step(
glm.nb(
abund + 1 ~
scale(mud) +
I(scale(mud) ^ 2) +
scale(CuPb) +
I(scale(CuPb) ^ 2) +
scale(TPTN) +
I(scale(TPTN) ^ 2) +
scale(TPTN):scale(CuPb) +
scale(TPTN):scale(mud) +
scale(CuPb):scale(mud),
data = .
),
control = glm.control(trace = 10, maxit = 1000)
),
direction = 'backwards')
## Start: AIC=3687.38
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(TPTN):scale(CuPb) +
## scale(TPTN):scale(mud) + scale(CuPb):scale(mud)
##
## Df Deviance AIC
## - I(scale(TPTN)^2) 1 710.20 3686.4
## - scale(mud):scale(TPTN) 1 710.74 3686.9
## <none> 709.20 3687.4
## - I(scale(CuPb)^2) 1 714.02 3690.2
## - scale(CuPb):scale(TPTN) 1 715.11 3691.3
## - scale(mud):scale(CuPb) 1 720.40 3696.6
## - I(scale(mud)^2) 1 721.79 3698.0
##
## Step: AIC=3686.38
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + scale(CuPb):scale(TPTN) + scale(mud):scale(TPTN) +
## scale(mud):scale(CuPb)
##
## Df Deviance AIC
## - scale(mud):scale(TPTN) 1 711.40 3685.0
## <none> 710.83 3686.4
## - scale(CuPb):scale(TPTN) 1 715.86 3689.4
## - I(scale(CuPb)^2) 1 716.21 3689.8
## - scale(mud):scale(CuPb) 1 721.16 3694.7
## - I(scale(mud)^2) 1 723.82 3697.4
##
## Step: AIC=3684.95
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + scale(CuPb):scale(TPTN) + scale(mud):scale(CuPb)
##
## Df Deviance AIC
## <none> 711.93 3685.0
## - I(scale(CuPb)^2) 1 716.79 3687.8
## - scale(mud):scale(CuPb) 1 721.84 3692.9
## - I(scale(mud)^2) 1 726.70 3697.7
## - scale(CuPb):scale(TPTN) 1 735.93 3706.9
## Start: AIC=2444.17
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(TPTN):scale(CuPb) +
## scale(TPTN):scale(mud) + scale(CuPb):scale(mud)
##
## Df Deviance AIC
## - I(scale(CuPb)^2) 1 468.50 2443.4
## <none> 467.28 2444.2
## - scale(mud):scale(CuPb) 1 469.48 2444.4
## - scale(CuPb):scale(TPTN) 1 472.93 2447.8
## - I(scale(TPTN)^2) 1 478.15 2453.0
## - scale(mud):scale(TPTN) 1 479.89 2454.8
## - I(scale(mud)^2) 1 479.99 2454.9
##
## Step: AIC=2443.39
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + scale(TPTN) +
## I(scale(TPTN)^2) + scale(CuPb):scale(TPTN) + scale(mud):scale(TPTN) +
## scale(mud):scale(CuPb)
##
## Df Deviance AIC
## <none> 468.46 2443.4
## - scale(CuPb):scale(TPTN) 1 472.93 2445.8
## - I(scale(TPTN)^2) 1 478.34 2451.3
## - I(scale(mud)^2) 1 480.02 2452.9
## - scale(mud):scale(CuPb) 1 481.68 2454.6
## - scale(mud):scale(TPTN) 1 484.43 2457.3
## Start: AIC=2303.55
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(TPTN):scale(CuPb) +
## scale(TPTN):scale(mud) + scale(CuPb):scale(mud)
##
## Df Deviance AIC
## - I(scale(TPTN)^2) 1 429.04 2302.2
## <none> 428.37 2303.6
## - scale(CuPb):scale(TPTN) 1 434.88 2308.1
## - I(scale(CuPb)^2) 1 436.43 2309.6
## - scale(mud):scale(TPTN) 1 436.98 2310.2
## - scale(mud):scale(CuPb) 1 449.62 2322.8
## - I(scale(mud)^2) 1 478.56 2351.7
##
## Step: AIC=2302.21
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + scale(CuPb):scale(TPTN) + scale(mud):scale(TPTN) +
## scale(mud):scale(CuPb)
##
## Df Deviance AIC
## <none> 429.81 2302.2
## - scale(CuPb):scale(TPTN) 1 436.06 2306.5
## - I(scale(CuPb)^2) 1 439.55 2309.9
## - scale(mud):scale(TPTN) 1 445.51 2315.9
## - scale(mud):scale(CuPb) 1 450.76 2321.2
## - I(scale(mud)^2) 1 492.19 2362.6
## Start: AIC=2938.77
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(TPTN):scale(CuPb) +
## scale(TPTN):scale(mud) + scale(CuPb):scale(mud)
##
## Df Deviance AIC
## - scale(CuPb):scale(TPTN) 1 598.94 2936.8
## - I(scale(TPTN)^2) 1 599.57 2937.4
## <none> 598.93 2938.8
## - scale(mud):scale(TPTN) 1 603.86 2941.7
## - I(scale(CuPb)^2) 1 604.02 2941.9
## - I(scale(mud)^2) 1 610.65 2948.5
## - scale(mud):scale(CuPb) 1 613.86 2951.7
##
## Step: AIC=2936.78
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(mud):scale(TPTN) +
## scale(mud):scale(CuPb)
##
## Df Deviance AIC
## - I(scale(TPTN)^2) 1 599.82 2935.7
## <none> 598.90 2936.8
## - scale(mud):scale(TPTN) 1 606.04 2941.9
## - I(scale(CuPb)^2) 1 606.76 2942.6
## - I(scale(mud)^2) 1 613.10 2949.0
## - scale(mud):scale(CuPb) 1 613.82 2949.7
##
## Step: AIC=2935.7
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + scale(mud):scale(TPTN) + scale(mud):scale(CuPb)
##
## Df Deviance AIC
## <none> 598.27 2935.7
## - I(scale(CuPb)^2) 1 606.57 2942.0
## - scale(mud):scale(CuPb) 1 613.16 2948.6
## - I(scale(mud)^2) 1 620.32 2955.8
## - scale(mud):scale(TPTN) 1 637.92 2973.3
## Start: AIC=4062.4
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(TPTN):scale(CuPb) +
## scale(TPTN):scale(mud) + scale(CuPb):scale(mud)
##
## Df Deviance AIC
## - scale(mud):scale(CuPb) 1 714.96 4060.4
## - scale(mud):scale(TPTN) 1 716.35 4061.8
## <none> 714.96 4062.4
## - scale(CuPb):scale(TPTN) 1 718.68 4064.1
## - I(scale(CuPb)^2) 1 719.64 4065.1
## - I(scale(TPTN)^2) 1 721.83 4067.3
## - I(scale(mud)^2) 1 726.48 4071.9
##
## Step: AIC=4060.4
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(CuPb):scale(TPTN) +
## scale(mud):scale(TPTN)
##
## Df Deviance AIC
## - scale(mud):scale(TPTN) 1 716.33 4059.8
## <none> 714.93 4060.4
## - scale(CuPb):scale(TPTN) 1 718.73 4062.2
## - I(scale(TPTN)^2) 1 721.80 4065.3
## - I(scale(CuPb)^2) 1 724.15 4067.6
## - I(scale(mud)^2) 1 729.21 4072.7
##
## Step: AIC=4059.8
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(CuPb):scale(TPTN)
##
## Df Deviance AIC
## <none> 714.47 4059.8
## - scale(CuPb):scale(TPTN) 1 717.17 4060.5
## - I(scale(TPTN)^2) 1 720.16 4063.5
## - I(scale(CuPb)^2) 1 722.63 4066.0
## - I(scale(mud)^2) 1 793.07 4136.4
## - scale(mud) 1 924.66 4268.0
## Start: AIC=2069.51
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(TPTN):scale(CuPb) +
## scale(TPTN):scale(mud) + scale(CuPb):scale(mud)
##
## Df Deviance AIC
## - I(scale(CuPb)^2) 1 389.70 2067.6
## - scale(mud):scale(TPTN) 1 390.27 2068.2
## - scale(mud):scale(CuPb) 1 390.33 2068.3
## <none> 389.59 2069.5
## - I(scale(mud)^2) 1 391.91 2069.8
## - scale(CuPb):scale(TPTN) 1 392.76 2070.7
## - I(scale(TPTN)^2) 1 398.81 2076.7
##
## Step: AIC=2067.62
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + scale(TPTN) +
## I(scale(TPTN)^2) + scale(CuPb):scale(TPTN) + scale(mud):scale(TPTN) +
## scale(mud):scale(CuPb)
##
## Df Deviance AIC
## - scale(mud):scale(TPTN) 1 390.59 2066.5
## <none> 389.70 2067.6
## - I(scale(mud)^2) 1 392.31 2068.2
## - scale(mud):scale(CuPb) 1 392.38 2068.3
## - scale(CuPb):scale(TPTN) 1 393.34 2069.3
## - I(scale(TPTN)^2) 1 398.93 2074.8
##
## Step: AIC=2066.51
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + scale(TPTN) +
## I(scale(TPTN)^2) + scale(CuPb):scale(TPTN) + scale(mud):scale(CuPb)
##
## Df Deviance AIC
## <none> 390.34 2066.5
## - scale(mud):scale(CuPb) 1 393.27 2067.4
## - scale(CuPb):scale(TPTN) 1 395.33 2069.5
## - I(scale(TPTN)^2) 1 399.76 2073.9
## - I(scale(mud)^2) 1 403.65 2077.8
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Start: AIC=1626.79
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(TPTN):scale(CuPb) +
## scale(TPTN):scale(mud) + scale(CuPb):scale(mud)
##
## Df Deviance AIC
## - scale(mud):scale(TPTN) 1 88.034 1624.8
## - scale(mud):scale(CuPb) 1 88.176 1624.9
## - I(scale(CuPb)^2) 1 88.473 1625.2
## - I(scale(mud)^2) 1 89.014 1625.8
## - I(scale(TPTN)^2) 1 89.514 1626.3
## - scale(CuPb):scale(TPTN) 1 89.770 1626.5
## <none> 88.028 1626.8
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
##
## Step: AIC=1624.79
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(CuPb):scale(TPTN) +
## scale(mud):scale(CuPb)
##
## Df Deviance AIC
## - scale(mud):scale(CuPb) 1 88.200 1623.0
## - I(scale(CuPb)^2) 1 88.482 1623.2
## - I(scale(mud)^2) 1 89.657 1624.4
## - scale(CuPb):scale(TPTN) 1 89.890 1624.7
## <none> 88.034 1624.8
## - I(scale(TPTN)^2) 1 90.134 1624.9
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
##
## Step: AIC=1622.96
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(CuPb):scale(TPTN)
##
## Df Deviance AIC
## - scale(CuPb):scale(TPTN) 1 89.968 1622.7
## <none> 88.200 1623.0
## - I(scale(CuPb)^2) 1 90.207 1623.0
## - I(scale(TPTN)^2) 1 90.334 1623.1
## - I(scale(mud)^2) 1 90.408 1623.2
## - scale(mud) 1 92.959 1625.7
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
##
## Step: AIC=1622.73
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2)
##
## Df Deviance AIC
## - I(scale(CuPb)^2) 1 90.233 1621.0
## - I(scale(TPTN)^2) 1 90.337 1621.1
## - scale(TPTN) 1 90.732 1621.5
## <none> 89.968 1622.7
## - I(scale(mud)^2) 1 92.248 1623.0
## - scale(CuPb) 1 92.851 1623.6
## - scale(mud) 1 94.804 1625.6
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
##
## Step: AIC=1620.99
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + scale(TPTN) +
## I(scale(TPTN)^2)
##
## Df Deviance AIC
## - scale(TPTN) 1 90.888 1619.7
## <none> 90.233 1621.0
## - I(scale(mud)^2) 1 92.248 1621.0
## - scale(CuPb) 1 92.852 1621.6
## - I(scale(TPTN)^2) 1 93.063 1621.8
## - scale(mud) 1 94.942 1623.7
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
##
## Step: AIC=1619.65
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(TPTN)^2)
##
## Df Deviance AIC
## - I(scale(mud)^2) 1 92.723 1619.5
## <none> 90.888 1619.7
## - I(scale(TPTN)^2) 1 93.370 1620.1
## - scale(CuPb) 1 94.804 1621.6
## - scale(mud) 1 94.965 1621.7
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
##
## Step: AIC=1619.48
## abund + 1 ~ scale(mud) + scale(CuPb) + I(scale(TPTN)^2)
##
## Df Deviance AIC
## - I(scale(TPTN)^2) 1 93.420 1618.2
## <none> 92.723 1619.5
## - scale(CuPb) 1 94.852 1619.6
## - scale(mud) 1 95.072 1619.8
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
##
## Step: AIC=1618.18
## abund + 1 ~ scale(mud) + scale(CuPb)
##
## Df Deviance AIC
## - scale(CuPb) 1 94.852 1617.6
## <none> 93.420 1618.2
## - scale(mud) 1 95.529 1618.3
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
##
## Step: AIC=1617.61
## abund + 1 ~ scale(mud)
##
## Df Deviance AIC
## - scale(mud) 1 95.530 1616.3
## <none> 94.852 1617.6
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
##
## Step: AIC=1616.29
## abund + 1 ~ 1
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Start: AIC=1629.72
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(TPTN):scale(CuPb) +
## scale(TPTN):scale(mud) + scale(CuPb):scale(mud)
##
## Df Deviance AIC
## - I(scale(mud)^2) 1 79.014 1627.7
## - scale(mud):scale(CuPb) 1 79.044 1627.8
## - scale(mud):scale(TPTN) 1 79.049 1627.8
## - I(scale(CuPb)^2) 1 79.159 1627.9
## - scale(CuPb):scale(TPTN) 1 79.164 1627.9
## - I(scale(TPTN)^2) 1 79.397 1628.1
## <none> 79.014 1629.7
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
##
## Step: AIC=1627.72
## abund + 1 ~ scale(mud) + scale(CuPb) + I(scale(CuPb)^2) + scale(TPTN) +
## I(scale(TPTN)^2) + scale(CuPb):scale(TPTN) + scale(mud):scale(TPTN) +
## scale(mud):scale(CuPb)
##
## Df Deviance AIC
## - scale(mud):scale(CuPb) 1 79.057 1625.8
## - scale(mud):scale(TPTN) 1 79.087 1625.8
## - I(scale(CuPb)^2) 1 79.169 1625.9
## - scale(CuPb):scale(TPTN) 1 79.172 1625.9
## - I(scale(TPTN)^2) 1 79.445 1626.2
## <none> 79.014 1627.7
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
##
## Step: AIC=1625.76
## abund + 1 ~ scale(mud) + scale(CuPb) + I(scale(CuPb)^2) + scale(TPTN) +
## I(scale(TPTN)^2) + scale(CuPb):scale(TPTN) + scale(mud):scale(TPTN)
##
## Df Deviance AIC
## - I(scale(CuPb)^2) 1 79.185 1623.9
## - scale(CuPb):scale(TPTN) 1 79.204 1623.9
## - scale(mud):scale(TPTN) 1 79.405 1624.1
## - I(scale(TPTN)^2) 1 79.596 1624.3
## <none> 79.057 1625.8
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
##
## Step: AIC=1623.89
## abund + 1 ~ scale(mud) + scale(CuPb) + scale(TPTN) + I(scale(TPTN)^2) +
## scale(CuPb):scale(TPTN) + scale(mud):scale(TPTN)
##
## Df Deviance AIC
## - scale(CuPb):scale(TPTN) 1 79.206 1621.9
## - scale(mud):scale(TPTN) 1 79.539 1622.2
## - I(scale(TPTN)^2) 1 79.599 1622.3
## <none> 79.185 1623.9
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
##
## Step: AIC=1621.91
## abund + 1 ~ scale(mud) + scale(CuPb) + scale(TPTN) + I(scale(TPTN)^2) +
## scale(mud):scale(TPTN)
##
## Df Deviance AIC
## - scale(CuPb) 1 79.207 1619.9
## - I(scale(TPTN)^2) 1 79.702 1620.4
## - scale(mud):scale(TPTN) 1 79.725 1620.4
## <none> 79.206 1621.9
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
##
## Step: AIC=1619.91
## abund + 1 ~ scale(mud) + scale(TPTN) + I(scale(TPTN)^2) + scale(mud):scale(TPTN)
##
## Df Deviance AIC
## - scale(mud):scale(TPTN) 1 79.812 1618.5
## - I(scale(TPTN)^2) 1 79.823 1618.5
## <none> 79.207 1619.9
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
##
## Step: AIC=1618.52
## abund + 1 ~ scale(mud) + scale(TPTN) + I(scale(TPTN)^2)
##
## Df Deviance AIC
## - I(scale(TPTN)^2) 1 79.823 1616.5
## - scale(TPTN) 1 80.282 1617.0
## - scale(mud) 1 81.319 1618.0
## <none> 79.812 1618.5
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
##
## Step: AIC=1616.53
## abund + 1 ~ scale(mud) + scale(TPTN)
##
## Df Deviance AIC
## - scale(TPTN) 1 80.336 1615.0
## - scale(mud) 1 81.343 1616.0
## <none> 79.823 1616.5
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
##
## Step: AIC=1615.04
## abund + 1 ~ scale(mud)
##
## Df Deviance AIC
## - scale(mud) 1 81.606 1614.3
## <none> 80.336 1615.0
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
##
## Step: AIC=1614.31
## abund + 1 ~ 1
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Start: AIC=1820.78
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(TPTN):scale(CuPb) +
## scale(TPTN):scale(mud) + scale(CuPb):scale(mud)
##
## Df Deviance AIC
## - I(scale(CuPb)^2) 1 211.80 1819.4
## - scale(mud):scale(TPTN) 1 211.89 1819.5
## <none> 211.20 1820.8
## - I(scale(mud)^2) 1 213.26 1820.8
## - scale(mud):scale(CuPb) 1 215.06 1822.6
## - scale(CuPb):scale(TPTN) 1 218.53 1826.1
## - I(scale(TPTN)^2) 1 220.85 1828.4
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
##
## Step: AIC=1819.38
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + scale(TPTN) +
## I(scale(TPTN)^2) + scale(CuPb):scale(TPTN) + scale(mud):scale(TPTN) +
## scale(mud):scale(CuPb)
##
## Df Deviance AIC
## - scale(mud):scale(TPTN) 1 212.29 1817.9
## <none> 211.80 1819.4
## - I(scale(mud)^2) 1 214.45 1820.0
## - scale(mud):scale(CuPb) 1 215.84 1821.4
## - I(scale(TPTN)^2) 1 223.50 1829.1
## - scale(CuPb):scale(TPTN) 1 225.69 1831.3
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
##
## Step: AIC=1817.87
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + scale(TPTN) +
## I(scale(TPTN)^2) + scale(CuPb):scale(TPTN) + scale(mud):scale(CuPb)
##
## Df Deviance AIC
## <none> 212.29 1817.9
## - I(scale(mud)^2) 1 215.02 1818.6
## - scale(mud):scale(CuPb) 1 216.24 1819.8
## - I(scale(TPTN)^2) 1 226.61 1830.2
## - scale(CuPb):scale(TPTN) 1 227.59 1831.2
## Start: AIC=4457.26
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(TPTN):scale(CuPb) +
## scale(TPTN):scale(mud) + scale(CuPb):scale(mud)
##
## Df Deviance AIC
## - scale(mud):scale(CuPb) 1 778.54 4456.0
## <none> 777.83 4457.3
## - scale(mud):scale(TPTN) 1 783.77 4461.2
## - I(scale(CuPb)^2) 1 784.11 4461.5
## - scale(CuPb):scale(TPTN) 1 795.54 4473.0
## - I(scale(TPTN)^2) 1 799.80 4477.2
## - I(scale(mud)^2) 1 801.31 4478.7
##
## Step: AIC=4455.97
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(CuPb):scale(TPTN) +
## scale(mud):scale(TPTN)
##
## Df Deviance AIC
## <none> 777.82 4456.0
## - scale(mud):scale(TPTN) 1 783.12 4459.3
## - I(scale(CuPb)^2) 1 786.11 4462.3
## - scale(CuPb):scale(TPTN) 1 796.14 4472.3
## - I(scale(TPTN)^2) 1 801.22 4477.4
## - I(scale(mud)^2) 1 819.38 4495.5
## Start: AIC=3134.99
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(TPTN):scale(CuPb) +
## scale(TPTN):scale(mud) + scale(CuPb):scale(mud)
##
## Df Deviance AIC
## - I(scale(TPTN)^2) 1 708.84 3133.0
## - scale(CuPb):scale(TPTN) 1 709.23 3133.4
## - I(scale(CuPb)^2) 1 709.89 3134.1
## - I(scale(mud)^2) 1 710.77 3134.9
## <none> 708.83 3135.0
## - scale(mud):scale(CuPb) 1 713.79 3137.9
## - scale(mud):scale(TPTN) 1 716.97 3141.1
##
## Step: AIC=3133
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + scale(CuPb):scale(TPTN) + scale(mud):scale(TPTN) +
## scale(mud):scale(CuPb)
##
## Df Deviance AIC
## - scale(CuPb):scale(TPTN) 1 709.25 3131.5
## - I(scale(CuPb)^2) 1 709.82 3132.1
## <none> 708.76 3133.0
## - I(scale(mud)^2) 1 711.03 3133.3
## - scale(mud):scale(CuPb) 1 713.82 3136.1
## - scale(mud):scale(TPTN) 1 720.87 3143.1
##
## Step: AIC=3131.49
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + scale(mud):scale(TPTN) + scale(mud):scale(CuPb)
##
## Df Deviance AIC
## - I(scale(CuPb)^2) 1 709.16 3130.1
## - I(scale(mud)^2) 1 710.34 3131.3
## <none> 708.55 3131.5
## - scale(mud):scale(CuPb) 1 713.81 3134.8
## - scale(mud):scale(TPTN) 1 732.80 3153.7
##
## Step: AIC=3130.1
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + scale(TPTN) +
## scale(mud):scale(TPTN) + scale(mud):scale(CuPb)
##
## Df Deviance AIC
## <none> 708.35 3130.1
## - I(scale(mud)^2) 1 714.07 3133.8
## - scale(mud):scale(CuPb) 1 727.32 3147.1
## - scale(mud):scale(TPTN) 1 732.18 3151.9
## Start: AIC=2359.69
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(TPTN):scale(CuPb) +
## scale(TPTN):scale(mud) + scale(CuPb):scale(mud)
##
## Df Deviance AIC
## - I(scale(mud)^2) 1 454.83 2358.1
## - scale(mud):scale(TPTN) 1 455.18 2358.5
## <none> 454.38 2359.7
## - scale(mud):scale(CuPb) 1 459.47 2362.8
## - scale(CuPb):scale(TPTN) 1 467.23 2370.5
## - I(scale(CuPb)^2) 1 470.31 2373.6
## - I(scale(TPTN)^2) 1 480.95 2384.3
##
## Step: AIC=2358.14
## abund + 1 ~ scale(mud) + scale(CuPb) + I(scale(CuPb)^2) + scale(TPTN) +
## I(scale(TPTN)^2) + scale(CuPb):scale(TPTN) + scale(mud):scale(TPTN) +
## scale(mud):scale(CuPb)
##
## Df Deviance AIC
## <none> 454.86 2358.1
## - scale(mud):scale(TPTN) 1 458.18 2359.4
## - scale(mud):scale(CuPb) 1 463.26 2364.5
## - scale(CuPb):scale(TPTN) 1 467.48 2368.8
## - I(scale(CuPb)^2) 1 472.60 2373.9
## - I(scale(TPTN)^2) 1 486.63 2387.9
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Start: AIC=1704.93
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(TPTN):scale(CuPb) +
## scale(TPTN):scale(mud) + scale(CuPb):scale(mud)
##
## Df Deviance AIC
## - scale(mud):scale(TPTN) 1 121.67 1702.9
## - I(scale(mud)^2) 1 121.78 1703.0
## - scale(mud):scale(CuPb) 1 121.90 1703.2
## - scale(CuPb):scale(TPTN) 1 122.04 1703.3
## - I(scale(CuPb)^2) 1 122.06 1703.3
## - I(scale(TPTN)^2) 1 122.77 1704.0
## <none> 121.66 1704.9
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
##
## Step: AIC=1702.94
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(CuPb):scale(TPTN) +
## scale(mud):scale(CuPb)
##
## Df Deviance AIC
## - scale(mud):scale(CuPb) 1 121.92 1701.2
## - I(scale(mud)^2) 1 121.95 1701.2
## - I(scale(CuPb)^2) 1 122.12 1701.4
## - scale(CuPb):scale(TPTN) 1 122.15 1701.4
## - I(scale(TPTN)^2) 1 123.04 1702.3
## <none> 121.67 1702.9
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
##
## Step: AIC=1701.19
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(CuPb):scale(TPTN)
##
## Df Deviance AIC
## - I(scale(CuPb)^2) 1 122.12 1699.4
## - scale(CuPb):scale(TPTN) 1 122.49 1699.8
## - I(scale(TPTN)^2) 1 123.28 1700.5
## <none> 121.92 1701.2
## - I(scale(mud)^2) 1 124.11 1701.4
## - scale(mud) 1 125.58 1702.8
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
##
## Step: AIC=1699.39
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + scale(TPTN) +
## I(scale(TPTN)^2) + scale(CuPb):scale(TPTN)
##
## Df Deviance AIC
## - scale(CuPb):scale(TPTN) 1 122.70 1698.0
## - I(scale(TPTN)^2) 1 123.36 1698.6
## <none> 122.12 1699.4
## - I(scale(mud)^2) 1 124.19 1699.5
## - scale(mud) 1 125.60 1700.9
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
##
## Step: AIC=1697.97
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + scale(TPTN) +
## I(scale(TPTN)^2)
##
## Df Deviance AIC
## - scale(CuPb) 1 122.74 1696.0
## - I(scale(TPTN)^2) 1 124.00 1697.3
## - scale(TPTN) 1 124.34 1697.6
## <none> 122.70 1698.0
## - I(scale(mud)^2) 1 125.71 1699.0
## - scale(mud) 1 127.86 1701.1
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
##
## Step: AIC=1696.01
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(TPTN) + I(scale(TPTN)^2)
##
## Df Deviance AIC
## - scale(TPTN) 1 124.39 1695.7
## <none> 122.74 1696.0
## - I(scale(TPTN)^2) 1 125.51 1696.8
## - I(scale(mud)^2) 1 127.47 1698.7
## - scale(mud) 1 133.07 1704.3
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
##
## Step: AIC=1695.66
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + I(scale(TPTN)^2)
##
## Df Deviance AIC
## - I(scale(TPTN)^2) 1 125.88 1695.2
## <none> 124.39 1695.7
## - I(scale(mud)^2) 1 127.97 1697.2
## - scale(mud) 1 135.06 1704.3
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
##
## Step: AIC=1695.15
## abund + 1 ~ scale(mud) + I(scale(mud)^2)
##
## Df Deviance AIC
## <none> 125.88 1695.2
## - I(scale(mud)^2) 1 128.74 1696.0
## - scale(mud) 1 135.09 1702.4
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Start: AIC=1840.44
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(TPTN):scale(CuPb) +
## scale(TPTN):scale(mud) + scale(CuPb):scale(mud)
##
## Df Deviance AIC
## - scale(CuPb):scale(TPTN) 1 240.70 1839.0
## - scale(mud):scale(CuPb) 1 241.59 1839.9
## - scale(mud):scale(TPTN) 1 241.81 1840.1
## <none> 240.13 1840.4
## - I(scale(mud)^2) 1 242.51 1840.8
## - I(scale(CuPb)^2) 1 243.04 1841.3
## - I(scale(TPTN)^2) 1 243.04 1841.3
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
##
## Step: AIC=1839.01
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(mud):scale(TPTN) +
## scale(mud):scale(CuPb)
##
## Df Deviance AIC
## - scale(mud):scale(CuPb) 1 242.32 1838.6
## <none> 240.70 1839.0
## - I(scale(CuPb)^2) 1 243.08 1839.4
## - I(scale(TPTN)^2) 1 243.09 1839.4
## - scale(mud):scale(TPTN) 1 243.42 1839.7
## - I(scale(mud)^2) 1 244.01 1840.3
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
##
## Step: AIC=1838.62
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(mud):scale(TPTN)
##
## Df Deviance AIC
## - scale(CuPb) 1 242.53 1836.8
## - I(scale(CuPb)^2) 1 243.26 1837.6
## - I(scale(mud)^2) 1 244.22 1838.5
## <none> 242.32 1838.6
## - I(scale(TPTN)^2) 1 244.82 1839.1
## - scale(mud):scale(TPTN) 1 245.85 1840.2
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
##
## Step: AIC=1836.83
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(mud):scale(TPTN)
##
## Df Deviance AIC
## - I(scale(CuPb)^2) 1 243.29 1835.6
## <none> 242.53 1836.8
## - I(scale(TPTN)^2) 1 245.01 1837.3
## - I(scale(mud)^2) 1 245.27 1837.6
## - scale(mud):scale(TPTN) 1 246.16 1838.5
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
##
## Step: AIC=1835.59
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(TPTN) + I(scale(TPTN)^2) +
## scale(mud):scale(TPTN)
##
## Df Deviance AIC
## <none> 243.29 1835.6
## - I(scale(mud)^2) 1 245.77 1836.1
## - scale(mud):scale(TPTN) 1 246.37 1836.7
## - I(scale(TPTN)^2) 1 246.50 1836.8
## Start: AIC=2106.65
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(TPTN):scale(CuPb) +
## scale(TPTN):scale(mud) + scale(CuPb):scale(mud)
##
## Df Deviance AIC
## - I(scale(TPTN)^2) 1 425.24 2104.9
## - scale(CuPb):scale(TPTN) 1 425.31 2105.0
## - I(scale(CuPb)^2) 1 425.74 2105.4
## <none> 424.94 2106.7
## - I(scale(mud)^2) 1 427.75 2107.5
## - scale(mud):scale(CuPb) 1 428.74 2108.4
## - scale(mud):scale(TPTN) 1 430.32 2110.0
##
## Step: AIC=2104.94
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + scale(CuPb):scale(TPTN) + scale(mud):scale(TPTN) +
## scale(mud):scale(CuPb)
##
## Df Deviance AIC
## - scale(CuPb):scale(TPTN) 1 425.37 2103.1
## - I(scale(CuPb)^2) 1 425.87 2103.6
## <none> 425.22 2104.9
## - I(scale(mud)^2) 1 428.72 2106.4
## - scale(mud):scale(CuPb) 1 429.08 2106.8
## - scale(mud):scale(TPTN) 1 433.46 2111.2
##
## Step: AIC=2103.09
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + scale(mud):scale(TPTN) + scale(mud):scale(CuPb)
##
## Df Deviance AIC
## - I(scale(CuPb)^2) 1 425.71 2101.6
## <none> 425.21 2103.1
## - I(scale(mud)^2) 1 429.03 2104.9
## - scale(mud):scale(CuPb) 1 429.13 2105.0
## - scale(mud):scale(TPTN) 1 448.62 2124.5
##
## Step: AIC=2101.6
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + scale(TPTN) +
## scale(mud):scale(TPTN) + scale(mud):scale(CuPb)
##
## Df Deviance AIC
## <none> 425.58 2101.6
## - I(scale(mud)^2) 1 435.42 2109.4
## - scale(mud):scale(CuPb) 1 437.62 2111.6
## - scale(mud):scale(TPTN) 1 449.45 2123.5
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Start: AIC=1879.53
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(TPTN):scale(CuPb) +
## scale(TPTN):scale(mud) + scale(CuPb):scale(mud)
##
## Df Deviance AIC
## - I(scale(mud)^2) 1 243.81 1877.6
## - I(scale(CuPb)^2) 1 243.85 1877.6
## - scale(mud):scale(CuPb) 1 243.93 1877.7
## - scale(mud):scale(TPTN) 1 244.12 1877.9
## <none> 243.75 1879.5
## - scale(CuPb):scale(TPTN) 1 255.38 1889.2
## - I(scale(TPTN)^2) 1 294.51 1928.3
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
##
## Step: AIC=1877.59
## abund + 1 ~ scale(mud) + scale(CuPb) + I(scale(CuPb)^2) + scale(TPTN) +
## I(scale(TPTN)^2) + scale(CuPb):scale(TPTN) + scale(mud):scale(TPTN) +
## scale(mud):scale(CuPb)
##
## Df Deviance AIC
## - I(scale(CuPb)^2) 1 243.96 1875.7
## - scale(mud):scale(TPTN) 1 244.16 1875.9
## - scale(mud):scale(CuPb) 1 244.23 1876.0
## <none> 243.81 1877.6
## - scale(CuPb):scale(TPTN) 1 256.98 1888.8
## - I(scale(TPTN)^2) 1 298.86 1930.6
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
##
## Step: AIC=1875.74
## abund + 1 ~ scale(mud) + scale(CuPb) + scale(TPTN) + I(scale(TPTN)^2) +
## scale(CuPb):scale(TPTN) + scale(mud):scale(TPTN) + scale(mud):scale(CuPb)
##
## Df Deviance AIC
## - scale(mud):scale(TPTN) 1 244.17 1873.9
## - scale(mud):scale(CuPb) 1 244.25 1874.0
## <none> 243.96 1875.7
## - scale(CuPb):scale(TPTN) 1 271.19 1901.0
## - I(scale(TPTN)^2) 1 301.05 1930.8
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
##
## Step: AIC=1873.94
## abund + 1 ~ scale(mud) + scale(CuPb) + scale(TPTN) + I(scale(TPTN)^2) +
## scale(CuPb):scale(TPTN) + scale(mud):scale(CuPb)
##
## Df Deviance AIC
## - scale(mud):scale(CuPb) 1 244.29 1872.1
## <none> 244.17 1873.9
## - scale(CuPb):scale(TPTN) 1 272.34 1900.1
## - I(scale(TPTN)^2) 1 341.90 1969.7
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
##
## Step: AIC=1872.07
## abund + 1 ~ scale(mud) + scale(CuPb) + scale(TPTN) + I(scale(TPTN)^2) +
## scale(CuPb):scale(TPTN)
##
## Df Deviance AIC
## - scale(mud) 1 244.69 1870.5
## <none> 244.29 1872.1
## - scale(CuPb):scale(TPTN) 1 332.08 1957.9
## - I(scale(TPTN)^2) 1 352.33 1978.1
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
##
## Step: AIC=1870.47
## abund + 1 ~ scale(CuPb) + scale(TPTN) + I(scale(TPTN)^2) + scale(CuPb):scale(TPTN)
##
## Df Deviance AIC
## <none> 244.69 1870.5
## - scale(CuPb):scale(TPTN) 1 334.23 1958.0
## - I(scale(TPTN)^2) 1 354.10 1977.9
## Warning in glm.nb(abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb)
## + : alternation limit reached
## Start: AIC=1808.26
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(TPTN):scale(CuPb) +
## scale(TPTN):scale(mud) + scale(CuPb):scale(mud)
##
## Df Deviance AIC
## - scale(mud):scale(TPTN) 1 249.66 1806.5
## - I(scale(mud)^2) 1 249.79 1806.6
## - scale(mud):scale(CuPb) 1 249.86 1806.7
## <none> 249.42 1808.3
## - scale(CuPb):scale(TPTN) 1 253.25 1810.1
## - I(scale(CuPb)^2) 1 253.40 1810.2
## - I(scale(TPTN)^2) 1 255.11 1812.0
##
## Step: AIC=1806.5
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(CuPb):scale(TPTN) +
## scale(mud):scale(CuPb)
##
## Df Deviance AIC
## - scale(mud):scale(CuPb) 1 250.24 1805.1
## - I(scale(mud)^2) 1 251.27 1806.1
## <none> 249.64 1806.5
## - I(scale(CuPb)^2) 1 254.58 1809.4
## - scale(CuPb):scale(TPTN) 1 254.81 1809.7
## - I(scale(TPTN)^2) 1 255.71 1810.6
##
## Step: AIC=1805.1
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(CuPb):scale(TPTN)
##
## Df Deviance AIC
## <none> 250.12 1805.1
## - scale(CuPb):scale(TPTN) 1 255.65 1808.6
## - I(scale(TPTN)^2) 1 256.07 1809.0
## - I(scale(CuPb)^2) 1 256.11 1809.1
## - I(scale(mud)^2) 1 258.87 1811.8
## - scale(mud) 1 262.17 1815.2
## Start: AIC=2031.78
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(TPTN):scale(CuPb) +
## scale(TPTN):scale(mud) + scale(CuPb):scale(mud)
##
## Df Deviance AIC
## - I(scale(CuPb)^2) 1 331.40 2029.8
## - scale(CuPb):scale(TPTN) 1 331.65 2030.0
## - scale(mud):scale(TPTN) 1 331.82 2030.2
## - I(scale(mud)^2) 1 332.36 2030.8
## <none> 331.40 2031.8
## - I(scale(TPTN)^2) 1 335.41 2033.8
## - scale(mud):scale(CuPb) 1 337.49 2035.9
##
## Step: AIC=2029.79
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + scale(TPTN) +
## I(scale(TPTN)^2) + scale(CuPb):scale(TPTN) + scale(mud):scale(TPTN) +
## scale(mud):scale(CuPb)
##
## Df Deviance AIC
## - scale(CuPb):scale(TPTN) 1 331.83 2028.2
## - scale(mud):scale(TPTN) 1 331.84 2028.2
## - I(scale(mud)^2) 1 332.50 2028.9
## <none> 331.41 2029.8
## - I(scale(TPTN)^2) 1 335.45 2031.8
## - scale(mud):scale(CuPb) 1 344.67 2041.0
##
## Step: AIC=2028.2
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + scale(TPTN) +
## I(scale(TPTN)^2) + scale(mud):scale(TPTN) + scale(mud):scale(CuPb)
##
## Df Deviance AIC
## - scale(mud):scale(TPTN) 1 332.85 2027.1
## <none> 331.98 2028.2
## - I(scale(mud)^2) 1 334.59 2028.8
## - I(scale(TPTN)^2) 1 338.96 2033.2
## - scale(mud):scale(CuPb) 1 360.87 2055.1
##
## Step: AIC=2027.06
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + scale(TPTN) +
## I(scale(TPTN)^2) + scale(mud):scale(CuPb)
##
## Df Deviance AIC
## - I(scale(mud)^2) 1 335.41 2027.0
## <none> 333.51 2027.1
## - scale(TPTN) 1 353.92 2045.5
## - scale(mud):scale(CuPb) 1 361.64 2053.2
## - I(scale(TPTN)^2) 1 379.11 2070.7
##
## Step: AIC=2026.96
## abund + 1 ~ scale(mud) + scale(CuPb) + scale(TPTN) + I(scale(TPTN)^2) +
## scale(mud):scale(CuPb)
##
## Df Deviance AIC
## <none> 334.68 2027.0
## - scale(TPTN) 1 353.95 2044.2
## - I(scale(TPTN)^2) 1 383.45 2073.7
## - scale(mud):scale(CuPb) 1 396.77 2087.1
## Start: AIC=2451.74
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(TPTN):scale(CuPb) +
## scale(TPTN):scale(mud) + scale(CuPb):scale(mud)
##
## Df Deviance AIC
## - scale(mud):scale(CuPb) 1 522.65 2449.8
## - I(scale(CuPb)^2) 1 522.73 2449.9
## <none> 522.56 2451.7
## - scale(CuPb):scale(TPTN) 1 525.99 2453.2
## - I(scale(mud)^2) 1 529.18 2456.3
## - scale(mud):scale(TPTN) 1 531.70 2458.9
## - I(scale(TPTN)^2) 1 544.53 2471.7
##
## Step: AIC=2449.83
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(CuPb):scale(TPTN) +
## scale(mud):scale(TPTN)
##
## Df Deviance AIC
## - I(scale(CuPb)^2) 1 523.28 2448.6
## <none> 522.52 2449.8
## - scale(CuPb):scale(TPTN) 1 525.87 2451.2
## - I(scale(mud)^2) 1 531.55 2456.8
## - scale(mud):scale(TPTN) 1 531.58 2456.9
## - I(scale(TPTN)^2) 1 544.40 2469.7
##
## Step: AIC=2448.58
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + scale(TPTN) +
## I(scale(TPTN)^2) + scale(CuPb):scale(TPTN) + scale(mud):scale(TPTN)
##
## Df Deviance AIC
## <none> 523.09 2448.6
## - scale(CuPb):scale(TPTN) 1 528.22 2451.7
## - scale(mud):scale(TPTN) 1 533.46 2456.9
## - I(scale(mud)^2) 1 533.82 2457.3
## - I(scale(TPTN)^2) 1 545.76 2469.2
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Start: AIC=1747.72
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(TPTN):scale(CuPb) +
## scale(TPTN):scale(mud) + scale(CuPb):scale(mud)
##
## Df Deviance AIC
## - I(scale(CuPb)^2) 1 188.54 1745.7
## - scale(mud):scale(CuPb) 1 188.64 1745.8
## - scale(CuPb):scale(TPTN) 1 188.77 1745.9
## - I(scale(mud)^2) 1 189.62 1746.8
## - scale(mud):scale(TPTN) 1 190.01 1747.2
## - I(scale(TPTN)^2) 1 190.35 1747.5
## <none> 188.54 1747.7
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
##
## Step: AIC=1745.72
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + scale(TPTN) +
## I(scale(TPTN)^2) + scale(CuPb):scale(TPTN) + scale(mud):scale(TPTN) +
## scale(mud):scale(CuPb)
##
## Df Deviance AIC
## - scale(mud):scale(CuPb) 1 188.81 1744.0
## - scale(CuPb):scale(TPTN) 1 188.83 1744.0
## - I(scale(mud)^2) 1 189.64 1744.8
## - scale(mud):scale(TPTN) 1 190.12 1745.3
## - I(scale(TPTN)^2) 1 190.43 1745.6
## <none> 188.54 1745.7
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
##
## Step: AIC=1743.98
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + scale(TPTN) +
## I(scale(TPTN)^2) + scale(CuPb):scale(TPTN) + scale(mud):scale(TPTN)
##
## Df Deviance AIC
## - scale(CuPb):scale(TPTN) 1 188.85 1742.0
## - I(scale(TPTN)^2) 1 190.43 1743.6
## - scale(mud):scale(TPTN) 1 190.43 1743.6
## <none> 188.81 1744.0
## - I(scale(mud)^2) 1 190.91 1744.1
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
##
## Step: AIC=1742.02
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + scale(TPTN) +
## I(scale(TPTN)^2) + scale(mud):scale(TPTN)
##
## Df Deviance AIC
## - scale(CuPb) 1 189.15 1740.3
## - I(scale(TPTN)^2) 1 190.59 1741.8
## <none> 188.85 1742.0
## - scale(mud):scale(TPTN) 1 190.85 1742.0
## - I(scale(mud)^2) 1 191.05 1742.2
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
##
## Step: AIC=1740.33
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(TPTN) + I(scale(TPTN)^2) +
## scale(mud):scale(TPTN)
##
## Df Deviance AIC
## - I(scale(TPTN)^2) 1 190.81 1740.0
## <none> 189.15 1740.3
## - scale(mud):scale(TPTN) 1 191.38 1740.5
## - I(scale(mud)^2) 1 192.47 1741.6
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
##
## Step: AIC=1739.98
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(TPTN) + scale(mud):scale(TPTN)
##
## Df Deviance AIC
## - scale(mud):scale(TPTN) 1 191.90 1739.1
## - I(scale(mud)^2) 1 192.50 1739.7
## <none> 190.81 1740.0
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
##
## Step: AIC=1739.07
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(TPTN)
##
## Df Deviance AIC
## - scale(mud) 1 191.90 1737.1
## - scale(TPTN) 1 191.95 1737.1
## - I(scale(mud)^2) 1 192.71 1737.9
## <none> 191.90 1739.1
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
##
## Step: AIC=1737.07
## abund + 1 ~ I(scale(mud)^2) + scale(TPTN)
##
## Df Deviance AIC
## - scale(TPTN) 1 192.00 1735.2
## - I(scale(mud)^2) 1 192.85 1736.0
## <none> 191.90 1737.1
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
##
## Step: AIC=1735.17
## abund + 1 ~ I(scale(mud)^2)
##
## Df Deviance AIC
## - I(scale(mud)^2) 1 193.13 1734.3
## <none> 192.00 1735.2
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
## Warning in theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace =
## control$trace > : iteration limit reached
##
## Step: AIC=1734.31
## abund + 1 ~ 1
##
## Start: AIC=2643.26
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(TPTN):scale(CuPb) +
## scale(TPTN):scale(mud) + scale(CuPb):scale(mud)
##
## Df Deviance AIC
## <none> 553.37 2643.3
## - scale(CuPb):scale(TPTN) 1 555.70 2643.6
## - scale(mud):scale(CuPb) 1 556.37 2644.3
## - scale(mud):scale(TPTN) 1 556.48 2644.4
## - I(scale(TPTN)^2) 1 556.56 2644.5
## - I(scale(mud)^2) 1 557.05 2644.9
## - I(scale(CuPb)^2) 1 565.72 2653.6
## Start: AIC=2570.28
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(TPTN):scale(CuPb) +
## scale(TPTN):scale(mud) + scale(CuPb):scale(mud)
##
## Df Deviance AIC
## - scale(mud):scale(TPTN) 1 519.29 2568.6
## - scale(CuPb):scale(TPTN) 1 520.61 2569.9
## <none> 519.00 2570.3
## - scale(mud):scale(CuPb) 1 521.28 2570.6
## - I(scale(mud)^2) 1 521.80 2571.1
## - I(scale(TPTN)^2) 1 524.66 2573.9
## - I(scale(CuPb)^2) 1 525.03 2574.3
##
## Step: AIC=2568.57
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(CuPb):scale(TPTN) +
## scale(mud):scale(CuPb)
##
## Df Deviance AIC
## <none> 518.82 2568.6
## - scale(CuPb):scale(TPTN) 1 521.30 2569.1
## - scale(mud):scale(CuPb) 1 521.43 2569.2
## - I(scale(TPTN)^2) 1 524.89 2572.6
## - I(scale(CuPb)^2) 1 526.17 2573.9
## - I(scale(mud)^2) 1 526.50 2574.2
##without scaling opredictors####
# sp_models <- sp %>%
# gather(sp, abund, -c(1:6)) %>%
# group_by(sp) %>%
# do(fit_sp = step(
# glm.nb(
# abund + 1 ~
# mud +
# I(mud ^ 2) +
# CuPb +
# I(CuPb ^ 2) +
# TPTN +
# I(TPTN ^ 2) +
# TPTN:CuPb +
# TPTN:mud +
# CuPb:mud,
# data = .
# ),
# control = glm.control(trace = 10, maxit = 1000)
# ),
# direction = 'backwards')
##get spp coefficients and rename terms####
sp_coef = tidy(sp_models, fit_sp) %>%
data.frame(.) %>%
mutate(
term = factor(term),
term = fct_recode(
term,
"Intercept" = "(Intercept)",
"Sediment" = "scale(mud)",
"Sediment^2" = "I(scale(mud)^2)",
"Metals" = "scale(CuPb)",
"Metals^2" = "I(scale(CuPb)^2)",
"Nutrients" = "scale(TPTN)",
"Nutrients^2" = "I(scale(TPTN)^2)",
"Nutrients x Metals" = "scale(CuPb):scale(TPTN)",
"Sediment x Nutrients" = "scale(mud):scale(TPTN)",
"Sediment x Metals" = "scale(mud):scale(CuPb)"
)
)
##subset relevant spp coefficients####
sp_coef1 <- sp_coef %>%
dplyr::filter(term != 'Intercept' &
term != 'Sediment^2' &
term != 'Metals^2' &
term != 'Nutrients^2') %>%
mutate(term = factor(term))
###Coefficient plot for species####
ggplot(sp_coef1,
aes(
x = estimate,
y = fct_rev(fct_inorder(term)),
color = term
)) +
geom_point() +
geom_errorbarh(aes(
xmin = estimate + (std.error * 1.96),
xmax = estimate - (std.error * 1.96),
height = .2
)) +
facet_wrap(~ sp) +
geom_vline(xintercept = 0,
lty = 2,
col = 2) +
ylab('') +
xlab('Estimates') +
geom_hline(yintercept = 3.5, lty = 2) +
scale_color_discrete(guide = F)

####Summary of spp regresssion####
sp_Summ <- glance(sp_models, fit_sp) %>%
mutate(Rsqr = 1 - (deviance / null.deviance)) %>%
dplyr::select(-df.null, -BIC) %>%
dplyr::filter(Rsqr > .1) %>%
print(n = 20)
## Source: local data frame [13 x 7]
## Groups: sp [13]
##
## sp null.deviance logLik AIC deviance
## (chr) (dbl) (dbl) (dbl) (dbl)
## 1 Anthopleura_aureoradiata 1206.7554 -1834.4753 3686.951 711.9269
## 2 Aonides_trifida 711.9496 -1212.6931 2445.386 468.4648
## 3 Arcuatula_senhousia 638.9090 -1142.1075 2304.215 429.8146
## 4 Austrominius_modestus 1172.3609 -1459.8502 2937.700 598.2667
## 5 Austrovenus_stutchburyi 1282.2567 -2021.9016 4061.803 714.4673
## 6 Hyboscolex_longiseta 249.7132 -900.9342 1819.868 212.2888
## 7 Linucula_hartvigiana 935.1958 -2218.9836 4457.967 777.8151
## 8 Macomona_liliana 826.3474 -1558.0494 3132.099 708.3472
## 9 Magelona_dakini 619.8039 -1170.0689 2360.138 454.8627
## 10 Notoacmea_elongata_ 494.4091 -1043.7986 2103.597 425.5781
## 11 Orbinia_papillosa 441.6075 -930.2342 1872.468 244.6890
## 12 Paphies_australis 491.6805 -1007.4804 2028.961 334.6768
## 13 Zeacumantus_subcarinatus 658.3974 -1275.2855 2570.571 518.8195
## Variables not shown: df.residual (int), Rsqr (dbl)
sp_coef2 <-
right_join(sp_coef1, sp_Summ, by = 'sp') %>%
mutate(
spp = gsub('_', ' ', sp),
term = factor(term),
term = fct_relevel(
term,
'Sediment',
'Metals',
'Nutrients',
'Nutrients x Metals',
'Sediment x Metals' ,
'Sediment x Nutrients'
)
)
##save spp coefficient results####
write.csv(sp_coef2, 'sp_summary.csv', row.names = F)
##plot spp with Rsq>0.1###
sp_plot <-
ggplot(sp_coef2,
aes(
x = estimate,
y = fct_rev(fct_inorder(term)),
color = term
)) +
geom_point() +
geom_errorbarh(aes(
xmin = estimate + (std.error * 1.96),
xmax = estimate - (std.error * 1.96),
height = .2
)) +
facet_wrap(~ spp) +
geom_vline(xintercept = 0,
lty = 2,
col = 1) +
ylab('') +
xlab('Estimates') +
geom_hline(yintercept = 3.5,
lty = 2,
col = 1) +
scale_color_discrete(guide = F) +
theme(strip.text = element_text(face = "italic"))
print(sp_plot)

ggsave(
sp_plot,
file = 'sp_plot.tif',
device = 'tiff',
dpi = 900,
compression = 'lzw'
)
## Saving 7 x 5 in image
####2. Traits#####
##read data
trait <- read_excel('InteractionData_07-09-16.xlsx', 2)
###Gamma glm for traits####
traits_models <- trait %>% gather(trait, abund,-c(1:6)) %>%
group_by(trait) %>%
do(fit_trait = step(
glm(
abund + 1 ~
scale(mud) +
I(scale(mud) ^ 2) +
scale(CuPb) +
I(scale(CuPb) ^ 2) +
scale(TPTN) +
I(scale(TPTN) ^ 2) +
scale(TPTN):scale(CuPb) +
scale(TPTN):scale(mud) +
scale(CuPb):scale(mud),
family = Gamma('log'),
data = .
)
),
direction = 'both')
## Start: AIC=3766.84
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(TPTN):scale(CuPb) +
## scale(TPTN):scale(mud) + scale(CuPb):scale(mud)
##
## Df Deviance AIC
## - I(scale(TPTN)^2) 1 1142.0 3766.7
## <none> 1137.2 3766.8
## - scale(mud):scale(TPTN) 1 1145.4 3768.1
## - scale(CuPb):scale(TPTN) 1 1147.7 3769.0
## - I(scale(CuPb)^2) 1 1152.2 3770.7
## - I(scale(mud)^2) 1 1167.4 3776.7
## - scale(mud):scale(CuPb) 1 1173.6 3779.1
##
## Step: AIC=3768.72
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + scale(CuPb):scale(TPTN) + scale(mud):scale(TPTN) +
## scale(mud):scale(CuPb)
##
## Start: AIC=5873.41
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(TPTN):scale(CuPb) +
## scale(TPTN):scale(mud) + scale(CuPb):scale(mud)
##
## Df Deviance AIC
## - scale(mud):scale(TPTN) 1 775.03 5871.5
## <none> 774.96 5873.4
## - scale(mud):scale(CuPb) 1 777.55 5873.7
## - scale(CuPb):scale(TPTN) 1 777.79 5873.9
## - I(scale(CuPb)^2) 1 780.32 5876.2
## - I(scale(mud)^2) 1 785.44 5880.7
## - I(scale(TPTN)^2) 1 787.92 5882.9
##
## Step: AIC=5871.49
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(CuPb):scale(TPTN) +
## scale(mud):scale(CuPb)
##
## Df Deviance AIC
## <none> 775.03 5871.5
## - scale(mud):scale(CuPb) 1 777.57 5871.7
## - scale(CuPb):scale(TPTN) 1 777.83 5872.0
## - I(scale(CuPb)^2) 1 780.61 5874.4
## - I(scale(mud)^2) 1 788.88 5881.8
## - I(scale(TPTN)^2) 1 794.86 5887.1
## Start: AIC=5350.55
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(TPTN):scale(CuPb) +
## scale(TPTN):scale(mud) + scale(CuPb):scale(mud)
##
## Df Deviance AIC
## <none> 365.69 5350.6
## - scale(CuPb):scale(TPTN) 1 368.23 5352.6
## - I(scale(mud)^2) 1 368.89 5353.7
## - I(scale(TPTN)^2) 1 369.26 5354.3
## - scale(mud):scale(CuPb) 1 371.94 5358.6
## - scale(mud):scale(TPTN) 1 377.21 5367.1
## - I(scale(CuPb)^2) 1 379.04 5370.0
## Start: AIC=6192.93
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(TPTN):scale(CuPb) +
## scale(TPTN):scale(mud) + scale(CuPb):scale(mud)
##
## Df Deviance AIC
## - I(scale(mud)^2) 1 401.47 6191.2
## - scale(CuPb):scale(TPTN) 1 401.58 6191.4
## - scale(mud):scale(CuPb) 1 402.39 6192.8
## <none> 401.34 6192.9
## - I(scale(CuPb)^2) 1 403.97 6195.5
## - scale(mud):scale(TPTN) 1 405.24 6197.7
## - I(scale(TPTN)^2) 1 407.08 6200.9
##
## Step: AIC=6191.21
## abund + 1 ~ scale(mud) + scale(CuPb) + I(scale(CuPb)^2) + scale(TPTN) +
## I(scale(TPTN)^2) + scale(CuPb):scale(TPTN) + scale(mud):scale(TPTN) +
## scale(mud):scale(CuPb)
##
## Df Deviance AIC
## - scale(CuPb):scale(TPTN) 1 401.85 6189.9
## - scale(mud):scale(CuPb) 1 402.41 6190.8
## <none> 401.47 6191.2
## - I(scale(CuPb)^2) 1 403.98 6193.6
## - I(scale(TPTN)^2) 1 408.50 6201.4
## - scale(mud):scale(TPTN) 1 409.11 6202.5
##
## Step: AIC=6189.97
## abund + 1 ~ scale(mud) + scale(CuPb) + I(scale(CuPb)^2) + scale(TPTN) +
## I(scale(TPTN)^2) + scale(mud):scale(TPTN) + scale(mud):scale(CuPb)
##
## Df Deviance AIC
## - scale(mud):scale(CuPb) 1 402.84 6189.7
## <none> 401.85 6190.0
## - I(scale(CuPb)^2) 1 404.15 6192.0
## - scale(mud):scale(TPTN) 1 409.18 6200.8
## - I(scale(TPTN)^2) 1 419.56 6218.9
##
## Step: AIC=6189.97
## abund + 1 ~ scale(mud) + scale(CuPb) + I(scale(CuPb)^2) + scale(TPTN) +
## I(scale(TPTN)^2) + scale(mud):scale(TPTN)
##
## Start: AIC=5030.58
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(TPTN):scale(CuPb) +
## scale(TPTN):scale(mud) + scale(CuPb):scale(mud)
##
## Df Deviance AIC
## - I(scale(mud)^2) 1 399.52 5029.0
## <none> 399.27 5030.6
## - scale(CuPb):scale(TPTN) 1 400.84 5031.0
## - scale(mud):scale(CuPb) 1 404.66 5036.9
## - I(scale(TPTN)^2) 1 405.46 5038.2
## - scale(mud):scale(TPTN) 1 409.14 5043.8
## - I(scale(CuPb)^2) 1 409.98 5045.1
##
## Step: AIC=5029.09
## abund + 1 ~ scale(mud) + scale(CuPb) + I(scale(CuPb)^2) + scale(TPTN) +
## I(scale(TPTN)^2) + scale(CuPb):scale(TPTN) + scale(mud):scale(TPTN) +
## scale(mud):scale(CuPb)
##
## Df Deviance AIC
## <none> 399.52 5029.1
## - scale(CuPb):scale(TPTN) 1 400.86 5029.2
## - I(scale(TPTN)^2) 1 405.60 5036.5
## - scale(mud):scale(CuPb) 1 407.70 5039.7
## - I(scale(CuPb)^2) 1 411.04 5044.9
## - scale(mud):scale(TPTN) 1 413.24 5048.3
## Start: AIC=6138.61
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(TPTN):scale(CuPb) +
## scale(TPTN):scale(mud) + scale(CuPb):scale(mud)
##
## Df Deviance AIC
## - I(scale(mud)^2) 1 328.65 6137.3
## - scale(mud):scale(CuPb) 1 328.96 6138.0
## <none> 328.32 6138.6
## - I(scale(TPTN)^2) 1 330.30 6141.0
## - scale(mud):scale(TPTN) 1 331.36 6143.4
## - scale(CuPb):scale(TPTN) 1 331.72 6144.2
## - I(scale(CuPb)^2) 1 335.19 6151.9
##
## Step: AIC=6137.42
## abund + 1 ~ scale(mud) + scale(CuPb) + I(scale(CuPb)^2) + scale(TPTN) +
## I(scale(TPTN)^2) + scale(CuPb):scale(TPTN) + scale(mud):scale(TPTN) +
## scale(mud):scale(CuPb)
##
## Df Deviance AIC
## - scale(mud):scale(CuPb) 1 329.02 6136.2
## <none> 328.65 6137.4
## - I(scale(TPTN)^2) 1 331.54 6141.8
## - scale(CuPb):scale(TPTN) 1 333.02 6145.1
## - I(scale(CuPb)^2) 1 335.21 6149.9
## - scale(mud):scale(TPTN) 1 336.32 6152.4
##
## Step: AIC=6136.33
## abund + 1 ~ scale(mud) + scale(CuPb) + I(scale(CuPb)^2) + scale(TPTN) +
## I(scale(TPTN)^2) + scale(CuPb):scale(TPTN) + scale(mud):scale(TPTN)
##
## Df Deviance AIC
## <none> 329.02 6136.3
## - I(scale(TPTN)^2) 1 331.57 6140.0
## - scale(CuPb):scale(TPTN) 1 333.54 6144.3
## - I(scale(CuPb)^2) 1 337.72 6153.5
## - scale(mud):scale(TPTN) 1 339.34 6157.1
## Start: AIC=5066.69
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(TPTN):scale(CuPb) +
## scale(TPTN):scale(mud) + scale(CuPb):scale(mud)
##
## Df Deviance AIC
## - scale(mud):scale(TPTN) 1 361.11 5065.0
## - scale(mud):scale(CuPb) 1 361.31 5065.4
## - I(scale(TPTN)^2) 1 361.94 5066.7
## <none> 360.98 5066.7
## - scale(CuPb):scale(TPTN) 1 362.69 5068.2
## - I(scale(CuPb)^2) 1 363.81 5070.5
## - I(scale(mud)^2) 1 366.91 5076.9
##
## Step: AIC=5064.98
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(CuPb):scale(TPTN) +
## scale(mud):scale(CuPb)
##
## Df Deviance AIC
## - scale(mud):scale(CuPb) 1 361.38 5063.5
## - I(scale(TPTN)^2) 1 361.98 5064.8
## <none> 361.11 5065.0
## - scale(CuPb):scale(TPTN) 1 362.69 5066.2
## - I(scale(CuPb)^2) 1 363.81 5068.5
## - I(scale(mud)^2) 1 374.03 5089.5
##
## Step: AIC=5063.58
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(CuPb):scale(TPTN)
##
## Df Deviance AIC
## - I(scale(TPTN)^2) 1 362.29 5063.4
## <none> 361.38 5063.6
## - scale(CuPb):scale(TPTN) 1 363.14 5065.2
## - I(scale(CuPb)^2) 1 364.68 5068.4
## - I(scale(mud)^2) 1 385.12 5110.3
## - scale(mud) 1 423.79 5189.8
##
## Step: AIC=5063.61
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + scale(CuPb):scale(TPTN)
##
## Start: AIC=4924.52
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(TPTN):scale(CuPb) +
## scale(TPTN):scale(mud) + scale(CuPb):scale(mud)
##
## Df Deviance AIC
## - scale(mud):scale(CuPb) 1 731.01 4922.5
## - scale(mud):scale(TPTN) 1 732.02 4923.5
## <none> 731.00 4924.5
## - I(scale(CuPb)^2) 1 734.70 4926.0
## - scale(CuPb):scale(TPTN) 1 742.67 4933.4
## - I(scale(mud)^2) 1 743.03 4933.7
## - I(scale(TPTN)^2) 1 747.36 4937.7
##
## Step: AIC=4922.54
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(CuPb):scale(TPTN) +
## scale(mud):scale(TPTN)
##
## Df Deviance AIC
## - scale(mud):scale(TPTN) 1 732.03 4921.5
## <none> 731.01 4922.5
## - I(scale(CuPb)^2) 1 738.94 4927.9
## - scale(CuPb):scale(TPTN) 1 742.77 4931.5
## - I(scale(TPTN)^2) 1 747.64 4936.0
## - I(scale(mud)^2) 1 748.80 4937.1
##
## Step: AIC=4921.73
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(CuPb):scale(TPTN)
##
## Df Deviance AIC
## <none> 732.03 4921.7
## - I(scale(CuPb)^2) 1 739.22 4926.5
## - scale(CuPb):scale(TPTN) 1 742.78 4929.8
## - I(scale(TPTN)^2) 1 761.38 4947.2
## - I(scale(mud)^2) 1 765.31 4950.9
## - scale(mud) 1 777.02 4961.9
## Start: AIC=5202.93
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(TPTN):scale(CuPb) +
## scale(TPTN):scale(mud) + scale(CuPb):scale(mud)
##
## Df Deviance AIC
## - I(scale(mud)^2) 1 659.04 5201.0
## - I(scale(CuPb)^2) 1 659.61 5201.4
## <none> 659.00 5202.9
## - I(scale(TPTN)^2) 1 661.55 5203.1
## - scale(CuPb):scale(TPTN) 1 662.09 5203.5
## - scale(mud):scale(CuPb) 1 662.51 5203.9
## - scale(mud):scale(TPTN) 1 663.58 5204.8
##
## Step: AIC=5200.99
## abund + 1 ~ scale(mud) + scale(CuPb) + I(scale(CuPb)^2) + scale(TPTN) +
## I(scale(TPTN)^2) + scale(CuPb):scale(TPTN) + scale(mud):scale(TPTN) +
## scale(mud):scale(CuPb)
##
## Df Deviance AIC
## - I(scale(CuPb)^2) 1 659.61 5199.5
## <none> 659.04 5201.0
## - I(scale(TPTN)^2) 1 661.89 5201.4
## - scale(CuPb):scale(TPTN) 1 662.09 5201.6
## - scale(mud):scale(CuPb) 1 662.79 5202.1
## - scale(mud):scale(TPTN) 1 666.39 5205.2
##
## Step: AIC=5199.72
## abund + 1 ~ scale(mud) + scale(CuPb) + scale(TPTN) + I(scale(TPTN)^2) +
## scale(CuPb):scale(TPTN) + scale(mud):scale(TPTN) + scale(mud):scale(CuPb)
##
## Df Deviance AIC
## <none> 659.61 5199.7
## - I(scale(TPTN)^2) 1 662.33 5200.0
## - scale(mud):scale(CuPb) 1 663.34 5200.8
## - scale(CuPb):scale(TPTN) 1 664.90 5202.1
## - scale(mud):scale(TPTN) 1 671.68 5207.7
## Start: AIC=4790.66
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(TPTN):scale(CuPb) +
## scale(TPTN):scale(mud) + scale(CuPb):scale(mud)
##
## Df Deviance AIC
## - scale(CuPb):scale(TPTN) 1 570.57 4788.7
## <none> 570.54 4790.7
## - scale(mud):scale(CuPb) 1 578.77 4796.0
## - I(scale(CuPb)^2) 1 580.27 4797.3
## - I(scale(TPTN)^2) 1 585.89 4802.3
## - I(scale(mud)^2) 1 586.22 4802.6
## - scale(mud):scale(TPTN) 1 592.15 4807.9
##
## Step: AIC=4788.71
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(mud):scale(TPTN) +
## scale(mud):scale(CuPb)
##
## Df Deviance AIC
## <none> 570.57 4788.7
## - scale(mud):scale(CuPb) 1 579.28 4794.5
## - I(scale(CuPb)^2) 1 582.68 4797.5
## - I(scale(mud)^2) 1 587.37 4801.7
## - I(scale(TPTN)^2) 1 591.53 4805.5
## - scale(mud):scale(TPTN) 1 593.51 4807.2
## Start: AIC=6144.73
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(TPTN):scale(CuPb) +
## scale(TPTN):scale(mud) + scale(CuPb):scale(mud)
##
## Df Deviance AIC
## - scale(mud):scale(TPTN) 1 712.72 6143.1
## - scale(CuPb):scale(TPTN) 1 713.47 6143.9
## <none> 712.33 6144.7
## - scale(mud):scale(CuPb) 1 717.11 6147.5
## - I(scale(CuPb)^2) 1 718.18 6148.6
## - I(scale(TPTN)^2) 1 720.66 6151.1
## - I(scale(mud)^2) 1 724.25 6154.6
##
## Step: AIC=6143.2
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(CuPb):scale(TPTN) +
## scale(mud):scale(CuPb)
##
## Df Deviance AIC
## - scale(CuPb):scale(TPTN) 1 713.64 6142.1
## <none> 712.72 6143.2
## - scale(mud):scale(CuPb) 1 717.12 6145.6
## - I(scale(CuPb)^2) 1 718.20 6146.7
## - I(scale(mud)^2) 1 727.48 6156.0
## - I(scale(TPTN)^2) 1 729.28 6157.8
##
## Step: AIC=6142.31
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(mud):scale(CuPb)
## Warning: glm.fit: algorithm did not converge
## Df Deviance AIC
## <none> 713.64 6142.3
## - I(scale(CuPb)^2) 1 718.32 6145.0
## - scale(mud):scale(CuPb) 1 718.57 6145.3
## - I(scale(mud)^2) 1 728.50 6155.2
## - I(scale(TPTN)^2) 1 756.13 6183.0
## - scale(TPTN) 1 882.58 6310.0
## Start: AIC=4204.81
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(TPTN):scale(CuPb) +
## scale(TPTN):scale(mud) + scale(CuPb):scale(mud)
##
## Df Deviance AIC
## <none> 1149.2 4204.8
## - I(scale(TPTN)^2) 1 1154.6 4205.0
## - scale(mud):scale(TPTN) 1 1155.2 4205.3
## - I(scale(CuPb)^2) 1 1159.1 4206.9
## - scale(CuPb):scale(TPTN) 1 1161.4 4207.8
## - I(scale(mud)^2) 1 1161.8 4208.0
## - scale(mud):scale(CuPb) 1 1189.8 4219.5
## Start: AIC=4847.04
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(TPTN):scale(CuPb) +
## scale(TPTN):scale(mud) + scale(CuPb):scale(mud)
##
## Df Deviance AIC
## - scale(mud):scale(CuPb) 1 942.83 4845.4
## - I(scale(CuPb)^2) 1 944.23 4846.4
## <none> 942.34 4847.0
## - scale(mud):scale(TPTN) 1 945.29 4847.1
## - scale(CuPb):scale(TPTN) 1 950.98 4851.0
## - I(scale(TPTN)^2) 1 967.04 4862.1
## - I(scale(mud)^2) 1 973.93 4866.9
##
## Step: AIC=4845.51
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(CuPb):scale(TPTN) +
## scale(mud):scale(TPTN)
##
## Df Deviance AIC
## - I(scale(CuPb)^2) 1 944.51 4844.7
## - scale(mud):scale(TPTN) 1 945.32 4845.2
## <none> 942.83 4845.5
## - scale(CuPb):scale(TPTN) 1 951.92 4849.8
## - I(scale(TPTN)^2) 1 969.34 4861.9
## - I(scale(mud)^2) 1 992.66 4878.0
##
## Step: AIC=4845.09
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + scale(TPTN) +
## I(scale(TPTN)^2) + scale(CuPb):scale(TPTN) + scale(mud):scale(TPTN)
##
## Df Deviance AIC
## - scale(mud):scale(TPTN) 1 946.48 4844.4
## <none> 944.51 4845.1
## - scale(CuPb):scale(TPTN) 1 960.51 4854.2
## - I(scale(TPTN)^2) 1 970.45 4861.0
## - I(scale(mud)^2) 1 992.69 4876.4
##
## Step: AIC=4844.94
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + scale(TPTN) +
## I(scale(TPTN)^2) + scale(CuPb):scale(TPTN)
##
## Df Deviance AIC
## <none> 946.48 4844.9
## - scale(CuPb):scale(TPTN) 1 960.52 4852.8
## - I(scale(TPTN)^2) 1 1015.52 4891.3
## - I(scale(mud)^2) 1 1029.76 4901.3
## - scale(mud) 1 1064.97 4925.9
## Start: AIC=6004.41
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(TPTN):scale(CuPb) +
## scale(TPTN):scale(mud) + scale(CuPb):scale(mud)
##
## Df Deviance AIC
## - scale(mud):scale(CuPb) 1 785.76 6002.4
## - scale(CuPb):scale(TPTN) 1 785.78 6002.4
## - I(scale(CuPb)^2) 1 786.62 6003.1
## - scale(mud):scale(TPTN) 1 787.06 6003.5
## - I(scale(mud)^2) 1 787.50 6003.9
## <none> 785.76 6004.4
## - I(scale(TPTN)^2) 1 798.21 6012.8
##
## Step: AIC=6002.41
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(CuPb):scale(TPTN) +
## scale(mud):scale(TPTN)
##
## Df Deviance AIC
## - scale(CuPb):scale(TPTN) 1 785.78 6000.4
## - scale(mud):scale(TPTN) 1 787.15 6001.6
## - I(scale(CuPb)^2) 1 787.39 6001.8
## - I(scale(mud)^2) 1 787.99 6002.3
## <none> 785.76 6002.4
## - I(scale(TPTN)^2) 1 798.34 6010.9
##
## Step: AIC=6000.44
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(mud):scale(TPTN)
##
## Df Deviance AIC
## - scale(mud):scale(TPTN) 1 787.47 5999.9
## - I(scale(mud)^2) 1 788.03 6000.3
## <none> 785.78 6000.4
## - scale(CuPb) 1 789.62 6001.7
## - I(scale(CuPb)^2) 1 796.13 6007.1
## - I(scale(TPTN)^2) 1 803.03 6012.9
##
## Step: AIC=6000.31
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2)
##
## Df Deviance AIC
## <none> 787.47 6000.3
## - scale(CuPb) 1 790.67 6001.0
## - I(scale(CuPb)^2) 1 799.59 6008.4
## - I(scale(mud)^2) 1 802.76 6011.1
## - I(scale(TPTN)^2) 1 830.63 6034.4
## - scale(mud) 1 831.47 6035.1
## - scale(TPTN) 1 903.26 6095.2
## Start: AIC=6064.84
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(TPTN):scale(CuPb) +
## scale(TPTN):scale(mud) + scale(CuPb):scale(mud)
##
## Df Deviance AIC
## - I(scale(mud)^2) 1 558.55 6063.0
## <none> 558.41 6064.8
## - scale(mud):scale(CuPb) 1 560.48 6065.1
## - I(scale(TPTN)^2) 1 560.73 6065.4
## - scale(CuPb):scale(TPTN) 1 562.72 6067.5
## - scale(mud):scale(TPTN) 1 564.30 6069.3
## - I(scale(CuPb)^2) 1 568.09 6073.4
##
## Step: AIC=6063.05
## abund + 1 ~ scale(mud) + scale(CuPb) + I(scale(CuPb)^2) + scale(TPTN) +
## I(scale(TPTN)^2) + scale(CuPb):scale(TPTN) + scale(mud):scale(TPTN) +
## scale(mud):scale(CuPb)
##
## Df Deviance AIC
## <none> 558.55 6063.1
## - scale(mud):scale(CuPb) 1 560.53 6063.2
## - I(scale(TPTN)^2) 1 561.90 6064.7
## - scale(CuPb):scale(TPTN) 1 563.31 6066.2
## - I(scale(CuPb)^2) 1 568.16 6071.5
## - scale(mud):scale(TPTN) 1 571.19 6074.8
## Start: AIC=4190.16
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(TPTN):scale(CuPb) +
## scale(TPTN):scale(mud) + scale(CuPb):scale(mud)
##
## Df Deviance AIC
## - I(scale(TPTN)^2) 1 384.82 4188.2
## - scale(mud):scale(CuPb) 1 385.42 4188.8
## - I(scale(mud)^2) 1 386.20 4189.6
## - scale(mud):scale(TPTN) 1 386.78 4190.2
## <none> 384.78 4190.2
## - I(scale(CuPb)^2) 1 389.16 4192.5
## - scale(CuPb):scale(TPTN) 1 395.26 4198.6
##
## Step: AIC=4188.24
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + scale(CuPb):scale(TPTN) + scale(mud):scale(TPTN) +
## scale(mud):scale(CuPb)
##
## Df Deviance AIC
## - scale(mud):scale(CuPb) 1 385.43 4186.9
## - I(scale(mud)^2) 1 386.67 4188.1
## <none> 384.82 4188.2
## - scale(mud):scale(TPTN) 1 388.20 4189.6
## - I(scale(CuPb)^2) 1 389.27 4190.7
## - scale(CuPb):scale(TPTN) 1 399.40 4200.8
##
## Step: AIC=4187.53
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + scale(CuPb):scale(TPTN) + scale(mud):scale(TPTN)
##
## Df Deviance AIC
## - I(scale(mud)^2) 1 386.74 4186.8
## <none> 385.43 4187.5
## - scale(mud):scale(TPTN) 1 389.74 4189.8
## - scale(CuPb):scale(TPTN) 1 399.66 4199.8
## - I(scale(CuPb)^2) 1 402.20 4202.3
##
## Step: AIC=4188.27
## abund + 1 ~ scale(mud) + scale(CuPb) + I(scale(CuPb)^2) + scale(TPTN) +
## scale(CuPb):scale(TPTN) + scale(mud):scale(TPTN)
##
## Start: AIC=5825.15
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(TPTN):scale(CuPb) +
## scale(TPTN):scale(mud) + scale(CuPb):scale(mud)
##
## Df Deviance AIC
## - scale(mud):scale(TPTN) 1 495.23 5824.1
## - scale(CuPb):scale(TPTN) 1 495.90 5824.8
## - I(scale(CuPb)^2) 1 496.06 5825.0
## <none> 494.44 5825.2
## - scale(mud):scale(CuPb) 1 497.18 5826.3
## - I(scale(mud)^2) 1 502.75 5832.8
## - I(scale(TPTN)^2) 1 504.05 5834.3
##
## Step: AIC=5824.47
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(CuPb):scale(TPTN) +
## scale(mud):scale(CuPb)
##
## Df Deviance AIC
## - scale(CuPb):scale(TPTN) 1 496.26 5823.7
## - I(scale(CuPb)^2) 1 496.34 5823.8
## <none> 495.23 5824.5
## - scale(mud):scale(CuPb) 1 497.44 5825.0
## - I(scale(mud)^2) 1 503.52 5832.1
## - I(scale(TPTN)^2) 1 513.08 5843.2
##
## Step: AIC=5824.19
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(mud):scale(CuPb)
##
## Df Deviance AIC
## - I(scale(CuPb)^2) 1 496.62 5822.6
## <none> 496.26 5824.2
## - scale(mud):scale(CuPb) 1 498.96 5825.3
## - I(scale(mud)^2) 1 504.13 5831.3
## - I(scale(TPTN)^2) 1 542.16 5875.4
## - scale(TPTN) 1 559.22 5895.2
##
## Step: AIC=5822.8
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + scale(TPTN) +
## I(scale(TPTN)^2) + scale(mud):scale(CuPb)
##
## Df Deviance AIC
## <none> 496.62 5822.8
## - scale(mud):scale(CuPb) 1 505.23 5830.8
## - I(scale(mud)^2) 1 512.91 5839.6
## - I(scale(TPTN)^2) 1 542.26 5873.6
## - scale(TPTN) 1 560.29 5894.5
## Start: AIC=5081.78
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(TPTN):scale(CuPb) +
## scale(TPTN):scale(mud) + scale(CuPb):scale(mud)
##
## Df Deviance AIC
## - scale(mud):scale(TPTN) 1 818.36 5080.1
## - scale(CuPb):scale(TPTN) 1 820.55 5081.7
## <none> 817.93 5081.8
## - I(scale(CuPb)^2) 1 821.32 5082.2
## - I(scale(TPTN)^2) 1 822.27 5082.9
## - I(scale(mud)^2) 1 822.44 5083.0
## - scale(mud):scale(CuPb) 1 833.20 5090.7
##
## Step: AIC=5080.24
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(CuPb):scale(TPTN) +
## scale(mud):scale(CuPb)
##
## Df Deviance AIC
## - scale(CuPb):scale(TPTN) 1 820.72 5079.9
## <none> 818.36 5080.2
## - I(scale(CuPb)^2) 1 822.76 5081.4
## - I(scale(TPTN)^2) 1 823.02 5081.6
## - I(scale(mud)^2) 1 831.78 5087.9
## - scale(mud):scale(CuPb) 1 835.99 5090.9
##
## Step: AIC=5080.75
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(mud):scale(CuPb)
##
## Start: AIC=5883.45
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(TPTN):scale(CuPb) +
## scale(TPTN):scale(mud) + scale(CuPb):scale(mud)
##
## Df Deviance AIC
## - scale(CuPb):scale(TPTN) 1 437.77 5881.5
## - I(scale(CuPb)^2) 1 437.87 5881.6
## - scale(mud):scale(TPTN) 1 437.90 5881.7
## - scale(mud):scale(CuPb) 1 438.09 5882.0
## <none> 437.75 5883.4
## - I(scale(TPTN)^2) 1 442.14 5888.1
## - I(scale(mud)^2) 1 447.12 5895.7
##
## Step: AIC=5881.49
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(mud):scale(TPTN) +
## scale(mud):scale(CuPb)
##
## Df Deviance AIC
## - I(scale(CuPb)^2) 1 437.87 5879.6
## - scale(mud):scale(TPTN) 1 437.96 5879.8
## - scale(mud):scale(CuPb) 1 438.09 5880.0
## <none> 437.77 5881.5
## - I(scale(TPTN)^2) 1 444.75 5890.1
## - I(scale(mud)^2) 1 447.73 5894.7
##
## Step: AIC=5879.67
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + scale(TPTN) +
## I(scale(TPTN)^2) + scale(mud):scale(TPTN) + scale(mud):scale(CuPb)
##
## Df Deviance AIC
## - scale(mud):scale(TPTN) 1 438.12 5878.1
## <none> 437.87 5879.7
## - scale(mud):scale(CuPb) 1 443.07 5885.6
## - I(scale(TPTN)^2) 1 444.76 5888.2
## - I(scale(mud)^2) 1 448.82 5894.4
##
## Step: AIC=5878.14
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + scale(TPTN) +
## I(scale(TPTN)^2) + scale(mud):scale(CuPb)
##
## Df Deviance AIC
## <none> 438.12 5878.1
## - scale(mud):scale(CuPb) 1 443.09 5883.8
## - I(scale(mud)^2) 1 455.44 5902.7
## - I(scale(TPTN)^2) 1 475.22 5933.0
## - scale(TPTN) 1 508.56 5984.0
## Start: AIC=4679.44
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(TPTN):scale(CuPb) +
## scale(TPTN):scale(mud) + scale(CuPb):scale(mud)
##
## Df Deviance AIC
## - scale(CuPb):scale(TPTN) 1 554.36 4677.5
## - scale(mud):scale(CuPb) 1 554.50 4677.7
## - I(scale(CuPb)^2) 1 554.90 4678.2
## - scale(mud):scale(TPTN) 1 555.24 4678.7
## <none> 554.34 4679.4
## - I(scale(TPTN)^2) 1 556.42 4680.3
## - I(scale(mud)^2) 1 557.07 4681.2
##
## Step: AIC=4677.46
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(mud):scale(TPTN) +
## scale(mud):scale(CuPb)
##
## Df Deviance AIC
## - scale(mud):scale(CuPb) 1 554.52 4675.7
## - scale(mud):scale(TPTN) 1 555.27 4676.7
## - I(scale(CuPb)^2) 1 555.44 4677.0
## <none> 554.36 4677.5
## - I(scale(mud)^2) 1 557.27 4679.5
## - I(scale(TPTN)^2) 1 557.51 4679.8
##
## Step: AIC=4675.7
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(mud):scale(TPTN)
##
## Df Deviance AIC
## - scale(CuPb) 1 555.58 4675.2
## - scale(mud):scale(TPTN) 1 555.64 4675.3
## <none> 554.52 4675.7
## - I(scale(CuPb)^2) 1 557.68 4678.1
## - I(scale(TPTN)^2) 1 557.71 4678.1
## - I(scale(mud)^2) 1 558.81 4679.6
##
## Step: AIC=4675.3
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(mud):scale(TPTN)
##
## Df Deviance AIC
## - scale(mud):scale(TPTN) 1 556.60 4674.7
## <none> 555.58 4675.3
## - I(scale(TPTN)^2) 1 558.79 4677.8
## - I(scale(CuPb)^2) 1 560.34 4680.0
## - I(scale(mud)^2) 1 562.78 4683.5
##
## Step: AIC=4674.83
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2)
##
## Df Deviance AIC
## <none> 556.60 4674.8
## - I(scale(TPTN)^2) 1 560.51 4678.3
## - I(scale(CuPb)^2) 1 560.72 4678.6
## - I(scale(mud)^2) 1 613.65 4752.4
## - scale(TPTN) 1 647.94 4800.2
## - scale(mud) 1 722.11 4903.7
## Start: AIC=2956.2
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(TPTN):scale(CuPb) +
## scale(TPTN):scale(mud) + scale(CuPb):scale(mud)
##
## Df Deviance AIC
## - scale(mud):scale(CuPb) 1 908.16 2954.2
## - scale(mud):scale(TPTN) 1 908.35 2954.3
## - I(scale(mud)^2) 1 909.84 2954.5
## - I(scale(TPTN)^2) 1 916.30 2955.7
## <none> 907.93 2956.2
## - I(scale(CuPb)^2) 1 926.87 2957.6
## - scale(CuPb):scale(TPTN) 1 942.88 2960.5
##
## Step: AIC=2954.42
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(CuPb):scale(TPTN) +
## scale(mud):scale(TPTN)
##
## Df Deviance AIC
## - scale(mud):scale(TPTN) 1 909.07 2952.6
## - I(scale(mud)^2) 1 909.97 2952.7
## - I(scale(TPTN)^2) 1 916.30 2953.9
## <none> 908.16 2954.4
## - scale(CuPb):scale(TPTN) 1 944.27 2958.9
## - I(scale(CuPb)^2) 1 961.47 2962.1
##
## Step: AIC=2953.31
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(CuPb):scale(TPTN)
##
## Df Deviance AIC
## - I(scale(mud)^2) 1 910.21 2951.5
## - scale(mud) 1 913.96 2952.2
## <none> 909.07 2953.3
## - I(scale(TPTN)^2) 1 925.36 2954.3
## - scale(CuPb):scale(TPTN) 1 944.27 2957.7
## - I(scale(CuPb)^2) 1 961.47 2960.8
##
## Step: AIC=2952.41
## abund + 1 ~ scale(mud) + scale(CuPb) + I(scale(CuPb)^2) + scale(TPTN) +
## I(scale(TPTN)^2) + scale(CuPb):scale(TPTN)
##
## Df Deviance AIC
## <none> 910.21 2952.4
## - I(scale(TPTN)^2) 1 926.35 2953.3
## - scale(mud) 1 939.05 2955.6
## - scale(CuPb):scale(TPTN) 1 947.89 2957.2
## - I(scale(CuPb)^2) 1 963.44 2960.0
## Start: AIC=5756.99
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + I(scale(TPTN)^2) + scale(TPTN):scale(CuPb) +
## scale(TPTN):scale(mud) + scale(CuPb):scale(mud)
##
## Df Deviance AIC
## - I(scale(TPTN)^2) 1 535.17 5755.2
## - I(scale(mud)^2) 1 536.67 5756.6
## <none> 534.96 5757.0
## - scale(mud):scale(CuPb) 1 541.17 5760.9
## - scale(mud):scale(TPTN) 1 544.56 5764.1
## - scale(CuPb):scale(TPTN) 1 544.62 5764.1
## - I(scale(CuPb)^2) 1 556.74 5775.6
##
## Step: AIC=5755.32
## abund + 1 ~ scale(mud) + I(scale(mud)^2) + scale(CuPb) + I(scale(CuPb)^2) +
## scale(TPTN) + scale(CuPb):scale(TPTN) + scale(mud):scale(TPTN) +
## scale(mud):scale(CuPb)
##
## Df Deviance AIC
## - I(scale(mud)^2) 1 536.67 5754.7
## <none> 535.17 5755.3
## - scale(mud):scale(CuPb) 1 541.24 5759.1
## - scale(mud):scale(TPTN) 1 546.49 5764.0
## - scale(CuPb):scale(TPTN) 1 551.41 5768.7
## - I(scale(CuPb)^2) 1 559.51 5776.3
##
## Step: AIC=5755.66
## abund + 1 ~ scale(mud) + scale(CuPb) + I(scale(CuPb)^2) + scale(TPTN) +
## scale(CuPb):scale(TPTN) + scale(mud):scale(TPTN) + scale(mud):scale(CuPb)
###get coefficients for models and change factor names###
trait_Coef <- tidy(traits_models, fit_trait, conf.int = T) %>%
data.frame(.) %>%
mutate(
term = factor(term),
term = fct_recode(
term,
"Intercept" = "(Intercept)",
"Sediment" = "scale(mud)",
"Sediment^2" = "I(scale(mud)^2)",
"Metals" = "scale(CuPb)",
"Metals^2" = "I(scale(CuPb)^2)",
"Nutrients" = "scale(TPTN)",
"Nutrients^2" = "I(scale(TPTN)^2)",
"Nutrients x Metals" = "scale(CuPb):scale(TPTN)",
"Sediment x Nutrients" = "scale(mud):scale(TPTN)",
"Sediment x Metals" = "scale(mud):scale(CuPb)"
)
)
trait_coef1 <- trait_Coef %>%
dplyr::filter(term != 'Intercept' &
term != 'Sediment^2' &
term != 'Metals^2' &
term != 'Nutrients^2') %>%
mutate(term = factor(term))
##Color coef plot for traits####
ggplot(trait_coef1,
aes(
x = estimate,
y = fct_rev(fct_inorder(term)),
color = term
)) +
geom_point() +
geom_errorbarh(aes(xmin = conf.low,
xmax = conf.high),
height = .2) +
facet_wrap(~ trait) +
geom_vline(xintercept = 0,
lty = 2,
col = 1) +
ylab('') +
geom_hline(yintercept = 3.5, lty = 2) +
scale_color_discrete(guide = F)

trait_Summ = glance(traits_models, fit_trait) %>%
mutate(Rsqr = 1 - (deviance / null.deviance)) %>%
dplyr::filter(Rsqr > 0.1) %>%
print(n = 22)
## Source: local data frame [22 x 9]
## Groups: trait [22]
##
## trait null.deviance df.null logLik AIC BIC
## (chr) (dbl) (int) (dbl) (dbl) (dbl)
## 1 Attached 2076.4288 747 -1874.362 3768.723 3814.897
## 2 Calified 1113.7541 747 -2925.747 5871.493 5917.667
## 3 Deep 426.6548 747 -2664.277 5350.554 5401.345
## 4 Deposit 466.6612 747 -3086.986 6189.972 6226.911
## 5 Depth_to_surface 479.8139 747 -2504.543 5029.087 5075.261
## 6 Freely_motile 437.1190 747 -3059.163 6136.326 6177.882
## 7 Large 541.8180 747 -2523.804 5063.609 5100.548
## 8 Limited 878.6001 747 -2451.867 4921.733 4963.290
## 9 Medium 830.8049 747 -2590.861 5199.722 5241.279
## 10 Permanent_burrow 705.4543 747 -2384.355 4788.709 4834.883
## 11 Round/Globulose 1108.9903 747 -3062.156 6142.313 6183.870
## 12 Sedentary 2073.4195 747 -2091.407 4204.813 4255.605
## 13 Simple_hole_or_pit 1268.4554 747 -2414.470 4844.940 4881.879
## 14 Small 990.9262 747 -2992.153 6000.306 6037.246
## 15 Soft-bodied 710.1602 747 -3021.525 6063.051 6109.225
## 16 Surface_to_depth 583.8680 747 -2086.135 4188.270 4225.209
## 17 Surface_to_surface 726.7398 747 -2903.398 5822.795 5859.735
## 18 Suspension 1567.4824 747 -2531.374 5080.748 5122.305
## 19 Top_2_cm 649.1362 747 -2931.071 5878.143 5915.082
## 20 Trough 765.3053 747 -2330.413 4674.826 4707.148
## 21 Tube_structure 1354.9574 747 -1468.206 2952.413 2989.352
## 22 Worm_like 621.0322 747 -2868.830 5755.660 5797.217
## Variables not shown: deviance (dbl), df.residual (int), Rsqr (dbl)
###joint with summary and filter Rsq>0.1###
trait_coef2 <-
right_join(trait_coef1, trait_Summ, by = 'trait') %>%
mutate(Trait = gsub('_', ' ', trait),
term = factor(term),
term = fct_relevel(
term,
'Sediment',
'Metals',
'Nutrients',
'Nutrients x Metals',
'Sediment x Metals' ,
'Sediment x Nutrients'
)
)
##save results###
write.csv(trait_coef2, 'trait_summary.csv', row.names = F)
##coef plot for traits####
trait_plot <-
ggplot(trait_coef2,
aes(
x = estimate,
y = fct_rev(fct_inorder(term)),
color = term
)) +
geom_point() +
geom_errorbarh(aes(
xmin = conf.low,
xmax = conf.high,
height = .2
)) +
facet_wrap(~ Trait) +
geom_vline(xintercept = 0,
lty = 2,
col = 2) +
ylab('') +
xlab('Estimates') +
geom_hline(yintercept = 3.5,
lty = 2,
col = 2) +
scale_color_discrete(guide = F)
###save plot as tiff###
print(trait_plot)

ggsave(
trait_plot,
file = 'trait_plot.tif',
device = 'tiff',
dpi = 900,
compression = 'lzw'
)
## Saving 7 x 5 in image