[Returnanalytics-commits] r2481 - in pkg/Meucci: . R data demo

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Jul 1 10:26:28 CEST 2013


Author: xavierv
Date: 2013-07-01 10:26:27 +0200 (Mon, 01 Jul 2013)
New Revision: 2481

Added:
   pkg/Meucci/data/equities.Rda
   pkg/Meucci/demo/S_EquitiesInvariance.R
Modified:
   pkg/Meucci/DESCRIPTION
   pkg/Meucci/R/PerformIidAnalysis.R
   pkg/Meucci/demo/S_AutocorrelatedProcess.R
   pkg/Meucci/demo/S_BivariateSample.R
Log:
added S_EquitiesInvariance.R demo file and its asociate data file

Modified: pkg/Meucci/DESCRIPTION
===================================================================
--- pkg/Meucci/DESCRIPTION	2013-06-30 22:16:49 UTC (rev 2480)
+++ pkg/Meucci/DESCRIPTION	2013-07-01 08:26:27 UTC (rev 2481)
@@ -29,7 +29,8 @@
     zoo,
     xts (>= 0.8),
     matlab,
-    pracma
+    pracma,
+    R.utils
 Suggests:
     quadprog,
     mvtnorm,

Modified: pkg/Meucci/R/PerformIidAnalysis.R
===================================================================
--- pkg/Meucci/R/PerformIidAnalysis.R	2013-06-30 22:16:49 UTC (rev 2480)
+++ pkg/Meucci/R/PerformIidAnalysis.R	2013-07-01 08:26:27 UTC (rev 2481)
@@ -30,7 +30,7 @@
 	##########################################################################################################
 	### Test "identically distributed hypothesis": split observations into two sub-samples and plot histogram
 	Sample_1 = Data[ 1:round(length(Data) / 2) ];
-	Sample_2 = Data[ round(length(Data)/2) + 1: length(Data) ];
+	Sample_2 = Data[(round(length(Data)/2) + 1) : length(Data) ];
 	num_bins_1 = round(5 * log(length(Sample_1)));
 	num_bins_2 = round(5 * log(length(Sample_2)));
 	X_lim = c( min(Data) - .1 * (max(Data) - min(Data)), max(Data) + .1 * (max(Data) - min(Data)));

Added: pkg/Meucci/data/equities.Rda
===================================================================
(Binary files differ)


Property changes on: pkg/Meucci/data/equities.Rda
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Modified: pkg/Meucci/demo/S_AutocorrelatedProcess.R
===================================================================
--- pkg/Meucci/demo/S_AutocorrelatedProcess.R	2013-06-30 22:16:49 UTC (rev 2480)
+++ pkg/Meucci/demo/S_AutocorrelatedProcess.R	2013-07-01 08:26:27 UTC (rev 2481)
@@ -7,7 +7,6 @@
 #' See Meucci's script for "S_AutocorrelatedProcess.m"
 #'
 #' @author Xavier Valls \email{flamejat@@gmail.com}
-#' @export
 
 ##################################################################################################################
 ### Input parameters

Modified: pkg/Meucci/demo/S_BivariateSample.R
===================================================================
--- pkg/Meucci/demo/S_BivariateSample.R	2013-06-30 22:16:49 UTC (rev 2480)
+++ pkg/Meucci/demo/S_BivariateSample.R	2013-07-01 08:26:27 UTC (rev 2481)
@@ -9,7 +9,6 @@
 #' See Meucci's script for "S_BivariateSample.m"
 #'
 #' @author Xavier Valls \email{flamejat@@gmail.com}
-#' @export
 
 ###################################################################################################################
 ### input parameters

Added: pkg/Meucci/demo/S_EquitiesInvariance.R
===================================================================
--- pkg/Meucci/demo/S_EquitiesInvariance.R	                        (rev 0)
+++ pkg/Meucci/demo/S_EquitiesInvariance.R	2013-07-01 08:26:27 UTC (rev 2481)
@@ -0,0 +1,42 @@
+##################################################################################################################
+### This file performs the quest for invariance in the stock market
+### == Chapter 3 ==
+##################################################################################################################
+#' This file performs the quest for invariance in the stock market, as described in 
+#' A. Meucci "Risk and Asset Allocation", Springer, 2005, chapter 3.
+#'
+#' @references
+#' \url{http://}
+#' See Meucci's script for "S_EquitiesInvariance.m"
+#'
+#' @author Xavier Valls \email{flamejat@@gmail.com}
+
+
+
+##################################################################################################################
+### Load daily stock prices from the utility sector in the S&P 500
+load("../data/equities.Rda");
+
+##################################################################################################################
+### Pick one stock from database
+Stock_Index = 20;
+P = Equities$Prices[ 632 : nrow( Equities$Prices ), Stock_Index ]; # select data after 1/8 rule
+
+##################################################################################################################
+### Quest for invariance
+# first invariant
+X = P[ -1 ] / P[ -length( P )];
+PerformIidAnalysis( 1 : length( X ), X, 'Analysis for X' );
+
+# second invariant
+Y = P[ -1 ] / P[ -length( P )];
+PerformIidAnalysis(1 : length( Y ), Y, 'Analysis for Y' );
+
+# third invariant
+Z = X ^ 2;
+PerformIidAnalysis( 1 : length(Z), Z, 'Analysis for Z' );
+
+# fourth invariant
+W = P[ 3 : length( P ) ] - 2 * P[ 2: ( length( P ) -1 ) ] + P[ 1 : ( length( P ) -2 ) ];
+PerformIidAnalysis( 1 : length( W ), W, 'Analysis for W' );
+



More information about the Returnanalytics-commits mailing list