📦 Simulate y_t = e_t + 0.8 e_{t-1} e_{t-2}
n <- 5000; theta <- 0.8; e <- rnorm(n + 2)
y <- e[3:(n + 2)] + theta * e[2:(n + 1)] * e[1:n]
round(acf(y, lag.max = 5, plot = FALSE)$acf[2:6], 3) # autocorrelations, lags 1-5
f_nonlin <- theta * e[2:(n + 1)] * e[1:n] # E(y_t | past)
c(R2_linear = 0,
R2_nonlinear = round(1 - mean((y - f_nonlin)^2) / var(y), 3),
theory = round(theta^2 / (1 + theta^2), 3))[1] -0.011 -0.008 -0.001 -0.018 -0.012
R2_linear R2_nonlinear theory
0.000 0.372 0.390


