% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/forecastADAPT.R
\name{forAD}
\alias{forAD}
\title{Computing adaptive forecast}
\usage{
forAD(x, p_max = 3, T0 = 50, n_v = 100, n_AR = 400,
      plots = TRUE, P = 50, PL = 500, p = 1, date_1 = NULL)
}
\arguments{
\item{x}{A univariate numeric time series (\code{ts}, \code{xts}, \code{zoo}) object or a numeric vector or a numeric data frame column.}

\item{p_max}{Maximum order of the AR model. Default is \code{3}. If set to \code{0}, no AR is estimated.}

\item{T0}{Length of the training period used to select tuning parameter \eqn{\rho}. Default is \code{50}.}

\item{n_v}{Length of the period of forecast errors used in calculation of MSFE. Default is \code{100}.}

\item{n_AR}{Length of the period of forecast errors used for estimation of AR and for computing correlograms. Default is \code{400}.}

\item{plots}{Logical. If \code{TRUE} (default), the following plots are produced: \cr 1) Rolling MSFEs (adapt, adapt+AR(\eqn{p}), adapt\eqn{^2}, adapt\eqn{^2}+AR(\eqn{p}), \eqn{p=1,...,p_{max}}), \cr 2) Rolling tuning parameters \eqn{\rho} (adapt, adapt\eqn{^2}), \cr 3) Rolling one-step ahead forecasts (adapt, adapt+AR(\eqn{p}), adapt\eqn{^2}, adapt\eqn{^2}+AR(\eqn{p}) for selected \eqn{p}) and the data, \cr 4) Rolling forecast errors (adapt, adapt+AR(\eqn{p}), adapt\eqn{^2}, adapt\eqn{^2}+AR(\eqn{p}) for selected \eqn{p}), \cr 5) Correlograms of the forecast errors. \cr Alternatively, \code{plots} can be a logical vector specifying which plots, 1)--5), to display.}

\item{P}{Length of the period used in plots. Default is \code{50}.}

\item{PL}{Length of the longer period used in plots. Default is \code{500}.}

\item{p}{Selected AR order used in plots. Default is \code{1}.}

\item{date_1}{The date for the one-step ahead forecast when \code{x} has dates. Default is \code{NULL}.}
}
\value{
An object of class '\code{forAD}', which is a list with the following components:
\item{for_1}{The one-step ahead forecast for all methods (adapt, adapt+AR(\eqn{p}), adapt\eqn{^2}, adapt\eqn{^2}+AR(\eqn{p}), \eqn{p=1,...,p_{max}}).}
\item{rho}{The tuning parameter for adaptive methods (adapt, adapt\eqn{^2}).}
\item{ar_coef_se}{The estimated coefficients and their standard errors for the adapt+AR(\eqn{p}), \eqn{p=1,...,p_{max}}.}
\item{ar_coef_se_sq}{The estimated coefficients and their standard errors for the adapt\eqn{^2}+AR(\eqn{p}), \eqn{p=1,...,p_{max}}.}
\item{MSFE}{The MSFE for all methods.}
\item{for_in}{The rolling one-step ahead forecasts for all methods.}
\item{rho_in}{The rolling tuning parameters for adaptive methods.}
\item{MSFE_in}{The rolling MSFE for all methods.}
\item{err_in}{The rolling one-step ahead forecast errors for all methods.}
\item{data}{The original data.}
}
\description{
The functions forAD computes the adaptive one-step ahead forecast of Giraitis, Kapetanios and Price (2013).
}
\details{
The method implements the adaptive (one-stage adapt or two-stage adapt\eqn{^2}) one-step ahead forecasting with weights \eqn{w_{j,\rho}\propto\rho^j}{w[j,rho] \propto rho^j} for \eqn{0<\rho\leq 1} (normalized to sum up to 1) in the 1st step, combined with AR forecasting in 2nd step.
}
\note{
Missing values are not allowed. \cr Permitted sample size: \eqn{N\geq25+2p_{max}} when \code{p_max > 0} and \eqn{N\geq21} when \code{p_max = 0}.
}
\examples{
# Sample x contains 200 independent standard normal data.
x <- rnorm(200)
print(forAD(x, plots = FALSE))
# Set plots to TRUE to see the plots.
\donttest{print(forAD(x))}
}
\references{
Giraitis L, Kapetanios G, Price S (2013). "Adaptive Forecasting in the Presence of Recent and Ongoing Structural Change." Journal of Econometrics, 177(2), 153-170. \doi{doi:10.1016/j.jeconom.2013.04.003}. \cr
Giraitis L, Kapetanios G, Mansur M, Price S (2015). "Forecasting Under Structural Change." In J Beran, Y Feng, H Hebbel (eds.), Empirical Economic and Financial Research: Theory, Methods and Practice, pp. 401–419. Springer International Publishing, Cham. \doi{doi:10.1007/978-3-319-03122-4_25}.
}
\author{
Violetta Dalla, Liudas Giraitis and George Kapetanios
}
