profile.kalman.ar: Likelihood Profile for a Time-Varying Autoregressive Model

View source: R/kalman.ar.R

profile.kalman.arR Documentation

Likelihood Profile for a Time-Varying Autoregressive Model

Description

Computes the log-likelihood of a kalman.ar model over a range of lambda, keeping the series, order and prior of the fit. It shows how well the data determine lambda and what a value set by hand costs.

Usage

## S3 method for class 'kalman.ar'
profile(fitted, lambda = 10^seq(-14, 0, by = 0.5), ...)

## S3 method for class 'kalman.profile'
plot(x, drop = 20, ylim = NULL,
     xlab = expression(lambda),
     ylab = gettext("Log-likelihood", domain = "R-dplR"), ...)

## S3 method for class 'kalman.profile'
print(x, digits = 4, ...)

Arguments

fitted

an object of class "kalman.ar".

lambda

numeric. Values to try, all above zero.

x

an object of class "kalman.profile".

drop

numeric. The plot shows log-likelihoods within this many units of the highest, and further down only as far as the fit that was profiled. The curve can fall by hundreds at large lambda, which would flatten the part that matters.

ylim

limits of the vertical axis, in place of drop.

xlab, ylab

axis labels.

digits

number of significant digits to print.

...

for plot, arguments passed to plot.default. Otherwise not used.

Details

The model is fitted again at each value of lambda. If the fit had variance = "varying", its variance path is kept as it is and not estimated again. The plot shows the log-likelihood against lambda on a log scale, with a dashed line at the log-likelihood of the ordinary AR model with fixed coefficients and a circle at the fit that was profiled.

A curve that is nearly level over several powers of ten says that the series holds little information about lambda. The maximum likelihood value then deserves little weight, and so does a comparison of AIC with the fixed model. A curve that falls away steeply above some value says that larger values make the one-step predictions clearly worse.

The number of years in which the coefficients are not those of a stationary process is given for each lambda. It usually rises with lambda and is another guide to how far it can be pushed.

Under prior = "rw2" the model at lambda = 0 has coefficients that change along straight lines, and its log-likelihood, loglik.zero, is not that of the fixed model.

Value

An object of class "kalman.profile", a list with elements:

lambda

the values, sorted.

loglik

log-likelihood at each.

n.nonstationary

years with non-stationary coefficients at each.

loglik.zero

log-likelihood at lambda = 0.

loglik.fixed

log-likelihood of the AR model with fixed coefficients.

fit.lambda, fit.loglik, lambda.estimated

from the fit.

order, prior

from the fit.

n.lik

years in the likelihood.

n.yrs

years with coefficients.

Note

This function is experimental and may change in future releases, as may kalman.ar.

Author(s)

Andy Bunn

See Also

kalman.ar, kalman.spec

Examples

ss <- datasets::sunspot.year
fit <- kalman.ar(as.numeric(ss), yrs = as.numeric(time(ss)), order = 30,
            lambda = 1e-3)
pr <- profile(fit)
pr
plot(pr)

dplR documentation built on Dec. 6, 2026, 1:07 a.m.