Learn R Programming

costat (version 1.1-1)

costat-package: Find costationary time series, compute time-localized autocovariance, time-localized cross-covariance, time-localized spectrum.

Description

Main purpose of package is, given two time series, $$X_t$$ and $$Y_t$$, find the time-varying linear combination $$Z_t = \alpha_t X_t + \beta_t Y_t$$ such that $$Z_t$$ is a stationary series. Essentially, the program begins using random starts for the coefficient vector of $$(\alpha_t, \beta_t)$$ and then optimizes a measure of stationarity over possible combinations of the coefficient function.

Arguments

Details

ll{ Package: costat Type: Package Version: 1.0 Date: 2007-06-13 License: GPL version 2 or newer } For costationarity the most important function is the findstysols which, given two time series, tsx and tsy, and a given complexity Ncoefs, finds the set (number dependent and equal to Nsims) of solutions that solve the optimization problem ``find the coefficient vectors that cause the time-varying linear combination of tsx and tsy to be as most stationary as possible''. findstysols is capable of running one optimization run, or several. The former can be useful when running a single optimization job as part of several on a multiprocessor machine, however the function can run all your optimization jobs a single call (it'll just take longer).

Typically, one should start with Ncoefs small (it must be one less than a dyadic number, e.g. 3, 7, 15, for Haar wavelets), 3 say, run several optimizations to see how likely the linear combinations are to be stationary. If the time series themselves are fairly stationary (but not exactly, if they were both stationary then it is trivial to find a stationary linear combination) then it will be easy to find many stationary combinations. If the time series are highly non-stationary, evolving significantly over time, then more complex time-varying combination vectors will be required to get stationarity more often. Note that since the algorithm is based on numerical optimization, one is never guaranteed to find an optimal solution even if one exists. Our methodology adopts the time-honoured strategy of multiple random starts to find stationary solutions. If many solutions indicate stationarity has been reached then you have found the types and complexity of solutions that give stationarity. If many solutions indicate that stationarity has not been reached (look at the p-value output of link{findstysols}) then you should increase Ncoefs to the next dyadic number (less one) and then try again.

Once you have discovered a set of solutions which appear to contain a number of stationary ones then the functions LCTSres and COEFbothscale can be used to interrogate the solution set to find clusters of solutions. Since findstysols uses multiple numerical optimizations the solution set tends to cluster around a number of ``true'' linear combination vectors and the interrogation functions are useful for identifying the number of these, and also what they represent.

The function mergexy can merge together the result sets of multiple findstysols runs with the resultant object being as if one run of findstysols had been used. This again can be useful to concatenate result sets from multiple runs on, say, a multiprocessor/core machine.

The test of stationarity is contained in the myTOS function, which can take a time series and uses a bootstrap method to test for stationarity. The exact test statistic is contained in TOSts which is called by myTOS. In principle, another test of stationarity could be substitued for the wavelet based bootstrap test, a Fourier test, or something else could potentially be used. The costationarity idea is independent of the particular test statistic used. However, the judgement of a particular linear combination of two time series and whether it is stationary does, of course, depend on the particular test used.

This package also contains a number of other functions of use in analysing single and pairs of locally stationary time series. For example, lacv computes the time-localized autocovariance of any time series (including stationary ones!) using a wavelet method (although the quantity itself only depends on time and lag), crosslacv performs a similar job, but computes the cross time-localized covariance between two series, ewcrossspec the time-localized cross spectrum, localvar computes the time-localized variance of the series, again computed via a wavelet method, but not, in the end, dependent on it, just time.

The functions tstosscan and plottstosscan take a single time series, apply a test of stationarity at multiple locations on multiple length windows of a series, and the latter function produces a plot that displays the results of the tests. These functions are very useful in discovering the degree of non-stationarity of a time series. I.e. not only whether a series, or bits of it, are non-stationary, but where and also over what periods. E.g. a series might be stationary over a window of 32 or 64 observations, but decidedly non-stationary over a longer time period (plus the statistical power of detection is greater for longer series as there is generally more information).

References

`Costationary and stationarity tests for stock index returns' by Car dinali and Nason, 2008, University of Bristol Technical Report 08:08.

Examples

Run this code
#
# See comprehensive examples in the help pages for the major functions
# outlined above.
#

Run the code above in your browser using DataLab