Skip to content

Instantly share code, notes, and snippets.

@BroVic
Created July 12, 2022 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BroVic/7eafc3973aaaf27c3cea77b146a1e30f to your computer and use it in GitHub Desktop.
Save BroVic/7eafc3973aaaf27c3cea77b146a1e30f to your computer and use it in GitHub Desktop.
# Intuition of the MA model based on https://www.youtube.com/watch?v=voryLhxiPzE
dat <- data.frame(f.hat = NA, epsilon = c(-2, 1, 0, 2, 1), f = NA)
mu <- 10
phi <- .5
for (i in seq(nrow(dat))) {
if (i == 1L)
dat$f.hat[i] <- mu
else
dat$f.hat[i] <- mu + phi * dat$epsilon[i - 1]
dat$f[i] <- dat$f.hat[i] + dat$epsilon[i]
}
dat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment