cts (version 1.0-21)

car: Fit Continuous Time AR Models to Irregularly Sampled Time Series

Description

Fit a continuous AR model to an irregularly sampled univariate time series with the Kalman filter

Usage

car(x, y=NULL, scale = 1.5, order = 3, ctrl=car_control())
# S3 method for car
print(x, digits = 3, ...)
# S3 method for car
summary(object, ...)
# S3 method for car
plot(x, type=c("spec", "pred", "diag"),...) 
# S3 method for car
predict(object, se.fit = TRUE, digits = 3, plot.it=TRUE,...)
# S3 method for car
spectrum(object, frmult=1, n.freq, plot.it = TRUE, na.action = na.fail, ...)
# S3 method for car
AIC(object, ..., k=NULL)
# S3 method for car
tsdiag(object, gof.lag = 10, ...)
# S3 method for car
kalsmo(object)

Arguments

x

two column data frame or matrix with the first column being the sampled time and the second column being the observations at the first column; otherwise x is a numeric vector of sampled time. It can be a car object for S3 methods

y

not used if x has two columns; otherwise y is a numeric vector of observations at sampled time x.

scale

The kappa value referred to in the paper by Belcher et a. (1994). We now recommend selection of kappa along with the model order by using AIC. Also, it is suggested to choose kappa close to 2pi times 1/mean.delta (reciprocal of the mean time between observations), though it is a good idea to explore somewhat lower and higher values to see whether the spectrum estimates were sensitive to this choice. Choosing kappa lower increases the risk of trying to estimate the spectrum beyond the effective Nyquist frequency of the data - though this does depend on the distribution of intersample times.

order

order of autoregression.

ctrl

control parameters used in predict and numerical optimization.

object

object of class car

type

in plot a character indicating the type of plot. type="spec", call spec; type="pred", call predict; type="diag", call diag

se.fit

Logical: should standard errors of prediction be returned?

digits

return value digits

plot.it

Logical: plot the forecast values?

gof.lag

the maximum number of lags for a Portmanteau goodness-of-fit test

frmult

numerical value, can be used to multiply the frequency range

n.freq

number of frequency

k

penalty, not used

na.action

NA action function.

further arguments to be passed to particular methods

Value

A list of class "car" with the following elements:

n.used

The number of observations used in fitting

order

The order of the fitted model. This is chosen by the user.

np

The number of parameters estimated. This may include the mean and the observation noise ratio.

scale

The kappa value referred to in the paper of Belcher et al.

vri

If vri=1, estimate the observation noise ratio.

vr

The estimated observation noise ratio.

sigma2

The estimated innovation variance.

phi

The estimated reparameterized autoregressive parameters.

x.mean

The estimated mean of the series used in fitting and for use in prediction.

b

All estimated parameters, which include phi, and possibly x.mean and vr.

delb

The estimated standard error of b

essp

The estimated correlation matrix of b

ecov

The estimated covariance matrix of phi. See also AIC

rootr

The real part of roots of phi. See also AIC

rooti

The imaginary part of roots of phi. See also AIC

tim

The numeric vector of sampled time.

ser

The numeric vector of observations at sampled time tim.

filser

The filtered time series with the Kalman filter.

filvar

The estimated variance of Kalman filtered time series filser

sser

The smoothed time series with the Kalman smoother.

svar

The estimated variance of smoothed time series sser

stdred

The standardized residuals from the fitted model.

pretime

Time of predictions.

pred

Predictions for the pretime.

prv

Prediction variance of pred

pre2

Fitted values including pred for all the time series. See also fty.

prv2

Variance of fitted values including prv for all the time series. See also fty.

fty

Forecast type

tnit

Numeric vector: iteration

ss

Numeric vector: sum of squares for each tnit

bit

Matrix with rows for tnit and columns for parameter estimates

aic

AIC value for the fitted model

bic

BIC value for the fitted model

Details

spectrum returns (and by default plots) the spectral density of the fitted model.

tsdiag is a generic diagnostic function for continuous AR model. It will generally plot the residuals, often standadized, the autocorrelation function of the residuals, and the p-values of a Portmanteau test for all lags up to gof.lag. The method for car object plots residuals scaled by the estimate of their (individual) variance, and use the Ljung--Box version of the portmanteau test.

AIC For continuous CAR model selection, t-statistic and AIC are calculated based on reparameterized coefficients phi and covariance matrix ecov. From the t-statistic, the final model is chosen such that if the true model order is less than the large value used for model estimation then for i > order the deviations of the estimated parameters phi from their true value of 0 will be small. From the AIC, the final model is chosen based on the smallest AIC value. A table with t-statistic and AIC for the corresponding model order.

factab calculate characteristic roots and system frequency from the estimated reparameterized coefficients of CAR fits.

smooth computes components corresponding to the diagonal transition matrix with the Kalman smoother. This may not be stable for some data due to numerical inversion of matrix.

References

Belcher, J. and Hampton, J. S. and Tunnicliffe Wilson, G. (1994). Parameterization of continuous time autoregressive models for irregularly sampled time series data. Journal of the Royal Statistical Society, Series B, Methodological,56,141--155

Jones, Richard H. (1981). Fitting a continuous time autoregression to discrete data. Applied Time Series Analysis II, 651--682

Wang, Zhu (2004). The Application of the Kalman Filter to Nonstationary Time Series through Time Deformation. PhD thesis, Southern Methodist University

Wang, Zhu and Woodward, W. A. and Gray, H. L. (2009). The Application of the Kalman Filter to Nonstationary Time Series through Time Deformation. Journal of Time Series Analysis, 30(5), 559-574.

Wang, Zhu (2013). cts: An R Package for Continuous Time Autoregressive Models via Kalman Filter. Journal of Statistical Software, Vol. 53(5), 1--19. http://www.jstatsoft.org/v53/i05

See Also

car_control for predict and numerical optimization parameters, and AIC for model selection

Examples

Run this code
# NOT RUN {
data(V22174)
fit <- car(V22174,scale=0.2,order=7, ctrl=car_control(trace=TRUE))
summary(fit)
spectrum(fit)
tsdiag(fit)
AIC(fit)
factab(fit)
###fitted values vs observed values
ntim <- dim(V22174)[1]
plot(V22174[,1], V22174[,2], type="l")
points(V22174[,1], fit$pre2[1:ntim], col="red")
### alternatively
fit2 <- car(V22174,scale=0.2,order=7, ctrl=car_control(fty=3))
plot(V22174[,1], V22174[,2], type="l")
points(V22174[,1], fit2$pre2, col="red")

data(asth)
fit <- car(asth,scale=0.25,order=4, ctrl=car_control(n.ahead=10))
kalsmo(fit)
# }

Run the code above in your browser using DataCamp Workspace