Learn R Programming

costat (version 1.1-1)

prodcomb: Combine two time series using a time-varying linear combination.

Description

This function takes the cfs vector and splits it into two halves. The first half contains the wavelet coefficients for the alpha linear combination function, and the second half for the beta one. Then the functions themselves are generated by using the coeftofn function. Then, the coefficient functions are multiplied by the respective time series (tsx by alpha and tsy by beta) and the result returned.

Usage

prodcomb(cfs, tsx, tsy, filter.number = 1, family = "DaubExPhase", all = FALSE)

Arguments

cfs
Wavelet coefficients of the two combination functions. The coefficients for alpha/beta combination functions are stored in the first/last half of the vector.
tsx
The x time series to combine
tsy
The y time series to combine
filter.number
The wavelet filter to use to obtain functions from coefficients
family
The wavelet family to do the same.
all
If TRUE then a list containing the combined series in the component lcts and the combination functions in components alpha and beta. Although the combined series is the thing that is usually later tested for sta

Value

  • If all=TRUE then a list with the following components:
  • lctsThe combined series, $$\alpha_t X_t + \beta_t Y_t$$
  • alphaThe $$\alpha_t$$ combination function.
  • betaThe $$\beta_t$$ combination function.
  • If all=FALSE then only lcts is returned.

Details

This function is called by findstysols and makes use of coeftofn to turn coefficients into a function used in the combination.

References

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

See Also

findstysols, coeftofn

Examples

Run this code
#
# Toy example
#
tmp.a <- c(1, -1)
tmp.b <- c(0.5, 0.5)
#
# Generate toy time series
#
xxx <- rnorm(256)
yyy <- rnorm(256)
#
# Combine xxx and yyy using the functions produced by inverse wavelet
# transform of tmp.a and tmp.b
#
tmp <- prodcomb(c(tmp.a, tmp.b), tsx=xxx, tsy=yyy)
#
# E.g. plot combination
#
ts.plot(tmp)
#
# Potentially test its stationarity.... etc
#

Run the code above in your browser using DataLab