The cts Package. June 23, 2006

Similar documents
Package lomb. February 20, 2015

cts: An R Package for Continuous Time Autoregressive Models via Kalman Filter

Package msir. R topics documented: April 7, Type Package Version Date Title Model-Based Sliced Inverse Regression

The Application of the Kalman Filter to. Nonstationary Time Series through Time. Deformation

DATA IN SERIES AND TIME I. Several different techniques depending on data and what one wants to do

Package TSPred. April 5, 2017

TIME SERIES ANALYSIS. Forecasting and Control. Wiley. Fifth Edition GWILYM M. JENKINS GEORGE E. P. BOX GREGORY C. REINSEL GRETA M.

Package tspi. August 7, 2017

Package TideHarmonics

Package NonpModelCheck

Elements of Multivariate Time Series Analysis

Package gma. September 19, 2017

Dynamic Time Series Regression: A Panacea for Spurious Correlations

lightcurve Data Processing program v1.0

Figure 18: Top row: example of a purely continuous spectrum (left) and one realization

ARIMA Modelling and Forecasting

Time Series: Theory and Methods

Package leiv. R topics documented: February 20, Version Type Package

Package ARCensReg. September 11, 2016

The ICS Package. May 4, 2007

Analysis of Violent Crime in Los Angeles County

Applied Time. Series Analysis. Wayne A. Woodward. Henry L. Gray. Alan C. Elliott. Dallas, Texas, USA

A test for improved forecasting performance at higher lead times

Module 29.3: nag tsa spectral Time Series Spectral Analysis. Contents

Chapter 3: Regression Methods for Trends

5 Autoregressive-Moving-Average Modeling

Time Series Analysis. James D. Hamilton PRINCETON UNIVERSITY PRESS PRINCETON, NEW JERSEY

Package peacots. November 13, 2016

Package FGN. October 18, 2007

at least 50 and preferably 100 observations should be available to build a proper model

The betareg Package. October 6, 2006

Package Rarity. December 23, 2016

Package ForwardSearch

Ch 8. MODEL DIAGNOSTICS. Time Series Analysis

M. H. Gonçalves 1 M. S. Cabral 2 A. Azzalini 3

The evdbayes Package

Computational Data Analysis!

Use of the Autocorrelation Function for Frequency Stability Analysis

INTRODUCTION TO TIME SERIES ANALYSIS. The Simple Moving Average Model

Package ChIPtest. July 20, 2016

A Course in Time Series Analysis

Package AID. R topics documented: November 10, Type Package Title Box-Cox Power Transformation Version 2.3 Date Depends R (>= 2.15.

Advanced Econometrics

Package TimeSeries.OBeu

Package MonoPoly. December 20, 2017

Multivariate Time Series Analysis and Its Applications [Tsay (2005), chapter 8]

Classic Time Series Analysis

Ch3. TRENDS. Time Series Analysis

TIME SERIES ANALYSIS AND FORECASTING USING THE STATISTICAL MODEL ARIMA

Time Series Analysis. James D. Hamilton PRINCETON UNIVERSITY PRESS PRINCETON, NEW JERSEY

ITSM-R Reference Manual

Time Series. Anthony Davison. c

Package CorrMixed. R topics documented: August 4, Type Package

The ARIMA Procedure: The ARIMA Procedure

APPLIED TIME SERIES ECONOMETRICS

A Handbook of Statistical Analyses Using R 2nd Edition. Brian S. Everitt and Torsten Hothorn

Defect Detection using Nonparametric Regression

Kernel-based portmanteau diagnostic test for ARMA time series models

The reldist Package. April 5, 2006

Automatic Autocorrelation and Spectral Analysis

Package nardl. R topics documented: May 7, Type Package

Package MAPA. R topics documented: January 5, Type Package Title Multiple Aggregation Prediction Algorithm Version 2.0.4

A Handbook of Statistical Analyses Using R 2nd Edition. Brian S. Everitt and Torsten Hothorn

Univariate Analysis of Variance

Package face. January 19, 2018

Package mpmcorrelogram

5 Transfer function modelling

Package sym.arma. September 30, 2018

Title. Description. Quick start. Menu. stata.com. xtcointtest Panel-data cointegration tests

Package CoxRidge. February 27, 2015

Package sklarsomega. May 24, 2018

ARIMA modeling to forecast area and production of rice in West Bengal

Package clogitboost. R topics documented: December 21, 2015

Local Polynomial Modelling and Its Applications

Package blme. August 29, 2016

Package gtheory. October 30, 2016

Discrete Simulation of Power Law Noise

mlegp: an R package for Gaussian process modeling and sensitivity analysis

NOTES AND CORRESPONDENCE. A Quantitative Estimate of the Effect of Aliasing in Climatological Time Series

NCSS Statistical Software. Harmonic Regression. This section provides the technical details of the model that is fit by this procedure.

Package rgabriel. February 20, 2015

Wavelet Methods for Time Series Analysis. Motivating Question

Unit root problem, solution of difference equations Simple deterministic model, question of unit root

Nonlinear Time Series

covariance function, 174 probability structure of; Yule-Walker equations, 174 Moving average process, fluctuations, 5-6, 175 probability structure of

Package CovSel. September 25, 2013

Package REGARMA. R topics documented: October 1, Type Package. Title Regularized estimation of Lasso, adaptive lasso, elastic net and REGARMA

Statistical Applications in the Astronomy Literature II Jogesh Babu. Center for Astrostatistics PennState University, USA

Package BootWPTOS. R topics documented: June 30, Type Package

Univariate ARIMA Models

The cramer Package. June 19, cramer.test Index 5

TAKEHOME FINAL EXAM e iω e 2iω e iω e 2iω

Package mar. R topics documented: February 20, Title Multivariate AutoRegressive analysis Version Author S. M. Barbosa

Package anoint. July 19, 2015

WAVEPAL. A Python software for the frequency and wavelet analyses of irregularly sampled time series. Guillaume Lenoir

10) Time series econometrics

