Assignment
Overview
This assignment covers the material from Time series modeling in R 1, 2, and 3. You will fit the same family of models we fit in the tutorials – white noise, autoregressive, seasonal ARIMA, time-series linear models, and dynamic regression – to a new ecological time series, and evaluate each one the way we did in class.
Work through the parts in order, which will expand the modeling approach gradually fixing problems you diagnose as you go.
Turn in a single R script (or Quarto document) on Canvas that contains your code, generates your plots, and includes written answers as comments (R script) or text block (Quarto document).
Learning Objectives:
- Fit white noise, AR, ARIMA, TSLM, and dynamic regression models to a new dataset
- Use residual to check if a model has captured the structure in a time series
- Interpret model coefficients
Data
We are exploring dissolved oxygen from Lake Barco, the National Ecological Observatory Network (NEON) aquatic site at the Ordway-Swisher Biological Station in Florida.
Dissolved oxygen is controlled by a combination of temperature and algae and serves as a good indicator of lake condition.
The data is monthly and includes three variables:
oxygen– dissolved oxygen concentration (mg/L), our response variabletemperature– water temperature (°C)chla– chlorophyll-a (µg/L), a measure of how much algae is in the water
Where the data come from
The data are NEON sensor measurements, obtained through the NEON Ecological Forecasting Challenge, which is run by the Ecological Forecasting Initiative Research Coordination Network and repackages the raw NEON products into tidy daily “target” files.
Two NEON data products underlie the three columns:
- Temperature at specific depth in surface water (DP1.20264.001) –
temperature - Water quality (DP1.20288.001) –
oxygenandchla
Both are collected at the Lake Barco (BARC) field site.
If you want to see how the daily target file was reduced to the monthly series – or to rebuild it with more recent data – the script is make_barco_timeseries.R.
Thomas RQ, Boettiger C, Carey CC, et al. (2023) The NEON Ecological Forecasting Challenge. Frontiers in Ecology and the Environment 21(3): 112–113. doi:10.1002/fee.2616
Part 1: Look at the data
- Download the Lake Barco limnology data
- Plot the oxygen time series along with its ACF and PACF using
gg_tsdisplay(). - Briefly describe what you see. E.g., Is there a trend? Is there a seasonal signal? At what lags is the autocorrelation strongest?
Part 2: White noise
- Fit a white noise model to
oxygenusingMEAN(). - Report the model with
report(). - Plot the data with the fitted values on top using
augment()andautoplot(). - Plot the residuals with
gg_tsresiduals().
Question: What structure in the data is this model failing to capture and how do you now?
Part 3: Autoregressive models
- Based on the PACF from Part 1, pick the number of autoregressive terms and fit an
AR()model tooxygen. - Report the model.
- Plot the fitted values over the data, and plot the residuals.
Question: Describe how you chose the AR order. Describe how this month’s oxygen relates to last month’s. Compared to the white noise model, what did the AR model improve. What structure is still left in the residuals?
Part 4: Seasonal ARIMA
- Fit an
ARIMA()model tooxygen, lettingfableselect the structure. - Report the model.
- Plot the fitted values over the data, and plot the residuals.
Question: What model structure was selected (How many AR terms, how many MA terms, how much differencing, and what seasonal terms). How did the the residual ACF change compared to the AR model.
Part 5: Adding covariates with TSLM
- Fit a
TSLM()model predictingoxygenfromtemperature. - Report the model.
- Add
chlaas a second predictor and refit. - Plot the fitted values compared to the data, and plot the residuals of the model with both
temperature andchla` as drivers.
Question: Describe the model coefficients including sign and significance. The TSLM() model doesn’t explicitly model seasonality, butit tracks the seasonal ups and downs well. How is it doing that? Are there any issues with the residuals?
Part 6: Dynamic regression
- Fit an
ARIMA()model withtemperatureas an external covariate. - Report the model.
- Fit a second version that also includes
chla. - Compare the two models using the AICc values (lower is better) in their reports and plot the fitted values and residuals for your preferred model.
Question: What error structure did fable choose for the two models? Is the temperature coefficient similar to the one from the TSLM() model? Compare the residuals of this model to the residuals from the TSLM() model in Part 5. What did adding the ARIMA error structure change, and why does it matter for interpreting the coefficients?
Part 7: Wrap-up
Include a short paragraph the answers:
- Which model would you choose to describe how dissolved oxygen behaves in Lake Barco, and why?
- One model suggests that oxygen is seasonal; another suggests why it is seasonal. Which is which, and when might you prefer each one?