Seascape Stats
Data is a data frame off all CTD casts with environmental and acoustic summary statistics.
= readRDS('../data/processed/cast_df_stats.rds') cast.df
The goals of these GLM models are:
- Show the relationship between environment and aggregation characteristics
- Show the differing relationships between environment and aggregation characteristics between the two seascape classifications.
I am showing model results in tables by using the
tab_model
function from the library
sjPlot. The below is a wrapper function. Feel free to
modify it if you think other stats from the GLMs should be
displayed.
# wrapper for showing model results
<- function(fit){
tab_model.wrap tab_model(fit, show.aic = T, show.se=T, show.ci=F)
}
Cluster GLMs
Again not really sure how to to interpret these. But my take was that there is only significant differences between clusters for density and biomass. Is this your take? Matches the plots.
depth ~ temp x cluster
<- glm(swarm_mean_depth ~ temp_mean*cluster, data=cast.df, family=Gamma(link='log'))
fit tab_model.wrap(fit)
 | swarm mean depth | ||
---|---|---|---|
Predictors | Estimates | std. Error | p |
(Intercept) | 2.45 | 2.02 | 0.276 |
temp mean | 1.15 | 0.06 | 0.005 |
cluster [B] | 0.73 | 0.85 | 0.785 |
temp mean * cluster [B] | 1.03 | 0.07 | 0.665 |
Observations | 386 | ||
R2 Nagelkerke | 0.061 | ||
AIC | 3084.635 |
anova(fit)
## Analysis of Deviance Table
##
## Model: Gamma, link: log
##
## Response: swarm_mean_depth
##
## Terms added sequentially (first to last)
##
##
## Df Deviance Resid. Df Resid. Dev
## NULL 385 146.65
## temp_mean 1 4.8412 384 141.80
## cluster 1 2.5797 383 139.22
## temp_mean:cluster 1 0.0740 382 139.15
ggplot(cast.df, aes(temp_mean, swarm_mean_depth, col = cluster)) +
geom_point() +
geom_smooth(method = "glm", method.args = list(family = Gamma(link = "log")))
## `geom_smooth()` using formula 'y ~ x'
coverage ~ temp x cluster
## use Box-Cox transformation for area
<- MASS::boxcox(area_corrected_area_sum ~ temp_mean*cluster, data = cast.df, plotit = FALSE)
bc ## lambda is 0.2222 for these data - close to 1/3 but residuals are a bit closer to Normal
<- bc$x[which.max(bc$y)]
lambda
## sjPlot::tab_model() doesn't like transformations in model calls, so modify the data.frame
<- dplyr::mutate(cast.df,
cast.df transf_area_sum = ((area_corrected_area_sum^lambda - 1)/lambda))
<- glm(transf_area_sum ~ temp_mean*cluster, data=cast.df, family = "gaussian")
fit tab_model.wrap(fit)
 | transf area sum | ||
---|---|---|---|
Predictors | Estimates | std. Error | p |
(Intercept) | -1.05 | 0.73 | 0.146 |
temp mean | -0.12 | 0.04 | 0.005 |
cluster [B] | -2.01 | 1.03 | 0.050 |
temp mean * cluster [B] | 0.13 | 0.06 | 0.038 |
Observations | 386 | ||
R2 | 0.043 | ||
AIC | 630.281 |
ggplot(cast.df, aes(temp_mean, transf_area_sum, col = cluster)) +
geom_point() +
geom_smooth(method = "lm")
## `geom_smooth()` using formula 'y ~ x'
density ~ temp x cluster
<- glm(Sv_mean_mean ~ temp_mean*cluster, data=cast.df, family='gaussian')
fit tab_model.wrap(fit)
 | Sv mean mean | ||
---|---|---|---|
Predictors | Estimates | std. Error | p |
(Intercept) | -20.72 | 6.89 | 0.003 |
temp mean | -1.93 | 0.41 | <0.001 |
cluster [B] | -24.88 | 9.77 | 0.011 |
temp mean * cluster [B] | 1.33 | 0.60 | 0.026 |
Observations | 386 | ||
R2 | 0.093 | ||
AIC | 2367.825 |
ggplot(cast.df, aes(temp_mean, Sv_mean_mean, col = cluster)) + geom_point() + geom_smooth(method = "glm")
## `geom_smooth()` using formula 'y ~ x'
Temperature and Salinity
temp ~ salt
<- glm(temp_mean ~ salt_mean, data=cast.df, family='gaussian')
fit tab_model.wrap(fit)
 | temp mean | ||
