% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/simulate_ARCHmX.R
\name{sim.ARCHmX}
\alias{sim.ARCHmX}
\title{Simulating data from an ARCH-m(X) process}
\usage{
sim.ARCHmX(n, 
  alpha, 
  m, 
  X, 
  delta=2, 
  shock.distr = "Normal", 
  valinit=200
)
}
\arguments{
\item{n}{Desired length of simulated time series data}
\item{alpha}{Set of parameters which determines the model's \eqn{p}-step time dependence.}
\item{m}{The function to apply to \eqn{X}. m must accept the matrix \eqn{X} and produce a vector of outputs for every row of \eqn{X}.}
\item{X}{Matrix with exogenous covariates where each row is an observation. Must be compatible with \eqn{m}}
\item{delta}{Value of the power of the main time series for a POWER-GARCH, default is 2}
\item{shock.distr}{The distribution from which the epsilons will be simulated. Default is 'Normal', and must be one of 'Normal', 't5', 't7', or 'Laplace'.}
\item{valinit}{How many cycles the simulation should spend warming up before returning samples. Default is 200}
}
\value{
A vector of simulated \eqn{\epsilon}s corresponding to each observation (row) in \eqn{X}.
}
\description{
Returns a sample ARCH-m(X) time series given \eqn{\alpha}s, data \eqn{X}, and a function \eqn{m(X)} provided by the user. A vector of simulated \eqn{\epsilon}s will be returned for every row in \eqn{X}.
}
\details{
The user's specified \eqn{\alpha}s, \eqn{\delta}, function \eqn{m(X)}, data \eqn{X}, and shock distribution \eqn{Z} partially define an ARCH-m(X) time series
\deqn{
\begin{cases}
    \epsilon_t=z_t\sigma_t\\
    \sigma_t^\delta=\sum_{j=1}^p\alpha_j\epsilon_{t-j}^\delta+m(\mathbf{X}_{t-1})
\end{cases}}
To get the \eqn{\epsilon_t} simulations off the ground, a series of burn-in \eqn{\epsilon}s are generated and used to build each \eqn{\sigma_t^\delta}. From here, the shock distribution is sampled to produce each \eqn{\epsilon_t}. 
}
\examples{
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)

summary(data$eps)
plot(data$eps, type = "l", main = "Simulated ARCH-m(X) series")
}
