Skip to contents

The rolling_correlation() is a generic S3 function that builds upon 'type-safe'-esque workflows limited to classes in in base R, and the package-wide dependencies. Ie. class in, class out.

Usage

rolling_correlation(x, y, n = 10)

Arguments

x, y

((double), (double)). A pair of vectors.

n

(integer). An integer of length 1.

Value

A double vector with the same length of x

Author

Serkan Korkmaz

Examples

## load Bitcoin (BTC)
## series
data(BTC, package = "talib")

## calculate the rolling statistic
## between Open and Close
output <- talib::rolling_correlation(x = BTC[[1]], y = BTC[[4]])

## display the results
utils::tail(output)
#> [1] 0.7369425 0.5788049 0.3598043 0.4020494 0.5134674 0.5397380