% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ar-models.R
\name{ARp}
\alias{ARp}
\title{Autoregressive model of order \emph{p}}
\usage{
ARp(margdist, margarg, acsvalue, actfpara, n, p = NULL, p0 = 0)
}
\arguments{
\item{margdist}{Character. Name of the target marginal distribution
(e.g. \code{"ggamma"}, \code{"paretoII"}). Must have a quantile function
\code{q<margdist>} available.}

\item{margarg}{Named list. Parameters of the marginal distribution passed
to \code{q<margdist>}.}

\item{acsvalue}{Numeric vector. Target autocorrelation structure starting
from lag 0 (i.e. \code{acsvalue[1] = 1}).}

\item{actfpara}{List returned by \code{\link{fitactf}}, containing the
fitted ACTF coefficients in \code{actfpara$actfcoef}.}

\item{n}{Positive integer. Length of the generated time series.}

\item{p}{Positive integer or \code{NULL}. AR model order. When
\code{NULL} (default), the order is chosen automatically as the number of
lags where the transformed ACS exceeds 0.01, capped at 1000.}

\item{p0}{Numeric in \eqn{[0, 1)}. Probability of zero values
(intermittency). Default \code{0}.}
}
\value{
A numeric vector of length \code{n} with the following attributes:
\describe{
\item{margdist}{Target marginal distribution name.}
\item{margarg}{Target marginal distribution parameters.}
\item{acsvalue}{Original (untransformed) target ACS.}
\item{p0}{Probability of zeros.}
\item{ar_coef}{AR(\eqn{p}) coefficients (Yule-Walker solution).}
\item{noise_sd}{Standard deviation of the Gaussian innovations.}
\item{gaussian}{The underlying Gaussian process (length \code{n}).}
\item{transformed_acs}{ACTF-transformed ACS used for the AR model.}
}
}
\description{
Generates a time series from an AR(\eqn{p}) model. The parent Gaussian
process is constructed to match a target autocorrelation structure via the
Yule-Walker equations, then transformed to a target marginal distribution
and optional intermittency (probability of zeros).
}
\seealso{
\code{\link{generateTS}}, \code{\link{actpnts}},
\code{\link{fitactf}}, \code{\link{acs}}
}
\keyword{internal}
