The AR-1 Autoregressive Process
AR1UC.RdDensity for the AR-1 model.
Usage
dAR1(x, drift = 0, var.error = 1, ARcoef1 = 0.0,
type.likelihood = c("exact", "conditional"), log = FALSE)Arguments
- x,
vector of quantiles.
- drift
the scaled mean (also known as the drift parameter), \(\mu^*\). Note that the mean is \(\mu^* /(1-\rho)\). The default corresponds to observations that have mean 0.
- log
Logical. If
TRUEthen the logarithm of the density is returned.- type.likelihood, var.error, ARcoef1
See
AR1. The argumentARcoef1is \(\rho\). The argumentvar.erroris the variance of the i.i.d. random noise, i.e., \(\sigma^2\). Iftype.likelihood = "conditional"then the first element or row of the result is currently assignedNA—this is because the density of the first observation is effectively ignored.
Details
Most of the background to this function is given
in AR1.
All the arguments are converted into matrices, and then
all their dimensions are obtained. They are then coerced
into the same size: the number of rows is the maximum
of all the single rows, and ditto for the number of columns.
See also
AR1.
Examples
if (FALSE) { # \dontrun{
nn <- 100; set.seed(1)
tdata <- data.frame(index = 1:nn,
TS1 = arima.sim(nn, model = list(ar = -0.50),
sd = exp(1)))
fit1 <- vglm(TS1 ~ 1, AR1, data = tdata, trace = TRUE)
rhobitlink(-0.5)
coef(fit1, matrix = TRUE)
(Cfit1 <- Coef(fit1))
summary(fit1) # SEs are useful to know
logLik(fit1)
sum(dAR1(depvar(fit1), drift = Cfit1[1], var.error = (Cfit1[2])^2,
ARcoef1 = Cfit1[3], log = TRUE))
fit2 <- vglm(TS1 ~ 1, AR1(type.likelihood = "cond"), data = tdata, trace = TRUE)
(Cfit2 <- Coef(fit2)) # Okay for intercept-only models
logLik(fit2)
head(keep <- dAR1(depvar(fit2), drift = Cfit2[1], var.error = (Cfit2[2])^2,
ARcoef1 = Cfit2[3], type.likelihood = "cond", log = TRUE))
sum(keep[-1])
} # }