AR1UC: The AR-1 Autoregressive Process

dAR1R Documentation

The AR-1 Autoregressive Process

Description

Density 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 TRUE then the logarithm of the density is returned.

type.likelihood, var.error, ARcoef1

See AR1. The argument ARcoef1 is \rho. The argument var.error is the variance of the i.i.d. random noise, i.e., \sigma^2. If type.likelihood = "conditional" then the first element or row of the result is currently assigned NA—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.

Value

dAR1 gives the density.

Author(s)

T. W. Yee and Victor Miranda

See Also

AR1.

Examples

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])

VGAM documentation built on Sept. 19, 2023, 9:06 a.m.