[Blotter-commits] r608 - pkg/RTAQ/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon May 30 11:49:19 CEST 2011
Author: jonathan
Date: 2011-05-30 11:49:18 +0200 (Mon, 30 May 2011)
New Revision: 608
Modified:
pkg/RTAQ/R/volatility.R
Log:
Modified: pkg/RTAQ/R/volatility.R
===================================================================
--- pkg/RTAQ/R/volatility.R 2011-05-30 09:48:43 UTC (rev 607)
+++ pkg/RTAQ/R/volatility.R 2011-05-30 09:49:18 UTC (rev 608)
@@ -88,26 +88,37 @@
##Multivariate measures:
#Realized Covariation (RCov):
-RCov = function(rdata,cor=FALSE, makeReturns = FALSE, ...){
- if(hasArg(data)){ rdata = data }
-
- if(makeReturns){ rdata = makeReturns(rdata)}
-
- if(is.null(dim(rdata))){ n=1 }else{ n = dim(rdata)[2]}
+RCov = function (rdata, cor = FALSE, makeReturns = FALSE, ...)
+{
+ if (hasArg(data)) {
+ rdata = data
+ }
+ if (makeReturns) {
+ rdata = makeReturns(rdata)
+ }
+ if (is.null(dim(rdata))) {
+ n = 1
+ }
+ else {
+ n = dim(rdata)[2]
+ }
+ if (n == 1) {
+ return(RV(rdata))
+ }
+ if (n > 1) {
+# rdata = na.locf(rdata, na.rm = FALSE)
- if( n == 1 ){ return( RV( rdata ))}
-
- if( n > 1 ){
- rdata = na.locf(rdata,na.rm=FALSE);
- rdata = as.matrix(rdata);
- covariance = t(rdata)%*%rdata;
- if(cor==FALSE){return(covariance)}
- if(cor==TRUE){
- sdmatrix = sqrt(diag(diag(covariance)));
- rcor = solve(sdmatrix)%*%covariance%*%solve(sdmatrix);
- return(rcor)
- }
- }
+ rdata = as.matrix(rdata)
+ covariance = t(rdata) %*% rdata
+ if (cor == FALSE) {
+ return(covariance)
+ }
+ if (cor == TRUE) {
+ sdmatrix = sqrt(diag(diag(covariance)))
+ rcor = solve(sdmatrix) %*% covariance %*% solve(sdmatrix)
+ return(rcor)
+ }
+ }
}
#Realized Outlyingness Weighted Quadratic Covariation (ROWQCov)
More information about the Blotter-commits
mailing list