Package date. R topics documented: February 20, Version Title Functions for Handling Dates. Description Functions for handling dates.

Time Series Examples Sheet

Package EMMIX. November 8, 2013

The lmm Package. May 9, Description Some improved procedures for linear mixed models

Transcription:

The cts Package June 23, 2006 Title Continuous Time Autoregressive Models Version 1.0 Author Fortran original by G. Tunnicliffe-Wilson and Zhu Wang, R port by Zhu Wang. Continuous Time Autoregressive Models and the Kalman Filter Maintainer Zhu Wang <zwang@scharp.org> License GPL version 2 or later R topics documented: aic.............................................. 1 asth............................................. 2 car.............................................. 3 ctsdiag............................................ 6 factab............................................ 7 kalsmo.car.......................................... 8 kalsmo.comp........................................ 9 plotpredict.car........................................ 10 plot.spec.car......................................... 11 plot.spec.ls......................................... 12 predict.car.......................................... 13 print.car........................................... 14 print.factab......................................... 15 spec.car........................................... 16 spec.ls............................................ 17 V22174........................................... 19 Index 20 1

2 aic aic Model Selection Statistics Compute t-statistic and AIC aic(object) object a fitted time-series CAR model Details Note 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. This is not "true" AIC car data(v22174) (fit <- car(v22174,scale=0.2,order=14)) aic(fit)

asth 3 asth Measurements of The Lung Function Measurements of the lung function of an asthma patient. data(asth) Format The format is: num [1:209, 1:2] 8 10 12 14 16 18 20 22 32 34... Details These are made by the patients mostly at 2h time intervals but with irregular gaps in this record. Source data(asth) str(asth) ; plot(asth) car Fit Continuous Time AR Models to Irregularly Sampled Time Series Fit a continuous AR model to an irregularly sampled univariate time series with the Kalman filter car(x, y=null, scale = 1.5, order = 3, ari= TRUE, phi = rep(0, order), vri = FALSE, vr = 0, pfi = "MAPS", ccv = "CTES", lpv = TRUE, scc = TRUE, n.ahead = 10, nit = 40, opm = 1, rgm = 1, req = 0.5, con = 1e-05, rpe = 1, ivl = 0.01, fac = 10, stl = 1e-05, sml = 100, gtl = 1e+05, kst = TRUE, fct = TRUE, fty=2)

