% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/nmfkc.ar.R
\name{nmfkc.ar}
\alias{nmfkc.ar}
\title{Construct observation and covariate matrices for a vector autoregressive model}
\usage{
nmfkc.ar(Y, degree = 1, intercept = TRUE)
}
\arguments{
\item{Y}{An observation matrix (P x N) or a \code{ts} object.
If \code{Y} is a \code{ts} object (typically N x P), it is automatically transposed to match the (P x N) format.}

\item{degree}{The lag order of the autoregressive model. The default is 1.}

\item{intercept}{Logical. If TRUE (default), an intercept term is added to the covariate matrix.}
}
\value{
A list containing:
\item{Y}{Observation matrix (P x N_A) used for NMF. Includes adjusted \code{"tsp_info"} attribute and time-based column names.}
\item{A}{Covariate matrix (R x N_A) constructed according to the specified lag order. Includes adjusted \code{"tsp_info"} attribute and time-based column names.}
\item{A.columns}{Index matrix used to generate \code{A}.}
\item{degree.max}{Maximum lag order.}
}
\description{
\code{nmfkc.ar} generates the observation matrix and covariate matrix
corresponding to a specified autoregressive lag order.

If the input \code{Y} is a \code{ts} object, its time properties are preserved
in the \code{"tsp_info"} attribute, adjusted for the lag.
Additionally, the column names of \code{Y} and \code{A} are set to the corresponding time points.
}
\examples{
# Example using AirPassengers (ts object)
d <- AirPassengers
ar_data <- nmfkc.ar(d, degree = 2)
dim(ar_data$Y)
dim(ar_data$A)

# Example using matrix input
Y <- matrix(1:20, nrow = 2)
ar_data <- nmfkc.ar(Y, degree = 1)
ar_data$degree.max

}
\references{
Satoh, K. (2025). Applying non-negative matrix factorization with covariates
to multivariate time series data as a vector autoregression model.
\emph{Japanese Journal of Statistics and Data Science}. arXiv:2501.17446.
\doi{10.1007/s42081-025-00314-0}
}
\seealso{
\code{\link{nmfkc}}, \code{\link{nmfkc.ar.degree.cv}}, \code{\link{nmfkc.ar.stationarity}}, \code{\link{nmfkc.ar.DOT}}
}
