Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions lessons/R-time-series-modeling-2/r_tutorial.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ data_ts
* Note that this is not using a moving average like you did when decomposing time-series
* MA models are like AR models in that they use past observations to predict the next step
* But instead of using the values themselves they use the past errors
* So a 1st order MA model looks like this
* So a 1st order MA model looks like this

> `y_t = c + theta_1 * e_t-1 + error_t`
> $y_t = c + \theta_1 e_{t-1} + \epsilon_t$

* So if `theta_1` > 0 then if the observation has greater than the mean at the previous time step it is like to be greater than the mean at the current time step
* So if $\theta_1$ > 0 then if the observation has greater than the mean at the previous time step it is like to be greater than the mean at the current time step
* Positive MA components say that if the previous observation was an outlier then the next observation is expected to be an outlier in the same direction
* This makes sense for NDVI
* Greenness isn't really driven by greenness in the same way a populations abundance is
Expand All @@ -49,7 +49,7 @@ data_ts
* Both AR and MA structures can be present in time-series
* We can combine them in an ARMA model

> `y_t = c + b_1 * y_t-1 + theta_1 * error_t-1 + error_t`
> $y_t = c + b_1 y_{t-1} + \theta_1 \epsilon_{t-1} + \epsilon_t$

### Accounting for trends

Expand All @@ -59,7 +59,7 @@ data_ts
* To take out the trend before model fitting the data is differenced
* Typically by subtracting the previous value

> `y_t' = y_t - y_t-1`
> $y_t' = y_t - y_{t-1}$

* So, if we difference the data we are now modeling the change from time-step to time-step, not the actual values

Expand Down Expand Up @@ -87,7 +87,7 @@ report(arima_model)
* `p` is the AR order, `d` is the degree of differencing, and `q` is the MA order
* So this model is a 3rd order MA model, with no differencing, and no autoregressive terms

> `y_t = c + theta_1 * e_t-1 + theta_2 * e_t-2 + theta_3 * e_t-3 + e_t`
> $y_t = c + \theta_1 \epsilon_{t-1} + \theta_2 \epsilon_{t-2} + \theta_3 \epsilon_{t-3} + \epsilon_t$

* This is also shown in the `Coefficients` table by the `ma1`, `ma2`, and `ma3` terms
* So, if NDVI was above average over the last 3 months we expect it to be above average now
Expand All @@ -99,17 +99,17 @@ report(arima_model)
* The seasonal component is also shown in PDQ notation in the second set of parentheses
* We model season components with lags of the length of a full seasonal cycle
* In this case a full cycle is 1 year
* So the SAR1 part of the model as
* So the SAR1 part of the model is

> `y_t = c + b_12 * y_t-12`
> $y_t = c + b_{12} y_{t-12}$

* The value in the current month is related to the value observed 1 year ago
* This makes a lot of sense for NDVI
* Ecosystems are typically greener during the summer than in the winter
* So a good piece of information is how green the ecosystem was at this time last year
* Our full model would therefore be

> `y_t = c + theta_1 * e_t-1 + theta_2 * e_t-2 + theta_3 * e_t-3 + b_12 * y_t-12 + e_t`
> $y_t = c + \theta_1 e_{t-1} + \theta_2 e_{t-2} + \theta_3 e_{t-3} + b_{12} y_{t-12} + \epsilon_t$

* What does this look like?

Expand Down
10 changes: 5 additions & 5 deletions lessons/R-time-series-modeling/r_tutorial.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ gg_tsdisplay(data_ts, NDVI)
* The data is normally distributed with a fixed mean and variance
* It takes the form

> `y_t = c + e_t, where e_t ~ N(0, sigma)`
> $y_t = c + \epsilon_t$, where $\epsilon_t \sim N(0, \sigma)$

* So each time step in our model is a random draw from a normal distribution with a mean of `c`
* We fit time-series models using the `fable` package
Expand Down Expand Up @@ -155,9 +155,9 @@ gg_tsdisplay(data_ts, NDVI)
* Current value depends on past values
* The simplest version of this type of model is an AR1 model

> *leave room to add y_t-2*
> *leave room to add $y_{t-2}$*

> `y_t = c + b_1 * y_t-1 + e_t, where e_t ~ N(0, sigma)`
> $y_t = c + b_1 y_{t-1} + \epsilon_t$, where $\epsilon_t \sim N(0, \sigma)$

* c is a constant, like the intercept in regression
* b_1 is a coefficient determining how y_t is related to y at a 1 time-step lag, i.e., the previous time step
Expand All @@ -170,9 +170,9 @@ gg_tsdisplay(data_ts, NDVI)

* Since we have also have lag 2 autocorrelation we add a term for two time steps back

> `y_t = c + b1 * y_t-1 + b2 * y_t-2 + e_t, where e_t ~ N(0, sigma)`
> $y_t = c + b_1 y_{t-1} + b_2 y_{t-2} + \epsilon_t$, where $\epsilon_t \sim N(0, \sigma)$

> Instructors note: Actually `y_t = (1 - b1 - b2) * c + b1 * y_t-1 + b2 * y_t-2 + e_t` due to non-zero mean
> Instructors note: Actually $y_t = (1 - b_1 - b_2) c + b_1 y_{t-1} + b_2 y_{t-2} + \epsilon_t$ due to non-zero mean

* This type of model structure is available in `fable`'s `AR()` model
* If we want to specify how many autoregressive terms to include we specify the model as an R formula
Expand Down
2 changes: 1 addition & 1 deletion lessons/uncertainty-dietze-ch-2/instructor_notes.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ order: 4

## Adding sources of uncertainty

* So far we've talked about uncertainty as a single thing: epilson ~ N(0, sigma)
* So far we've talked about uncertainty as a single thing: $\epsilon \sim N(0, \sigma)$
* What are the different sources of uncertainty? ***list on board and discuss what each is as students name them***
* observation error
* parameter uncertainty
Expand Down
2 changes: 1 addition & 1 deletion lessons/uncertainty/instructor_notes.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ order: 4

## Sources of uncertainty

- So far we've talked about uncertainty as a single thing: epilson ~ N(0, sigma)
- So far we've talked about uncertainty as a single thing: $\epsilon \sim N(0, \sigma)$
- Different sources of uncertainty
- process uncertainty
- parameter uncertainty
Expand Down
Loading