4 car x y scale order 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. not used if x has two columns; otherwise y is a numeric vector of observations at sampled time x. The kappa value referred to in the paper. order of autoregression. ari ari=true: parameter starting values follow phi. ari=false: they are taken as zero phi vri vr pfi ccv lpv scc n.ahead nit opm rgm req con rpe ivl fac stl sml gtl kst fct fty parameter starting values used only if ari=true. vri=false, observation noise not included in the model. vri=true, observation noise included 0.5, initial value of observation noise ratio: only if vri=true always use the option pfi="maps". ccv="ctes" for constant term estimation. ccv="mnct" if mean correction, ccv=null if omitted. lpv=true always use this option. scc=true always use this option. number of steps ahead at which to predict. number of iteations. opm=1 always use this. rgm=1 always use this. root equality switch value. convergence criterion. relative size of parameter perturbations. initial value of step size constraint parameter. step size constraint modification parameter. This value may be setup to fac=5 for better convergency. typical smallest step size parameter. typical small step size parametrr. typical greatest step size parameter. kst=true to save estimated states. fct=true to use all time series to fit the model. fty=1 forecast past the end. fty=2 forecast last L-steps. fty=3 forecast last L-steps updated (filtering)types. Details See references.

car 5 A list of class "car" with the following elements: n.used order np scale vr sigma2 phi x.mean b delb essp ecov rootr rooti tim ser filser filvar sser svar stdred predict predict.var The number of observations of ser used in fitting The order of the fitted model. This is chosen by the user. The number of parameters estimated. This may include the mean and the observation noise ratio. The kappa value referred to in the paper. The estimated observation noise ratio. The estimated innovation variance. The estimated reparameterized autoregressive parameters. The estimated mean of the series used in fitting and for use in prediction. All estimated parameters, which include phi, and possibly x.mean and vr. The estimated standard error of b The estimated correlation matrix of b The estimated covariance matrix of phi. See also aic The real part of roots of phi. See also aic The imaginary part of roots of phi. See also aic The numeric vector of sampled time. The numeric vector of observations at sampled time tim. The filtered time series with the Kalman filter. The estimated variance of Kalman filtered time series filser The smoothed time series with the Kalman smoother. The estimated variance of smoothed time series sser The standardized residuals from the fitted model. Predictions for the series which has been used to fit the model. Prediction variance of predict 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 aic for model selection

6 ctsdiag data(v22174) car(v22174,scale=0.2,order=7) data(asth) car(asth,scale=0.25,order=4) ctsdiag Diagnostic Plots for Time-Series CAR Fits A generic function to plot time-series diagnostics. ctsdiag(object, gof.lag = 10,...) Details object gof.lag a fitted time-series CAR model the maximum number of lags for a Portmanteau goodness-of-fit test... further arguments to be passed to particular methods This is a generic function. 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. None. Diagnostics are plotted. 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

factab 7 car data(v22174) (fit <- car(v22174,scale=0.2,order=7)) ctsdiag(fit) factab Calculate Characteristic Roots and System Frequency Calculate characteristic roots and system frequency from the estimated reparameterized coefficients of CAR fits. factab(object) object a fitted time-series CAR model A table with characteristic roots and frequencies for the corresponding model fit. 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 car and kalsmo.car

8 kalsmo.car data(asth) (fit <- car(asth,scale=0.25,order=4)) factab(fit) kalsmo.car Compute Components with the Kalman Smoother Compute Components corresponding to the diagonal transition matrix with the Kalman Smoother. kalsmo.car(object) object a fitted time-series CAR model Details Note See references. Compute components corresponing to all roots of the chracteristic equation of the CAR model. car can return non-diagonal components 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 car and factab

kalsmo.comp 9 data(asth) (fit <- car(asth,scale=0.25,order=4)) kalsmo.car(fit) kalsmo.comp Estimate Componenents with the Kalman Smoother Estimate unobserved components with the Kalman smoother to a fitted CAR model. kalsmo.comp(x, comp = NULL, plot = TRUE, na.action = na.fail,...) x the result of a fit by car. comp a numeric vector from which components are estimaed plot plot the component? na.action how to handle NAs?... further graphical parameters. A component is computed from the estimated components for each root of the characteristic equation. Wang, Zhu(2004). The Application of the Kalman Filter to Nonstationary Time Series through Time Deformation. PhD thesis, Southern Methodist University kalsmo.car

