3 Lab 6: Time Series Analysis
# Load required packages
library(trend) # Includes the Mann-Kendall Trend testing
library(MODISTools) # Allows us to remotely bring in MODIS data
library(daymetr) # Allows us to bring in Daymet data
library(vars) # VAR model package
library(dplyr)
library(ggplot2)
library(gridExtra) # Make grids of ggplots
library(sf)
library(reshape2)
You may use:
- The Baker Woodlot data for NDVI and Daymet I already processed - combined_baker.csv
- The Lake Lansing data from MODIS (you will have to recalculate NDTI as in the tutorial) - Lake_Lansing_SR_MODIS.csv
- Your own data pull from the MODIS or daymet packages
- Something else entirely. You can even analyze your own time series data that is not remotely sensed at all. These are generic time series methods.
3.1 Data Selection and Pre-Processing (25 pts)
Please select complete time series data that has at least two variables from the above. You need two concurrently sampled variables to apply VAR and Granger Causality tests.
Verify that your data are complete for the time series you are choosing (5 pts):
Ensure that your data are in a date format such as by using
as.Date()
. (10 pts):Plot your variables over time. You may use one or multiple plots. (10 pts total [will verify 1st two plots if you have more than two variables you are plotting]). Your x-axis should be a date or year and not just be the index of the rows:
3.2 Linear trend (25 pts)
Choose one focal variable. Conduct a linear trend analysis on the chosen variable in your time series.
Include in your output: 4. A p-value of the trend (5 pts) 5. An effect size of your trend (5 pts) 6. A proper interpretation of your linear trend using the p-value and effect size (10 pts) 7. A plot with the trend ploted on top of your data (5 pts)
3.3 Mann-Kendall trend (25 pts)
Choose one focal variable. Conduct a Mann-Kendall trend analysis on the chosen variable in your time series.
Include in your output: 8. A p-value of the trend (5 pts) 9. The tau value (5 pts) 10. A proper interpretation of your nonparametric trend trend using the p-value and tau value (10 pts) 11. A plot with the a LOESS ploted on top of your data (5 pts)
3.4 VAR and Granger causality (25 pts)
Now two choose variables from your time series to apply a VAR model to and test one direction of causality with.
Identify what variable you hypothesize could be causal for the other variable, and why (5 pts):
First, choose and justify a lag value for your VAR model (e.g., 1, 2, 3 or more time steps) [5 pts]:
Run the VAR model and print the model output (5 pts).
Test for G-causality and print the output for the correct hypothesis from your answer to question 12 above (5 pts).
Interpret the G-causality based on the P-value (5 pts):