Learn R Programming

timeSeries (version 4030.106)

timeSeries-method-stats: Time Series Correlations

Description

S4 methods of stats package for timeSeries objects.

covComputes Covariance from a 'timeSeries' object,
corComputes Correlations from a 'timeSeries' object.
dcauchy...
dnorm...
dt...

Usage

# S4 method for timeSeries
cov(x, y = NULL, use = "all.obs", 
    method = c("pearson", "kendall", "spearman"))
    
# S4 method for timeSeries
cor(x, y = NULL, use = "all.obs", 
    method = c("pearson", "kendall", "spearman"))

Value

returns the covariance or correlation matrix.

Arguments

method

a character string indicating which correlation coefficient (or covariance) is to be computed. One of "pearson" (default), "kendall", or "spearman", can be abbreviated.

use

an optional character string giving a method for computing covariances in the presence of missing values. This must be (an abbreviation of) one of the strings "all.obs", "complete.obs" or "pairwise.complete.obs".

x

an univariate object of class timeSeries.

y

NULL (default) or a timeSeries object with compatible dimensions to x. The default is equivalent to y = x (but more efficient).

Examples

Run this code
## Load Microsoft Data Set - 
   data(MSFT)
   X = MSFT[, 1:4]
   X = 100 * returns(X)

## Compute Covariance Matrix - 
   cov(X[, "Open"], X[, "Close"])
   cov(X)

Run the code above in your browser using DataLab