% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/nmfkc.ar.R
\name{nmfkc.ar.degree.cv}
\alias{nmfkc.ar.degree.cv}
\title{Optimize lag order for the autoregressive model}
\usage{
nmfkc.ar.degree.cv(
  Y,
  rank = 1,
  degree = 1:2,
  intercept = TRUE,
  plot = TRUE,
  ...
)
}
\arguments{
\item{Y}{Observation matrix \eqn{Y(P,N)} or a \code{ts} object.}

\item{rank}{Rank of the basis matrix. For backward compatibility,
\code{Q} is accepted via \code{...}.}

\item{degree}{A vector of candidate lag orders to be evaluated.}

\item{intercept}{Logical. If TRUE (default), an intercept is added to the covariate matrix.}

\item{plot}{Logical. If TRUE (default), a plot of the objective function values is drawn.}

\item{...}{Additional arguments passed to \code{nmfkc.cv}.}
}
\value{
A list with components:
\item{degree}{The lag order that minimizes the cross-validation objective function.}
\item{degree.max}{Maximum recommended lag order, computed as \eqn{10 \log_{10}(N)}
following the \code{ar} function in the \pkg{stats} package.}
\item{objfunc}{Objective function values for each candidate lag order.}
}
\description{
\code{nmfkc.ar.degree.cv} selects the optimal lag order for an autoregressive model
by applying cross-validation over candidate degrees.

This function accepts both standard matrices (Variables x Time) and \code{ts} objects
(Time x Variables). \code{ts} objects are automatically transposed internally.
}
\examples{
# Example using ts object directly
d <- AirPassengers

# Selection of degree (using ts object)
# Note: Y is automatically transposed if it is a ts object
nmfkc.ar.degree.cv(Y=d, rank=1, degree=11:14)
}
\seealso{
\code{\link{nmfkc.ar}}, \code{\link{nmfkc.cv}}
}
