% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pmm2_ts_design.R
\name{create_sar_matrix}
\alias{create_sar_matrix}
\title{Create design matrix for seasonal AR model}
\usage{
create_sar_matrix(x, p = 0, P = 1, s = 12, multiplicative = FALSE)
}
\arguments{
\item{x}{Numeric vector (centered time series)}

\item{p}{Non-seasonal AR order (default 0)}

\item{P}{Seasonal AR order (must be positive)}

\item{s}{Seasonal period (e.g., 12 for monthly data)}

\item{multiplicative}{Logical, include multiplicative cross-terms (default FALSE)}
}
\value{
Design matrix with lagged values. Columns are:
\itemize{
\item First p columns: non-seasonal lags \eqn{(y_{t-1}, \dots, y_{t-p})}
\item Next P columns: seasonal lags \eqn{(y_{t-s}, \dots, y_{t-Ps})}
\item If multiplicative = TRUE: additional \eqn{p \times P} columns for cross-terms
}
}
\description{
Constructs a design matrix for Seasonal Autoregressive (SAR) models,
optionally including non-seasonal AR lags and multiplicative cross-terms.
}
\details{
For a SAR(P)_s model:
\deqn{y_t = \Phi_1 y_{t-s} + \dots + \Phi_P y_{t-Ps} + \epsilon_t.}

For an additive AR(p)+SAR(P)_s model:
\deqn{y_t = \phi_1 y_{t-1} + \dots + \phi_p y_{t-p} +
            \Phi_1 y_{t-s} + \dots + \Phi_P y_{t-Ps} + \epsilon_t.}

For a multiplicative AR(p) x SAR(P)_s model (multiplicative = TRUE):
Includes cross-terms such as \eqn{y_{t-1-s}}, \eqn{y_{t-1-2s}}, etc.
}
\examples{
\donttest{
# Simple SAR(1)_12 model
x <- rnorm(120)
X <- create_sar_matrix(x, p = 0, P = 1, s = 12)

# AR(1) + SAR(1)_12 additive model
X <- create_sar_matrix(x, p = 1, P = 1, s = 12)

# AR(1) x SAR(1)_12 multiplicative model
X <- create_sar_matrix(x, p = 1, P = 1, s = 12, multiplicative = TRUE)
}
}
