[Returnanalytics-commits] r3018 - pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Sep 7 14:48:30 CEST 2013


Author: shubhanm
Date: 2013-09-07 14:48:30 +0200 (Sat, 07 Sep 2013)
New Revision: 3018

Modified:
   pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/table.ComparitiveReturn.GLM.R
   pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/table.UnsmoothReturn.R
Log:
table.ComparitiveReturn.GLM.R Handle of nan + correction of ARMA function
table.UnsmoothReturn.R Handle of NANa + handling correction of ARMA function

+ still some issues in accuracy of values in Comparative Return GLM


Modified: pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/table.ComparitiveReturn.GLM.R
===================================================================
--- pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/table.ComparitiveReturn.GLM.R	2013-09-07 12:22:09 UTC (rev 3017)
+++ pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/table.ComparitiveReturn.GLM.R	2013-09-07 12:48:30 UTC (rev 3018)
@@ -27,7 +27,7 @@
     # p = Confifence Level
     # Output:
     # A table of estimates of Moving Average
-    
+    require("tseries")
     y = checkData(R, method = "xts")
     columns = ncol(y)
     rows = nrow(y)
@@ -37,13 +37,14 @@
     # for each column, do the following:
     for(column in 1:columns) {
       x = y[,column]
+      x=na.omit(x)
       skew = skewness(x)
-      arma.coeff= arma(x,0,n)
+      arma.coeff= arma(x,order=c(0,n))
       kurt= kurtosis(x)
       z = c(skew,
-            ((sum(arma.coeff$theta^2)^1.5)*(skew/(sum(arma.coeff$theta^3)))),
+            ((sum(as.numeric(arma.coeff$coef[1:n])^2)^1.5)*(skew/(sum(as.numeric(arma.coeff$coef[1:n])^3)))),
             kurt,
-             (kurt*(sum(arma.coeff$theta^2)^2-6*(sum(arma.coeff$theta^2)*sum(arma.coeff$theta^2)))/(sum(arma.coeff$theta^4))))
+             (-kurt*(sum(as.numeric(arma.coeff$coef[1:n])^2)^2-6*(sum(as.numeric(arma.coeff$coef[1:n])^2)*sum(as.numeric(arma.coeff$coef[1:n])^2)))/(sum(as.numeric(arma.coeff$coef[1:n])^4))))
       znames = c(
         "Skewness ( Orignal) ",
         "Skewness (Unsmooth)",
@@ -60,8 +61,8 @@
     colnames(resultingtable) = columnnames
     ans = base::round(resultingtable, digits)
     ans
-    
-    
+    # arma.coeff$theta
+    # as.numeric(arma.coeff$coef[1:n])
   }
 
 ###############################################################################

Modified: pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/table.UnsmoothReturn.R
===================================================================
--- pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/table.UnsmoothReturn.R	2013-09-07 12:22:09 UTC (rev 3017)
+++ pkg/PerformanceAnalytics/sandbox/Shubhankit/noniid.sm/R/table.UnsmoothReturn.R	2013-09-07 12:48:30 UTC (rev 3018)
@@ -53,6 +53,7 @@
     # for each column, do the following:
     for(column in 1:columns) {
       x = y[,column]
+    x=na.omit(x)
       ma.stats= arma(x, order = c(0, 2))
 
       z = c(as.numeric(ma.stats$coef[1]),



More information about the Returnanalytics-commits mailing list