Final Project
library(knitr)
library(tidyverse)
library(lmtest)
library(bbmle)
library(MASS)
library(car)
library(pscl)
library(conflicted)
library(lme4)
library(ggplot2)
library(ggthemes)
library(sjPlot)
library(extrafont)
loadfonts(device = "win")
conflict_prefer("select","dplyr")
conflict_prefer("filter","dplyr")
conflict_prefer("summarize", "dplyr")PART 1 – Data selection and cleaning.
Choose a butterfly species to work with. The folder “butterfly club data” includes 100 .csv files, each giving information for a different species. The species are identified by 4-letter codes, which are identified by name in the “butterfly species codes” spreadsheet. You can see photos of the butterflies on the MBC website (https://www.massbutterflies.org/butterfly-info.asp), and also read about many of them on a eBook, Butterflies of Massachusetts (written by MBC member Sharon Stichter: https://www.butterfliesofmassachusetts.net/).
- a) State which butterfly species you are going to
analyze, and briefly (1-2 sentences) explain why.
- I chose Callophrys gryneus, which is colloquially known as the Juniper Hairstreak. I chose this species because it once flourished in all of New England, but is now very localized southern New England. It is now “critically imperilled” in Maine and possibly extirpated in New Hampshire. It’s also my favorite color (olive green).
- a) State which butterfly species you are going to
analyze, and briefly (1-2 sentences) explain why.
Each data file has ~20,000 rows and 6 columns. Each row is a “trip” recorded in the MCB database. The columns are: (1) listlength is the number of species seen on a particular trip; (2) present is a column coding whether that species was seen on each trip (1 = species seen, 0 = species not seen); (3) listyear is the year of the trip; (4) yearday is the day of year on which each trip took place, e.g., Jan 1 is day 1, April 1 is day 91, June 1 is day 152, etc. (5) listplace is the Massachusetts township in which each trip took place; (6) ltqty is the number of individual butterflies of that species seen on that trip.
- b) To do the analyses, you will need to clean the
data in three ways:
- For some reason, the “present” column occasionally includes values greater than 1. For your analysis, you should replace all values > 1 with a 1.
- The database includes some records from years before the club started making regular trips. For this analysis, filter the data to include only records collected between 1992 and 2010.
- The database also includes some records where individual club members reported single interesting butterfly species, without really searching an area. To remove these records, filter your data to include only trips where the listlength is greater than 5 species.
- b) To do the analyses, you will need to clean the
data in three ways:
judu <- read.csv("/Users/emilybreeden/Desktop/BIO 427/Project 3/JUDUlist.csv")
# part b) 1.
judu$present[which(judu$present>1)] <- 1
range(judu$present)## [1] 0 1
## [1] 1992 2010
## [1] 6 84
- c) To analyze whether temperature affects butterfly
phenology (i.e., the days on which a species is present), you need to
merge the data on sightings of your butterfly with temperature data.
Temperature is summarized for each year using cumulative growing degree
days (GDD) from the beginning of the year until June 1. (See https://en.wikipedia.org/wiki/Growing_degree-day or the
Hodgson et al. 2010 and Cayton et al. 2015 papers on Canvas for an
extended description of the relationship between GDD and temperature in
general, and applied to butterfly phenology in particular.)
- Merge the Jan-Jun GDD for each species with the butterfly sightings data for your species. Call the new column “GDD”.
gdd <- read.csv("/Users/emilybreeden/Desktop/BIO 427/Project 3/GDD_MA.csv") %>%
rename(GDD = GDD_JanJun)
judu2 <- judu %>%
rename(year = listyear) %>%
left_join(gdd, by = "year")PART 2 – Analysis of trends, using data on whether species were present on lists.
- a) This analysis will be based on the “present”
column in the dataframe. Select an appropriate probability distribution
for the “present” column. Briefly justify your choice.
- I would choose a binomial probability distribution, because the values in the “present” are presence/absence data and are recorded in 0s and 1s.
- b) Test whether the probability your species is
seen on lists is changing through time using a simple GLM with the
probability distribution chosen in part 2a and
listyearas a continuous predictor variable. Report the line(s) of code used in your analysis, the R output of your code, and the test statistics used to reach your conclusion. Be sure to report both whether the species is increasing or decreasing and whether this change is statistically significant.- The Juniper Hairstreak is significantly increasing in abundance over time. The coefficient for year in my model is positive (0.0414), indicating the increase in abundance.Further, the significance of this effect is seen by the results of my marginal hypothesis test (Chisq = 36.517, df = 1, p = 1.513e-09) and the confidence interval for this coefficient does not intercept 0 (0.0279, 0.0550).
## [1] 0 18
## Analysis of Deviance Table (Type II tests)
##
## Response: present
## LR Chisq Df Pr(>Chisq)
## year_0 36.517 1 1.513e-09 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Call:
## glm(formula = present ~ year_0, family = binomial, data = judu2)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.6773 -0.6286 -0.5717 -0.5092 2.1057
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -2.101639 0.082811 -25.379 < 2e-16 ***
## year_0 0.041443 0.006916 5.992 2.07e-09 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 5676.8 on 6473 degrees of freedom
## Residual deviance: 5640.2 on 6472 degrees of freedom
## AIC: 5644.2
##
## Number of Fisher Scoring iterations: 4
## (Intercept) year_0
## -2.10163864 0.04144344
## Waiting for profiling to be done...
## 2.5 % 97.5 %
## (Intercept) -2.26578843 -1.94110818
## year_0 0.02793025 0.05504662
## Warning in stat_smooth(method = "glm", method.arg = list(family = "binomial"),
## : Ignoring unknown parameters: `method.arg`
## `geom_smooth()` using formula = 'y ~ x'
- c) Repeat the analysis in part 2B using a
mixed-effects GLMM with a random effect of year. Report the same
statistics as in part 2B plus an estimate of the among-year standard
deviation.
- The probability of the Juniper Hairstreak’s change in abundance over time is still significant with the inclusion of year as a random effect, as shown by the results of my marginal hypothesis test (Chisq = 20.204, Df = 1, p = 6.961e-06). Further, the Juniper Hairstreak’s abundance over time is still increasing with the additional random effect, as the coefficient for year_0 is greater than 0 (0.0425) and the confidence interval for this value does not intercept 0 (0.0234, 0.0624). The among-year standard deviation is 0.13571.
## Generalized linear mixed model fit by maximum likelihood (Laplace
## Approximation) [glmerMod]
## Family: binomial ( logit )
## Formula: present ~ year_0 + (1 | year_0)
## Data: judu2
##
## AIC BIC logLik deviance df.resid
## 5641.9 5662.2 -2817.9 5635.9 6471
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -0.5307 -0.4548 -0.4272 -0.3649 2.9650
##
## Random effects:
## Groups Name Variance Std.Dev.
## year_0 (Intercept) 0.01842 0.1357
## Number of obs: 6474, groups: year_0, 19
##
## Fixed effects:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -2.128000 0.109836 -19.374 < 2e-16 ***
## year_0 0.042465 0.009447 4.495 6.96e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## year_0 -0.898
## (Intercept) year_0
## -2.12800040 0.04246465
## Analysis of Deviance Table (Type II Wald chisquare tests)
##
## Response: present
## Chisq Df Pr(>Chisq)
## year_0 20.204 1 6.961e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## Computing profile confidence intervals ...
## 2.5 % 97.5 %
## .sig01 0.03048625 0.25524740
## (Intercept) -2.36199572 -1.91272698
## year_0 0.02337958 0.06244063
## Groups Name Std.Dev.
## year_0 (Intercept) 0.13571
- d) Repeat the analysis in part 2B using a
mixed-effects GLMM with a random effect of township (listplace). Report
the same statistics as in part 2B plus an estimate of the among-site
standard deviation.
- The probability of the Juniper Hairstreak’s change in abundance over
time is still significant with the inclusion of township as a random
effect, as shown by the results of my marginal hypothesis test (Chisq =
38.917, Df = 1, p = 4.422e-10). Further, the Juniper Hairstreak’s
abundance over time is still increasing with the additional random
effect, as the coefficient for
year_0is greater than 0 (0.0561) and the confidence interval of the coefficient does not intercept 0 (0.0385, 0.0738). Thus, the Juniper Hairstreak is still significantly increasing in abundance. The among-site standard deviation is 1.1443.
- The probability of the Juniper Hairstreak’s change in abundance over
time is still significant with the inclusion of township as a random
effect, as shown by the results of my marginal hypothesis test (Chisq =
38.917, Df = 1, p = 4.422e-10). Further, the Juniper Hairstreak’s
abundance over time is still increasing with the additional random
effect, as the coefficient for
m2d <- glmer(present ~ year_0 + (1|listplace), family = binomial, data = judu2, glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 10000)))
summary(m2d)## Generalized linear mixed model fit by maximum likelihood (Laplace
## Approximation) [glmerMod]
## Family: binomial ( logit )
## Formula: present ~ year_0 + (1 | listplace)
## Data: judu2
## Control: glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 10000))
##
## AIC BIC logLik deviance df.resid
## 5162.6 5182.9 -2578.3 5156.6 6466
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.5126 -0.4351 -0.3287 -0.1948 7.5280
##
## Random effects:
## Groups Name Variance Std.Dev.
## listplace (Intercept) 1.309 1.144
## Number of obs: 6469, groups: listplace, 240
##
## Fixed effects:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -2.593142 0.148196 -17.498 < 2e-16 ***
## year_0 0.056122 0.008996 6.238 4.42e-10 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## year_0 -0.669
## Analysis of Deviance Table (Type II Wald chisquare tests)
##
## Response: present
## Chisq Df Pr(>Chisq)
## year_0 38.917 1 4.422e-10 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## (Intercept) year_0
## -2.59314217 0.05612229
#confint(m2d)
#Error in zeta(shiftpar, start = opt[seqpar1][-w]) :
#profiling detected new, lower deviance (deviance diff = 0.00366, tolerance = 1e-09)
#confint(m2d, devtol = Inf)
#Error in approxfun(obj1[, 2], obj1[, 1]) :
#need at least two non-NA values to interpolate
confint.merMod(m2d, method = "Wald")## 2.5 % 97.5 %
## .sig01 NA NA
## (Intercept) -2.88360090 -2.30268345
## year_0 0.03848983 0.07375475
## Groups Name Std.Dev.
## listplace (Intercept) 1.1443
- e) For your species, is variation larger among
sites or among years? Briefly, explain your answer (i.e., say “years
because ….”, not just “years”).
- Variation is larger among site, because in a model with both year and township as random effects, the Juniper Hairstreak’s presence had a higher among-site standard deviation (1.14574), than among-year standard deviation (0.13947).
m2e <- glmer(present ~ year_0 + (1|year_0) + (1|listplace), family = binomial, data = judu2)
VarCorr(m2e)## Groups Name Std.Dev.
## listplace (Intercept) 1.14574
## year_0 (Intercept) 0.13947
- f) In previous analyses published with these data,
they included the number of species seen on each trip as a second
covariate of species presence. The idea here is that the number of
species seen overall acts as a measure of how good the conditions were
on each day (butterflies like warm sunny weather) and how carefully the
participants looked on each trip. Repeat the analysis in part 2B, adding
listlength as a second fixed effect (i.e., a second predictor variable).
Report the same statistics as in part 2B plus the slope coefficient for
list length.
- With
listlengthas an added parameter, my species is still increasing in abundance over time as the coefficient foryear_0is greater than 0 (0.0407) and has a confidence interval that does not intercept 0 (0.0272, 0.0544). Further, it is increasing in abundance as the number of species counted on a given day increases as the coefficient forlistlengthis greater than 0 (0.00906) and has a confidence interval that does not intercept 0 (0.000864, 0.0170). Based on the results of a marginal hypothesis test, both of these effects are significant (year_0: Chisq = 35.149, Df = 1, p = 3.083e-09) (listlength: Chisq = 4.678, Df = 1, p = 0.03055).
- With
##
## Call:
## glm(formula = present ~ year_0 + listlength, family = binomial,
## data = judu2)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.8759 -0.6222 -0.5656 -0.5058 2.1244
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -2.209232 0.096587 -22.873 < 2e-16 ***
## year_0 0.040736 0.006927 5.881 4.07e-09 ***
## listlength 0.009059 0.004116 2.201 0.0277 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 5676.8 on 6473 degrees of freedom
## Residual deviance: 5635.6 on 6471 degrees of freedom
## AIC: 5641.6
##
## Number of Fisher Scoring iterations: 4
## Analysis of Deviance Table (Type II tests)
##
## Response: present
## LR Chisq Df Pr(>Chisq)
## year_0 35.159 1 3.038e-09 ***
## listlength 4.678 1 0.03055 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## (Intercept) year_0 listlength
## -2.20923174 0.04073601 0.00905947
## Waiting for profiling to be done...
## 2.5 % 97.5 %
## (Intercept) -2.3999471865 -2.02123554
## year_0 0.0272021872 0.05435891
## listlength 0.0008638022 0.01701316
- g) Which of the four (or five) models fit above is
best for these data? Justify your answer using statistics.
- Based on their AIC values, the model with just
listlengthas a random effect is equally as good as the model with bothlistlengthandyear_0as random effects. These two models had a dAIC of 1.3. Further, when using a likelihood ratio test between these two models, there was not a significant enough difference between the log-likelihood of the two models to pick one model.
- Based on their AIC values, the model with just
## AIC dAIC df weight
## m2e 5161.3 0.0 4 0.66
## m2d 5162.6 1.3 3 0.34
## m2f 5641.6 480.3 3 <0.001
## m2c 5641.9 480.6 3 <0.001
## m2b 5644.2 482.9 2 <0.001
## Likelihood ratio test
##
## Model 1: present ~ year_0 + (1 | year_0) + (1 | listplace)
## Model 2: present ~ year_0 + (1 | listplace)
## #Df LogLik Df Chisq Pr(>Chisq)
## 1 4 -2576.7
## 2 3 -2578.3 -1 3.2935 0.06955 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
- h) Of course, it is possible to include any
combination of the two random effects and list length. Which set do you
think is best for your data? Briefly, justify your choice. Run this
model. Show the R code you used, and report the relevant output (i.e.,
the coefficients and test statistics).
- Based off of the models run, the model that best fits this data is
the mixed binomial model (m2h.1) with both
year_0andlistlengthas fixed effects, and bothlistplaceandyear_0as random effects as it had the lowest AIC (5162.8). The mixed binomial model (m2h.3) with justlistplaceas a random effect was relatively close in fitness with an AIC of 5164.1 (dAIC = 1.3). However, given that this model failed to converge and still has a higher AIC, I believe modelm2h.1is the best model. Further, with the inclusion of the random effects of bothyear_0andlistplace, the fixed effectlistlengthno longer has a significant effect (Chisq = 0.5329, Df = 1, p = 0.4654).year_0has a postive effect on presence as it has a coefficient of 0.0590 (0.0367, 0.0814). Whilelistlengthhas a positive coefficient of 0.00358, it’s confidence interval overlaps with 0 (-0.00603, 0.0132), thus reaffirming that it is not significant.
- Based off of the models run, the model that best fits this data is
the mixed binomial model (m2h.1) with both
m2h.1 <- glmer(present ~ year_0 + listlength + (1|listplace) + (1|year_0), family = binomial, data = judu2, glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 10000)))
m2h.2 <- glmer(present ~ year_0 + listlength + (1|year_0), family = binomial, data = judu2)
m2h.3 <- glmer(present ~ year_0 + listlength + (1|listplace), family = binomial, data = judu2, glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e7)))## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 0.133548 (tol = 0.002, component 1)
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, : Model is nearly unidentifiable: very large eigenvalue
## - Rescale variables?
m2h.4 <- glm(present ~ year_0 + listlength, family = binomial, data = judu2)
ICtab(m2h.1, m2h.2, m2h.3, m2h.4, base = T, weights = T)## AIC dAIC df weight
## m2h.1 5162.8 0.0 5 0.65
## m2h.3 5164.1 1.3 4 0.35
## m2h.2 5638.9 476.1 4 <0.001
## m2h.4 5641.6 478.8 3 <0.001
## Analysis of Deviance Table (Type II Wald chisquare tests)
##
## Response: present
## Chisq Df Pr(>Chisq)
## year_0 26.8665 1 2.18e-07 ***
## listlength 0.5329 1 0.4654
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## (Intercept) year_0 listlength
## -2.681774364 0.059037137 0.003581662
#confint(m2h.1)
#Error in zeta(shiftpar, start = opt[seqpar1][-w]) :
#profiling detected new, lower deviance (deviance diff = 0.00647, tolerance = 1e-09)
confint.merMod(m2h.1, method = "Wald")## 2.5 % 97.5 %
## .sig01 NA NA
## .sig02 NA NA
## (Intercept) -3.036118601 -2.32743013
## year_0 0.036713355 0.08136092
## listlength -0.006034678 0.01319800
PART 3 – Analysis of the number of individuals seen on each trip.
- a) For this analysis, you will use the “ltqty”
column of the data, i.e., the number of individuals of your species seen
on each trip. Choose and briefly justify a probability distribution for
these data.
- The data for the
ltqtycolumn is discrete and numerical, so I will run a Poisson model. However, the mean and variance are not equal (i.e., the data are overdispersed). Therefore, I will also run a negative binomial to attempt to account for the overdispersion. For fun, I will also run a negative binomial model.- Based on the results of the AIC, the negative binomial is the best fit for the data (by a long shot). Therefore, I will use it for my analysis.
- The data for the
## [1] 0.9643188
## [1] 21.52429
- b) Analyze trends in abundance of your species
through time using lqty as the response variable and year as a
continuous predictor variable. Report the lines of code used to run your
analysis, the slope coefficient(s) for the effect of year, and relevant
test statistics for deciding whether the abundance is changing through
time.
- Based on the results of my negative binomial model, the Juniper
Hairstreak is increasing in abundance over time.
year_0has a positive coefficient (0.0525) and a confidence interval that does not intercept 0 (0.0323, 0.0727). This, in conjunction with the results of the marginal hypothesis test (Chisq = 26.022, Df = 1, p = 3.375e-07), show that the effects ofyear_0are both positive and significant.
- Based on the results of my negative binomial model, the Juniper
Hairstreak is increasing in abundance over time.
m3b <- glm(ltqty ~ year_0, family = poisson, data = judu2)
m3b.1 <- glm.nb(ltqty ~ year_0, data = judu2)
m3b.2 <- glm(ltqty ~ year_0, data = judu2)
ICtab(m3b, m3b.1, m3b.2, base = T)## AIC dAIC df
## m3b.1 10923.8 0.0 3
## m3b 34489.2 23565.3 2
## m3b.2 38228.5 27304.7 3
## (Intercept) year_0
## -0.60683258 0.05250531
## Waiting for profiling to be done...
## 2.5 % 97.5 %
## (Intercept) -0.83378723 -0.37250662
## year_0 0.03236747 0.07266623
## Analysis of Deviance Table (Type II tests)
##
## Response: ltqty
## LR Chisq Df Pr(>Chisq)
## year_0 26.022 1 3.375e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## `geom_smooth()` using formula = 'y ~ x'
- c) Both species presence and the number seen are
metrics of abundance. Did you reach the same conclusion by analyzing
presence and number seen? If not, which analysis do you think gives a
better answer? Decide whether your species is significantly increasing,
significantly decreasing or not changing in abundance, and briefly
explain how your statistical models relate to your conclusion.
- I reached the same conclusions when analyzing presence and number
seen. The results of the model for presence showed that the Juniper
Hairstreak population was increasing over time. Further, the results of
the model for number seen (
ltqty) also showed that the Juniper Hairstreak was increasing over time. The effect/coefficient ofyear_0in both models was not only positive, but also statistically significant as the confidence intervals for these coefficients did not intercept 0. Further, both of these predictors had p-values less than 0.05. Therefore, the Juniper Hairstreak is significantly increasing over time.
- I reached the same conclusions when analyzing presence and number
seen. The results of the model for presence showed that the Juniper
Hairstreak population was increasing over time. Further, the results of
the model for number seen (
PART 4 – Analysis of phenology (sighting dates)
- a) For this analysis, you will use only trips on
which the species was seen. Create a new data frame by filtering your
data to include only trips with present = 1. Report the line of code
used to create this new data frame, and the number of trips on which
your species was seen (i.e., the number of rows in your data frame).
Turn in this second data frame with your data.
- The number of trips on which my species was seen was 1031.
## [1] 1 1
## [1] 1031
- b) Choose a probability distribution for sighting
dates, i.e., the yearday column. Briefly, justify your choice.
- I would use a poisson distribution, because the data for the
yeardaycolumn is discrete quantitative data. However, the mean of theyeardaycolumn does not equal it’s variance indicating these data are overdispersed. Therefore, I will also run a negative binomial model and test which one is better using AIC. For fun, I will also run a model with a normal distribution.- Based on the AIC comparison done in 4c, the negative binomial model was a better fit for the data. Thus, I will use a negative binomial for the rest of my analysis.
- I would use a poisson distribution, because the data for the
## [1] 141.9709
## [1] 211.9331
- c) Test whether the average sighting date is
changing through time using a GLM with the probability distribution
chosen above, and listyear as a continuous predictor variable. Report
the line(s) of code used in your analysis, the R output of your code,
and the test statistics used to reach your conclusion. Be sure to report
both whether the average date is increasing (later phenology) or
decreasing (earlier phenology) and whether this change is statistically
significant.
- Based on the results of my negative binomial model
(
m2c.1), the average sighting date is decreasing over time, which is supported byyear_0’s negative coefficient value (-0.00323). This decrease is statistically significant, as the confidence interval for this coefficient does not intercept 0 (-0.00448, -0.00198).
- Based on the results of my negative binomial model
(
m4c <- glm(yearday ~ year_0, family = poisson, data = judu_present)
m4c.1 <- glm.nb(yearday ~ year_0, data = judu_present)
m4c.2 <- glm(yearday ~ year_0, data = judu_present)
ICtab(m4c, m4c.1, m4c.2, base = T) ## AIC dAIC df
## m4c.1 8419.2 0.0 3
## m4c.2 8427.7 8.5 3
## m4c 8498.9 79.7 2
## (Intercept) year_0
## 4.99126767 -0.00323073
## Waiting for profiling to be done...
## 2.5 % 97.5 %
## (Intercept) 4.976191642 5.006329236
## year_0 -0.004478294 -0.001982971
## `geom_smooth()` using formula = 'y ~ x'
- d) Test whether the average sighting date depends
on spring temperatures using a GLM with the probability distribution
chosen above, and GDD as a continuous predictor variable. Report the
line(s) of code used in your analysis, the R output of your code, and
the test statistics used to reach your conclusion. Be sure to report
both whether the average date is higher (later phenology) or lower
(earlier phenology) in years with higher GDD, and whether this change is
statistically significant.
- Based on the results of my negative binomial model
(
m4d), the average sighting dates are decreasing as GDD is increasing, as the variableGDDhas a negative coefficient value (-0.000678). The effects of this variable are significant, as the confidence interval for the coefficient does not intercept 0 (-0.000829, -0.000528) and the results of the marginal hypothesis test support this conclusion (Chisq = 78.141, Df = 1, p = 2.2e-16).
- Based on the results of my negative binomial model
(
## Analysis of Deviance Table (Type II tests)
##
## Response: yearday
## LR Chisq Df Pr(>Chisq)
## GDD 78.141 1 < 2.2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## (Intercept) GDD
## 5.0994123439 -0.0006785231
## Waiting for profiling to be done...
## 2.5 % 97.5 %
## (Intercept) 5.0669671891 5.131857717
## GDD -0.0008291785 -0.000527947
## `geom_smooth()` using formula = 'y ~ x'
- e) Not surprisingly, the climate is generally
getting warmer through time. Is variation in GDD sufficient to explain
trends in phenology, or is something more going on? To evaluate this
possibility, fit a GLM to the yearday data, using both year and GDD as
continuous predictor variables. If year is still statistically
significant even after accounting for GDD in each year, there may be
something more going on. Report the lines of R code you used to run this
model, the relevant test statistics, and your conclusions.
- Variation in GDD is not sufficient to explain the later phenology of
the Juniper Hairstreak. Based on the results of a marginal hypothesis
test for the model with both
year_0andGDDas predictors, both of the predictors are significant. The results foryear_0are as follows: Chisq = 5.479, Df = 1, p = 0.01924. The results forGDDare as follows: Chisq = 56.863, Df = 1, p = 4.674e-14. Thus, whileGDDhas a lower p-value, the p-value foryear_0is still below the 0.05 cut off. Therefore, both variables are signficant predictors and more variables are contributing to phenology trends then justGDD.
- Variation in GDD is not sufficient to explain the later phenology of
the Juniper Hairstreak. Based on the results of a marginal hypothesis
test for the model with both
## Analysis of Deviance Table (Type II tests)
##
## Response: yearday
## LR Chisq Df Pr(>Chisq)
## year_0 5.479 1 0.01924 *
## GDD 56.863 1 4.674e-14 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## AIC dAIC df
## m4e 8365.9 0.0 4
## m4d 8369.3 3.5 3
## m4c.1 8419.2 53.4 3
PART 5 – conclusions
- Briefly, summarize what you have learned about your butterfly
species from these analyses. You can include 1-2 sentences about the
basic biology if you like. Be sure to include 2-4 sentences about your
conclusions based on the statistical models.
- The Juniper Hairstreak (Callophrys gryneus) is increasing in abundance over time. Most of the variation of presence over time is accounted for by the location being surveyed, rather than the year during which surverying occurred. This makes sense as the Juniper Hairstreak’s host plant, the Easter Red Cedar (Juniperus virginiana), is found in high concentration in the coastal regions of Massachusetts and sparsely in the rest of the state. However, the population has begun to emerge earlier in the year over time. This is likely due to the warming climate, as most butterfly species use temperature as an indicator of when to end diapause and begin mating. Thus, if the climate is warming earlier and earlier, the butterflies will emerge from diapause earlier and earlier. This is further supported by the population emerging earlier as GDD (Growing Degree Days) increases. However, there are likely other variables impacting the earlier phenology, as GDD does not account for all of the variation in phenology.