rRealizedVariance {realized}R Documentation

Calculate realized variance, covariance, or correlation.

Description

Calculate realized variance, covariance, correlation, covariance matrix, or correlation matrix.

Usage

rRealizedVariance(x, y = NULL, type = "naive", period = 1, lags = 1, cor = FALSE, args = list(), cts = TRUE, makeReturns = FALSE)

Arguments

x RealizedObject or TimeSeries for S+
y RealizedObject or TimeSeries for S+
period Sampling period
type Type of realized estimator to use, a rv. or rc. is appended to this value and that function is called
lags Number of lags or subgrids for kernel and subsample based estimators
cor T for correlation
args List of extra parameters to pass into rv.* or rc.*
cts Create calendar time sampling if a non realizedObject is passed
makeReturns Prices are passed make them into log returns

Details

Calculate realized variance, covariance, correlation, covariance matrix, or correlation matrix.

Value

A single numeric value or a matrix if x is multicolumn matrix.

Author(s)

Scott Payseur <spayseur@u.washington.edu>

See Also

rc.avg, rc.kernel, rc.naive, rc.timescale, rv.avg, rv.kernel, rv.naive, rv.timescale

Examples

data(msft.real.cts)
data(ge.real.cts)

# Traditional Estimate at highest frequency
rRealizedVariance(x=msft.real.cts[[1]], y=ge.real.cts[[1]], type="naive", period=1)

# Traditional Estimate at one minute frequency 
rRealizedVariance(x=msft.real.cts[[1]], y=ge.real.cts[[1]], type="naive", period=1, args=list(align.period=60)) 

# Traditional Estimate at 10 minute frequency 
rRealizedVariance(x=msft.real.cts[[1]], y=ge.real.cts[[1]], type="naive", period=10, args=list(align.period=60)) 

# Bartlett Kernel Estimate with minute aligned data at 20 lags 
rRealizedVariance(x=msft.real.cts[[1]], y=ge.real.cts[[1]], type="kernel", lags=20, args=list(align.period=60, type="Bartlett"))

# Cubic Kernel Estimate with second aligned data at 400 lags 
rRealizedVariance(x=msft.real.cts[[1]], y=ge.real.cts[[1]], type="kernel", lags=400, args=list(type="Cubic")) 

# Lead-Lag with one lag at one minute frequency 
rRealizedVariance(x=msft.real.cts[[1]], y=ge.real.cts[[1]], type="kernel", lags=1, args=list(align.period=60)) 
 
# Subsample Average Estimate with second aligned data at 600 subgrids 
rRealizedVariance(x=msft.real.cts[[1]], y=ge.real.cts[[1]], type="avg", period=600) 

# Traditional Estimate at highest frequency 
rRealizedVariance(x=merge(msft.real.cts[[1]], ge.real.cts[[1]]), type="naive", period=1)

# Traditional Estimate at 10 minute frequency 
rRealizedVariance(x=merge(msft.real.cts[[1]], ge.real.cts[[1]]), type="naive", period=10, args=list(align.period=60))

# Lead-Lag with one lag at one minute frequency> 
rRealizedVariance(x=merge(msft.real.cts[[1]], ge.real.cts[[1]]), type="kernel", lags=1, args=list(align.period=60))

# Subsample Average Estimate with second aligned data at 600 subgrids 
rRealizedVariance(x=merge(msft.real.cts[[1]], ge.real.cts[[1]]), type="avg", period=600)
 
 
 
 
# Traditional Estimate at highest frequency 
rRealizedVariance(x=msft.real.cts[[1]], y=ge.real.cts[[1]], type="naive", period=1, cor=TRUE) 

# Traditional Estimate at one minute frequency 
rRealizedVariance(x=msft.real.cts[[1]], y=ge.real.cts[[1]], type="naive", period=1, args=list(align.period=60), cor=TRUE)

# Traditional Estimate at 10 minute frequency 
rRealizedVariance(x=msft.real.cts[[1]], y=ge.real.cts[[1]], type="naive", period=10, args=list(align.period=60), cor=TRUE) 

# Bartlett Kernel Estimate with minute aligned data at 20 lags 
rRealizedVariance(x=msft.real.cts[[1]], y=ge.real.cts[[1]], type="kernel", lags=20, args=list(align.period=60, type="Bartlett"), cor=TRUE)

# Cubic Kernel Estimate with second aligned data at 400 lags 
rRealizedVariance(x=msft.real.cts[[1]], y=ge.real.cts[[1]], type="kernel", lags=400, args=list(type="Cubic"), cor=TRUE) 

# Lead-Lag with one lag at one minute frequency 
rRealizedVariance(x=msft.real.cts[[1]], y=ge.real.cts[[1]], type="kernel", lags=1, args=list(align.period=60), cor=TRUE) 

# Subsample Average Estimate with second aligned data at 600 subgrids 
rRealizedVariance(x=msft.real.cts[[1]], y=ge.real.cts[[1]], type="avg", period=600, cor=TRUE) 

# Correlation Matrices
# Traditional Estimate at highest frequency 
rRealizedVariance(x=merge(msft.real.cts[[1]], ge.real.cts[[1]]), type="naive", period=1, cor=TRUE)

# Traditional Estimate at 10 minute frequency
rRealizedVariance(x=merge(msft.real.cts[[1]], ge.real.cts[[1]]), type="naive", period=10, args=list(align.period=60), cor=TRUE)

# Lead-Lag with one lag at one minute frequency 
rRealizedVariance(x=merge(msft.real.cts[[1]], ge.real.cts[[1]]), type="kernel", lags=1, args=list(align.period=60), cor=TRUE) 

# Subsample Average Estimate with second aligned data at 600 subgrids >
rRealizedVariance(x=merge(msft.real.cts[[1]], ge.real.cts[[1]]), type="avg", period=600, cor=TRUE) 


[Package realized version 0.81 Index]