Unit 23 Strategy + Notation
We normally have: X1,X2,...,Xt0 Our goal is to forecast a future value, say Xt0+4
Typicall t0=n ie it is the last value of the realization. However, sometimes to evaluate our forecast, we compare it to the last few values of the realization.
23.1 Notation
^Xt0(ℓ) is the forecast of Xt0+ℓ given data up to time t0
t0 is called the forecast origin
ℓ is called the lead time, the number of steps ahead which we want to forecast
23.2 some math
Xt−ϕ1Xt−1=(1−ϕ1)μ+at
assume we know ϕ1
we don-t know X11, we dont know mu, and we dont know a12
Iterative forecasting
We assume a in the future is 0, then we have
ar1forcastgen <- function(phi, mu) {
fun <- function(xprev, l = 1) {
if (l == 1)
return(phi * xprev + mu * (1 - phi)) else return(phi * fun(xprev, l - 1) + mu * (1 - phi))
}
fun
}
ex74 <- ar1forcastgen(phi = 0.8, mu = 24.17)
times <- c(1, 2, 3, 4, 5)
lapply(times, ex74, xprev = 22.93) %>% as.data.frame
## X23.178 X23.3764 X23.53512 X23.662096 X23.7636768
## 1 23.178 23.3764 23.53512 23.6621 23.76368
ex74(22.93, l = 2)
## [1] 23.3764