10 plotpredict.car plotpredict.car Plot of forecast from CAR fits PLot of forecast from models fitted by car plotpredict.car(object, xlab = "time", ylab = NULL, type = "l", main = NULL, sub object the result of a car fit. xlab the x label of the plot. ylab the y label of the plot. type the type of plot to be drawn, defaults to lines. main overall title for the plot. sub a sub title for the plot.... further graphical parameters. Details See predict.car. A plot of original continuous time series along with predictions and 95% confidence intervals 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 car

plot.spec.car 11 data(asth) (fit <- car(asth,scale=0.25,order=4,n.ahead=10)) plotpredict.car(predict(fit) plot.spec.car Plotting Spectral Densities Plotting method for objects of class "spec.car". plot.spec.car(x, add = FALSE, ci = 0.95, log = "db", xlab = "frequency", ylab = NULL, type = "l", main = NULL, sub = NULL,...) x add ci log xlab ylab type main sub an object of class "spec.car". logical. If TRUE, add to already existing plot. Coverage probability for confidence interval. Plotting of the confidence bar is omitted unless ci is strictly positive. If "db", plot on log10 (decibel) scale (as S-PLUS), otherwise use conventional log scale or linear scale. Logical values are also accepted. The default is "yes" unless options(ts.s.compat = TRUE) has been set, when it is "db". the x label of the plot. the y label of the plot. the type of plot to be drawn, defaults to lines. overall title for the plot. a sub title for the plot.... further graphical parameters. plot of spectral density from continuous time series model

12 plot.spec.ls 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 spec.car plot.spec.ls Plotting Lomb-Scargle Periodogram Plotting method for objects of class "spec.ls". plot.spec.ls(x, add = FALSE, ci = 0.95, log = c("yes", "db", "no"), xlab = "frequency", ylab = NULL, type = "l", main = NULL, sub = NULL,...) x add ci log xlab ylab type main sub an object of class "spec.car". logical. If TRUE, add to already existing plot. Coverage probability for confidence interval. Plotting of the confidence bar is omitted unless ci is strictly positive. If "db", plot on log10 (decibel) scale (as S-PLUS), otherwise use conventional log scale or linear scale. Logical values are also accepted. The default is "yes" unless options(ts.s.compat = TRUE) has been set, when it is "db". the x label of the plot. the y label of the plot. the type of plot to be drawn, defaults to lines. overall title for the plot. a sub title for the plot.... Further graphical parameters. spec.ls

predict.car 13 predict.car Forecast from CAR fits Forecast from models fitted by car predict.car(object, se.fit = TRUE, digits = max(3, getoption("digits") - 3),... object the result of a car fit. se.fit Logical: should standard errors of prediction be returned? digits return value digits... arguments passed to or from other methods. Details The Kalman filter forecasting algorithm is used. A time series of predictions, or if se.fit = TRUE, a list with components predict, the predictions, and se, the estimated standard errors. Both components are time series. 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 car

14 print.car data(v22174) (fit <- car(v22174,scale=0.2,order=7,n.ahead=10)) predict(fit) data(asth) (fit <- car(asth,scale=0.25,order=4,n.ahead=10)) predict(fit) print.car Print the Main Results of CAR Fits Print summary results of CAR fits print.car(x, digits = max(3, getoption("digits") - 3),...) x a fitted time-series CAR model digits round error option... further arguments to be passed to particular methods A list of main results from car. 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 car

print.factab 15 data(v22174) (fit <- car(v22174,scale=0.2,order=7)) print(fit) print.factab Print the Results of Characteristic Roots and System Frequency Print summary results of calculated characteristic roots and system frequency from the estimated reparameterized coefficients of CAR fits. print.factab(x,digits = max(3, getoption("digits") - 3),...) x calculated from factab digits round error option... further arguments to be passed to particular methods A table with characteristic roots and frequencies for the corresponding model fit. 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 car and factab data(asth) (fit <- car(asth,scale=0.25,order=4)) print.factab(factab(fit))

16 spec.car spec.car Estimate Spectral Density of a Time Series from CAR Fit uses the existing CAR fit) and return (and by default plots) the spectral density of the fitted model. spec.car(x, n.freq, plot = TRUE, na.action = na.fail,...) x the result of a fit by car. n.freq number of frequency plot Plot the periodogram? na.action NA action function.... Graphical arguments passed to plot.spec. An object of class "spec.car". The result is returned invisibly if plot is true. Note The multivariate case is not yet implemented. 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 car

spec.ls 17 data(v22174) (fit <- car(v22174,scale=0.2,order=7)) spec.car(fit) data(asth) (fit <- car(asth,scale=0.25,order=4)) spec.car(fit) spec.ls Estimate Spectral Density of an Irregularly Sampled Time Series by a Smoothed Periodogram The most commonly used method of computing the spectrum on unevenly spaced time series is periodogram analysis, see Lomb (1975) and Scargle (1982). The Lomb-Scargle method for unevenly spaced data is known to be a powerful tool to find, and test significance of, weak perriodic signals. The Lomb-Scargle periodogram possesses the same statistical properties of standard power spectra. spec.ls(x, y=null, spans = NULL, kernel = NULL, taper = 0.1, pad = 0, fast = TRUE, type = "lomb",demean = FALSE, detrend = TRUE, plot = TRUE, na.action = na.fail,...) x y spans kernel taper pad fast type demean detrend plot na.action 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. not used if x has two columns; otherwise y is a numeric vector of observations at sampled time x.the time at which x is observed vector of odd integers giving the widths of modified Daniell smoothers to be used to smooth the periodogram. alternatively, a kernel smoother of class "tskernel". proportion of data to taper. A split cosine bell taper is applied to this proportion of the data at the beginning and end of the series. proportion of data to pad. Zeros are added to the end of the series to increase its length by the proportion pad. logical; if TRUE, pad the series to a highly composite length. Lomb-Scargle spectrum of Fourier transformation spectrum logical. If TRUE, subtract the mean of the series. logical. If TRUE, remove a linear trend from the series. This will also remove the mean. plot the periodogram? NA action function.... graphical arguments passed to plot.spec.ls.

18 spec.ls Details The raw Lomb-Scargle periodogram for irregularly sampled time series is not a consistent estimator of the spectral density, but adjacent values are asymptotically independent. Hence a consistent estimator can be derived by smoothing the raw periodogram, assuming that the spectral density is smooth. The series will be automatically padded with zeros until the series length is a highly composite number in order to help the Fast Fourier Transform. This is controlled by the fast and not the pad argument. The periodogram at zero is in theory zero as the mean of the series is removed (but this may be affected by tapering): it is replaced by an interpolation of adjacent values during smoothing, and no value is returned for that frequency. A list object of class "spec.ls" with the following additional components: kernel df bandwidth taper pad detrend demean The kernel argument, or the kernel constructed from spans. The distribution of the spectral density estimate can be approximated by a chi square distribution with df degrees of freedom. The equivalent bandwidth of the kernel smoother as defined by Bloomfield (1976, page 201). The value of the taper argument. The value of the pad argument. The value of the detrend argument. The value of the demean argument. The result is returned invisibly if plot is true. Note This is slow program and a fast program may use FFT, see (Press et al, 1992) Lomb-Scargle periodogram by Zhu Wang Bloomfield, P. (1976) Fourier Analysis of Time Series: An Introduction.Wiley. Lomb, N. R. (1976) Least-squares frequency-analysis of unequally spaced data. Astrophysics and Space Science, 39,447-462 W. H. Press and S. A. Teukolsky and W. T. Vetterling and B.P. Flannery (1992) Numerical Recipes in C: The Art of Scientific Computing., Cambridge University Press, second edition. Scargle, J.D. (1982) Studies in astronomical time series analysis II. Statistical aspects of spectral analysis of unevenly spaced data, The Astrophysical Journal, 263, volume 2, 835-853. spec.taper, plot.spec.ls, fft

V22174 19 data(v22174) spec.ls(v22174) data(asth) spec.ls(asth) V22174 Measurments of Relative Aboundance Format Source Measurments of relative aboundance of an xxygen isotope in an ocean core. data(v22174) The format is: num [1:164, 1:2] 6.13 8.39 10.64 12.90 15.16... data(v22174) str(v22174) ; plot(v22174)

Index Topic datasets asth, 2 V22174, 18 Topic hplot plot.spec.car, 10 plot.spec.ls, 11 Topic ts aic, 1 car, 3 ctsdiag, 5 factab, 6 kalsmo.car, 7 kalsmo.comp, 8 plot.spec.car, 10 plot.spec.ls, 11 plotpredict.car, 9 predict.car, 12 print.car, 13 print.factab, 14 spec.car, 15 spec.ls, 16 tsdiag.car (ctsdiag), 5 V22174, 18 aic, 1, 4, 5 asth, 2 car, 2, 3, 5 10, 12 15 ctsdiag, 5 factab, 6, 8, 14 fft, 17 kalsmo.car, 7, 7, 9 kalsmo.comp, 8 plot.spec, 15 plot.spec.car, 10 plot.spec.ls, 11, 17 plotpredict.car, 9 predict.car, 12 print.car, 13 print.factab, 14 spec.car, 11, 15 spec.ls, 12, 16 spec.taper, 17 20