% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ARCHmX.R
\name{ARCHmX}
\alias{ARCHmX}
\title{Fitting an ARCH-m(X) model}
\usage{
ARCHmX(
  eps, 
  X, 
  p, 
  delta=2,
  covariates="all",
  hypothesisTest=TRUE,
  bandwidth = "plugin", 
  k.choice = "plugin"
)
}
\arguments{
\item{eps}{Time series}

\item{X}{Matrix with exogenous covariates where the number of rows is equal to the length of eps and columns represent the covariates.}

\item{p}{Order of the ARCH-m(X) model. Value of p cannot be 0.}

\item{delta}{Value of the power of the main time series for a POWER-GARCH, default is 2.}

\item{covariates}{Instead of slicing X when building partial models, you can specify a vector of column indices. Defaults to "all".}

\item{hypothesisTest}{Whether to perform covariate hypothesis testing, default is TRUE.}

\item{bandwidth}{Choice of bandwidth for the Nadaraya-Watson Kernel regression estimation. Options are "plugin" or "CV". Default is "plugin".}

\item{k.choice}{Choice of window size k for the ANOVA hypotghesis test. Options are "plugin" or "CV". Default is "plugin".}
}
\value{
An object of class ARCHmX
}
\description{
Fits an ARCH-m(X) model with given data and estimates the alphas and the nonparametric function m(X). 
}
\details{
Performs semiparametric estimation of \eqn{\alpha_1,\cdots,\alpha_p} and \eqn{m(X_{t})} for the ARCH-m(X) model \deqn{\epsilon_t=z_t\sigma_t,}
\deqn{\sigma_t^2=\sum_{j=1}^p\alpha_j\epsilon_{t-j}^2+m(\mathbf{X}_{t-1}).}

Under the model, it can be shown that 
\deqn{\mathbb{E}\left[\epsilon_t^2-\sum_{j=1}^p\alpha_j\epsilon_{t-j}^2\right]=m(\mathbf{X}_{t-1}).}

A Nadaraya-Watson kernel is used to estimate \eqn{m(\mathbf{x}_{t-1})} as
\deqn{\hat{m}(\mathbf{x}_{t-1})=\hat{m}(\mathbf{x}_{t-1},\mathbf{\alpha})=\sum_{\ell=p+1}^{T}W_{\ell}(\mathbf{x}_{t-1})\left(\epsilon_\ell^2-\sum_{j=1}^p\alpha_j\epsilon_{\ell-j}^2\right).}

This gives rise to a residual sum of squares
\deqn{\text{RSS}=\sum_{t=p+1}^T\left(\tilde{\epsilon}_{t,0}^2-\sum_{k=1}^p\alpha_k\tilde{\epsilon}_{t,k}^2\right)^2=\|\tilde{\mathbf{Y}}-\tilde{\mathbf{X}}\alpha\|^2}

where
\deqn{\tilde{\epsilon}_{t,k}^2=\epsilon_{t-k}^2-\sum_{\ell=p+1}^TW_\ell(\mathbf{x}_{t-1})\epsilon_{\ell-k}^2.}

Non-negative least squares regression is used to obtain the final estimates of \eqn{\alpha_1,\cdots,\alpha_p}.

No variable selection is done in this function, but an ANOVA-type hypothesis test may be performed for the significance of each covariate. This is enabled by default. 
}
\examples{
# We simulate a time series as in the simulate_ARCHmX example.
set.seed(1)
n <- 2000
alpha <- c(0.01, 0.02, 0.03)
valinit <- 200
X <- matrix(rnorm((n + valinit) * 5), ncol = 5)

m <- function(X) {
  abs(X[, 1])
}

data <- sim.ARCHmX(n = n, alpha = alpha, m = m, X = X, delta = 2, valinit = valinit)

p <- length(alpha)

# Then we fit the model
model <- ARCHmX(eps = data$eps, X = data$X, p=p)

# Model summary shows Covariate 1 significant at the <0.001 level. 
summary(model)
}
