estimate_ar_res: Estimate AR(p) model

View source: R/oos_helpers.R

estimate_ar_resR Documentation

Estimate AR(p) model

Description

Fits an autoregressive model of order p for the horizon-h target and returns the OLS coefficients and residuals.

Usage

estimate_ar_res(y, h, p)

Arguments

y

Numeric vector of the target variable.

h

Positive integer; forecast horizon.

p

Non-negative integer; AR lag order.

Value

A list with components:

a_hat

Coefficient vector (intercept first).

res

Residual vector.

Examples

y <- arima.sim(list(ar = 0.7), n = 200)
ar_fit <- estimate_ar_res(y, h = 1, p = 1)
ar_fit$a_hat


sdim documentation built on July 15, 2026, 1:10 a.m.