---|---|---|---|
Predictors | Estimates | std. Error | p |
(Intercept) | 56.58 | 5.21 | <0.001 |
salt mean | -1.14 | 0.15 | <0.001 |
Observations | 386 | ||
R2 | 0.135 | ||
AIC | 1032.233 |
ggplot(cast.df, aes(salt_mean, temp_mean)) +
geom_point() +
geom_smooth(method = "glm", method.args = list(family='gaussian'))
## `geom_smooth()` using formula 'y ~ x'
temp ~ salt x survey
<- glm(temp_mean ~ salt_mean, data = cast.df, family = gaussian)
fit tab_model.wrap(fit)
 | temp mean | ||
---|---|---|---|
Predictors | Estimates | std. Error | p |
(Intercept) | 56.58 | 5.21 | <0.001 |
salt mean | -1.14 | 0.15 | <0.001 |
Observations | 386 | ||
R2 | 0.135 | ||
AIC | 1032.233 |
summary(fit)
##
## Call:
## glm(formula = temp_mean ~ salt_mean, family = gaussian, data = cast.df)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.54627 -0.46314 -0.02568 0.47946 3.04236
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 56.5820 5.2137 10.853 < 2e-16 ***
## salt_mean -1.1427 0.1477 -7.735 9.22e-14 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.8402562)
##
## Null deviance: 372.93 on 385 degrees of freedom
## Residual deviance: 322.66 on 384 degrees of freedom
## AIC: 1032.2
##
## Number of Fisher Scoring iterations: 2
ggplot(cast.df, aes(salt_mean, temp_mean, col = survey)) +
geom_point() +
geom_smooth(method = "glm")
## `geom_smooth()` using formula 'y ~ x'
Crossshore Gradient
temp ~ crossShoreDistance
<- split(cast.df, cast.df$survey)
df.split for (i in 1:length(df.split)){
message('\n', names(df.split)[i])
<- glm(temp_mean ~ crossShoreDistance, data=df.split[[i]])
fit #print(tab_model.wrap(fit))
print(summary(fit))
}
##
## 2015_S1
##
## Call:
## glm(formula = temp_mean ~ crossShoreDistance, data = df.split[[i]])
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.07877 -0.58608 -0.06332 0.35528 1.58023
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 17.08930 0.18105 94.388 < 2e-16 ***
## crossShoreDistance 0.13760 0.02265 6.076 9.88e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.396428)
##
## Null deviance: 26.925 on 32 degrees of freedom
## Residual deviance: 12.289 on 31 degrees of freedom
## AIC: 67.053
##
## Number of Fisher Scoring iterations: 2
##
## 2016_S1
##
## Call:
## glm(formula = temp_mean ~ crossShoreDistance, data = df.split[[i]])
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.08708 -0.32856 0.00993 0.28729 0.93718
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 16.42650 0.07707 213.133 < 2e-16 ***
## crossShoreDistance 0.09207 0.01052 8.755 7.44e-13 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.1710508)
##
## Null deviance: 25.086 on 71 degrees of freedom
## Residual deviance: 11.974 on 70 degrees of freedom
## AIC: 81.162
##
## Number of Fisher Scoring iterations: 2
##
## 2016_S2
##
## Call:
## glm(formula = temp_mean ~ crossShoreDistance, data = df.split[[i]])
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.93236 -0.28289 -0.07889 0.41275 0.81125
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 15.799954 0.091310 173.037 <2e-16 ***
## crossShoreDistance 0.007271 0.013507 0.538 0.593
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.1881886)
##
## Null deviance: 10.217 on 55 degrees of freedom
## Residual deviance: 10.162 on 54 degrees of freedom
## AIC: 69.347
##
## Number of Fisher Scoring iterations: 2
##
## 2017_S1
##
## Call:
## glm(formula = temp_mean ~ crossShoreDistance, data = df.split[[i]])
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.98229 -0.25324 -0.06302 0.17760 1.57132
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 15.76935 0.12832 122.895 < 2e-16 ***
## crossShoreDistance 0.06895 0.01791 3.851 0.000406 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.2917552)
##
## Null deviance: 16.288 on 42 degrees of freedom
## Residual deviance: 11.962 on 41 degrees of freedom
## AIC: 73.012
##
## Number of Fisher Scoring iterations: 2
##
## 2017_S2
##
## Call:
## glm(formula = temp_mean ~ crossShoreDistance, data = df.split[[i]])
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.9385 -0.2437 0.0125 0.3828 0.6618
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 15.96703 0.09096 175.532 <2e-16 ***
## crossShoreDistance 0.02852 0.01290 2.211 0.0314 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.1764484)
##
## Null deviance: 10.0383 on 53 degrees of freedom
## Residual deviance: 9.1753 on 52 degrees of freedom
## AIC: 63.532
##
## Number of Fisher Scoring iterations: 2
##
## 2018_S1
##
## Call:
## glm(formula = temp_mean ~ crossShoreDistance, data = df.split[[i]])
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.19658 -0.18239 0.03863 0.27564 0.93848
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 15.273260 0.110813 137.829 <2e-16 ***
## crossShoreDistance 0.008503 0.015627 0.544 0.59
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.1654624)
##
## Null deviance: 5.1783 on 32 degrees of freedom
## Residual deviance: 5.1293 on 31 degrees of freedom
## AIC: 38.219
##
## Number of Fisher Scoring iterations: 2
##
## 2018_S2
##
## Call:
## glm(formula = temp_mean ~ crossShoreDistance, data = df.split[[i]])
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.08258 -0.71334 0.00757 0.70321 1.12396
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 15.18119 0.21084 72.00 <2e-16 ***
## crossShoreDistance 0.02019 0.02969 0.68 0.502
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.5351738)
##
## Null deviance: 14.697 on 28 degrees of freedom
## Residual deviance: 14.450 on 27 degrees of freedom
## AIC: 68.096
##
## Number of Fisher Scoring iterations: 2
##
## 2019_S1
##
## Call:
## glm(formula = temp_mean ~ crossShoreDistance, data = df.split[[i]])
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.54589 -0.87740 0.06019 0.80505 1.85252
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 14.95819 0.27068 55.26 < 2e-16 ***
## crossShoreDistance 0.14965 0.03817 3.92 0.000455 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.9872792)
##
## Null deviance: 45.780 on 32 degrees of freedom
## Residual deviance: 30.606 on 31 degrees of freedom
## AIC: 97.164
##
## Number of Fisher Scoring iterations: 2
##
## 2019_S2
##
## Call:
## glm(formula = temp_mean ~ crossShoreDistance, data = df.split[[i]])
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.31068 -0.36402 0.00289 0.27367 1.33878
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 16.09525 0.15775 102.032 <2e-16 ***
## crossShoreDistance 0.05359 0.02225 2.409 0.0221 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.3353034)
##
## Null deviance: 12.340 on 32 degrees of freedom
## Residual deviance: 10.394 on 31 degrees of freedom
## AIC: 61.527
##
## Number of Fisher Scoring iterations: 2
ggplot(cast.df, aes(crossShoreDistance, temp_mean)) +
geom_point() +
geom_smooth(method = "glm") +
facet_wrap('survey')
## `geom_smooth()` using formula 'y ~ x'
<br?
coverage ~ crossShoreDistance
<- split(cast.df, cast.df$survey)
df.split for (i in 1:length(df.split)){
message('\n', names(df.split)[i])
<- glm(transf_area_sum ~ crossShoreDistance, data=df.split[[i]])
fit #print(tab_model.wrap(fit))
print(summary(fit))
}
##
## 2015_S1
##
## Call:
## glm(formula = transf_area_sum ~ crossShoreDistance, data = df.split[[i]])
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.92939 -0.34872 -0.01466 0.34912 1.48797
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -3.449090 0.148364 -23.247 <2e-16 ***
## crossShoreDistance 0.005109 0.018557 0.275 0.785
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.2661982)
##
## Null deviance: 8.2723 on 32 degrees of freedom
## Residual deviance: 8.2521 on 31 degrees of freedom
## AIC: 53.911
##
## Number of Fisher Scoring iterations: 2
##
## 2016_S1
##
## Call:
## glm(formula = transf_area_sum ~ crossShoreDistance, data = df.split[[i]])
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.23263 -0.32272 0.00105 0.32841 1.18628
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -3.017598 0.092843 -32.502 <2e-16 ***
## crossShoreDistance -0.002733 0.012668 -0.216 0.83
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.2482193)
##
## Null deviance: 17.387 on 71 degrees of freedom
## Residual deviance: 17.375 on 70 degrees of freedom
## AIC: 107.97
##
## Number of Fisher Scoring iterations: 2
##
## 2016_S2
##
## Call:
## glm(formula = transf_area_sum ~ crossShoreDistance, data = df.split[[i]])
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.05562 -0.32471 -0.01494 0.25733 1.52330
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -3.05230 0.10995 -27.761 <2e-16 ***
## crossShoreDistance 0.03217 0.01626 1.978 0.0531 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.2728636)
##
## Null deviance: 15.802 on 55 degrees of freedom
## Residual deviance: 14.735 on 54 degrees of freedom
## AIC: 90.153
##
## Number of Fisher Scoring iterations: 2
##
## 2017_S1
##
## Call:
## glm(formula = transf_area_sum ~ crossShoreDistance, data = df.split[[i]])
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.97148 -0.38227 -0.04024 0.38510 1.13347
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -3.06508 0.13610 -22.520 <2e-16 ***
## crossShoreDistance -0.02192 0.01899 -1.154 0.255
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.3282464)
##
## Null deviance: 13.895 on 42 degrees of freedom
## Residual deviance: 13.458 on 41 degrees of freedom
## AIC: 78.079
##
## Number of Fisher Scoring iterations: 2
##
## 2017_S2
##
## Call:
## glm(formula = transf_area_sum ~ crossShoreDistance, data = df.split[[i]])
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.81078 -0.38804 0.06741 0.26360 0.98903
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -3.027150 0.098305 -30.794 <2e-16 ***
## crossShoreDistance -0.009255 0.013939 -0.664 0.51
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.2060766)
##
## Null deviance: 10.807 on 53 degrees of freedom
## Residual deviance: 10.716 on 52 degrees of freedom
## AIC: 71.914
##
## Number of Fisher Scoring iterations: 2
##
## 2018_S1
##
## Call:
## glm(formula = transf_area_sum ~ crossShoreDistance, data = df.split[[i]])
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.3107 -0.2820 0.1477 0.3245 0.7379
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -2.692090 0.138309 -19.464 <2e-16 ***
## crossShoreDistance -0.006397 0.019505 -0.328 0.745
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.2577605)
##
## Null deviance: 8.0183 on 32 degrees of freedom
## Residual deviance: 7.9906 on 31 degrees of freedom
## AIC: 52.848
##
## Number of Fisher Scoring iterations: 2
##
## 2018_S2
##
## Call:
## glm(formula = transf_area_sum ~ crossShoreDistance, data = df.split[[i]])
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.85044 -0.18479 0.07493 0.25750 0.52566
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -2.416415 0.110470 -21.874 <2e-16 ***
## crossShoreDistance -0.002305 0.015556 -0.148 0.883
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.1469135)
##
## Null deviance: 3.9699 on 28 degrees of freedom
## Residual deviance: 3.9667 on 27 degrees of freedom
## AIC: 30.607
##
## Number of Fisher Scoring iterations: 2
##
## 2019_S1
##
## Call:
## glm(formula = transf_area_sum ~ crossShoreDistance, data = df.split[[i]])
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.94351 -0.29033 0.01446 0.28482 0.86312
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -3.36498 0.13089 -25.708 < 2e-16 ***
## crossShoreDistance 0.08891 0.01846 4.817 3.63e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.2308488)
##
## Null deviance: 12.5128 on 32 degrees of freedom
## Residual deviance: 7.1563 on 31 degrees of freedom
## AIC: 49.209
##
## Number of Fisher Scoring iterations: 2
##
## 2019_S2
##
## Call:
## glm(formula = transf_area_sum ~ crossShoreDistance, data = df.split[[i]])
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.75516 -0.25987 0.03786 0.32738 0.83785
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -3.14945 0.10554 -29.840 < 2e-16 ***
## crossShoreDistance 0.04845 0.01488 3.255 0.00274 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.1501016)
##
## Null deviance: 6.2434 on 32 degrees of freedom
## Residual deviance: 4.6531 on 31 degrees of freedom
## AIC: 35.004
##
## Number of Fisher Scoring iterations: 2
ggplot(cast.df, aes(crossShoreDistance, transf_area_sum)) +
geom_point() +
geom_smooth(method = "glm") +
facet_wrap('survey')
## `geom_smooth()` using formula 'y ~ x'