[Returnanalytics-commits] r3116 - in pkg/Meucci: R demo man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Sep 16 11:32:05 CEST 2013


Author: xavierv
Date: 2013-09-16 11:32:05 +0200 (Mon, 16 Sep 2013)
New Revision: 3116

Modified:
   pkg/Meucci/R/LognormalMoments2Parameters.R
   pkg/Meucci/demo/00Index
   pkg/Meucci/demo/S_LognormalSample.R
   pkg/Meucci/demo/S_NonAnalytical.R
   pkg/Meucci/demo/S_NormalSample.R
   pkg/Meucci/demo/S_StudentTSample.R
   pkg/Meucci/man/LognormalMoments2Parameters.Rd
Log:
 - updated documentation for chapter 1 demo scripts and its functions

Modified: pkg/Meucci/R/LognormalMoments2Parameters.R
===================================================================
--- pkg/Meucci/R/LognormalMoments2Parameters.R	2013-09-16 08:26:10 UTC (rev 3115)
+++ pkg/Meucci/R/LognormalMoments2Parameters.R	2013-09-16 09:32:05 UTC (rev 3116)
@@ -1,24 +1,30 @@
 #' @title Computes the mean and standard deviation of a lognormal distribution from its parameters.
 #'
-#' @description Computes the mean and standard deviation of a lognormal distribution from its parameters, as described in  
+#' @description determines $\mu$ and $\sigma^2$ from $\Expect\{X\}$ and $\Var\{X\}$, and uses it to determine $\mu$ 
+#'  and $\sigma^{2}$ such that $\Expect\left\{  X\right\} \bydef 3$ and $\Var\left\{  X\right\}  \bydef 5$, as described in  
 #'  A. Meucci, "Risk and Asset Allocation", Springer, 2005.
 #'
-#'	@param  e    [scalar] expected value of the lognormal distribution
-#'  @param	v    [scalar] variance of the lognormal distribution
+#' \deqn{\sigma^{2} = \ln \left( 1 + \frac{V}{E^{2}} \right) , }
+#' \deqn{\mu = \ln(E) - \frac{1}{2} \ln \left( 1 + \frac{V}{E^{2}} \right) .}
+#'
+#'
+#'	@param  e     [scalar] expected value of the lognormal distribution
+#'  @param	v  	  [scalar] variance of the lognormal distribution
 #'  
-#'  @return	mu   [scalar] expected value of the normal distribution
-#'  @return	sig2 [scalar] variance of the normal distribution
+#'  @return	mu 	  [scalar] expected value of the normal distribution
+#'  @return	sig2  [scalar] variance of the normal distribution
 #'  
 #'  @note	Inverts the formulas (1.98)-(1.99) in "Risk and Asset Allocation", Springer, 2005.
 #'
 #' @references
-#' A. Meucci - "Exercises in Advanced Risk and Portfolio Management" \url{http://symmys.com/node/170}., "E 25- Simulation of a lognormal random variable"
+#' A. Meucci - "Exercises in Advanced Risk and Portfolio Management" \url{http://symmys.com/node/170}, "E 25- Simulation of a lognormal random variable".
+#'
 #' See Meucci's script for "LognormalMoments2Parameters.m"
 #'
 #' @author Xavier Valls \email{flamejat@@gmail.com}
 #' @export
 
-LognormalMoments2Parameters = function( e, v)
+LognormalMoments2Parameters = function( e, v )
 {
 	sig2 = log( 1 + v / ( e^2 ) );
 	mu = log( e ) - sig2 / 2;

Modified: pkg/Meucci/demo/00Index
===================================================================
--- pkg/Meucci/demo/00Index	2013-09-16 08:26:10 UTC (rev 3115)
+++ pkg/Meucci/demo/00Index	2013-09-16 09:32:05 UTC (rev 3116)
@@ -98,7 +98,7 @@
 S_Wishart                            generates a sample from the 2x2 Wishart distribution
 S_WishartCorrelation                 computes the correlation of the first diagonal and off-diagonal elements of a 2x2 Wishart distribution as a function of the inputs
 S_WishartLocationDispersion   		 computes the location-dispersion ellipsoid of the normalized first diagonal and off-diagonal elements of a 2x2 Wishart distribution as a function of the inputs
-S_ToyExample               			 illustrates the use of Entropy Pooling to compute Fully Flexible probabilities
+S_ToyExample               			 illustrates the use of Entropy Pooling to compute Fully Flexible Probabilities
 logToArithmeticCovariance   		 generates arithmetric returns and arithmetric covariance matrix given a distribution of log returns
 S_plotGaussHermite          		 displays mesh points based on Gaussian-Hermite quadrature Bayesian networks
 

Modified: pkg/Meucci/demo/S_LognormalSample.R
===================================================================
--- pkg/Meucci/demo/S_LognormalSample.R	2013-09-16 08:26:10 UTC (rev 3115)
+++ pkg/Meucci/demo/S_LognormalSample.R	2013-09-16 09:32:05 UTC (rev 3116)
@@ -2,15 +2,14 @@
 #' A. Meucci, "Risk and Asset Allocation", Springer, 2005,  Chapter 1.
 #'
 #' @references
-#' @references
-#' A. Meucci - "Exercises in Advanced Risk and Portfolio Management" \url{http://symmys.com/node/170}., "E 25- Simulation of a lognormal random variable"
-#' See Meucci's script for "S_LognormalSample.m"
+#' A. Meucci - "Exercises in Advanced Risk and Portfolio Management" \url{http://symmys.com/node/170}, 
+#' E 25- Simulation of a lognormal random variable".
 #'
+#' See Meucci's script for "S_LognormalSample.m".
+#'
 #' @author Xavier Valls \email{flamejat@@gmail.com}
 #' @export
 
-source("../R/LognormalMoments2Parameters.R");
-
 ##################################################################################################################
 ### Input parameters
 

Modified: pkg/Meucci/demo/S_NonAnalytical.R
===================================================================
--- pkg/Meucci/demo/S_NonAnalytical.R	2013-09-16 08:26:10 UTC (rev 3115)
+++ pkg/Meucci/demo/S_NonAnalytical.R	2013-09-16 09:32:05 UTC (rev 3116)
@@ -2,11 +2,12 @@
 #' A. Meucci, "Risk and Asset Allocation", Springer, 2005,  Chapter 1.
 #'
 #' @references
-#' \url{http://}
-#' See Meucci's script for "S_NonAnalytical.m"
+#' A. Meucci - "Exercises in Advanced Risk and Portfolio Management" \url{http://symmys.com/node/170},
+#' "E 22- Sum of random variables via simulation".
 #'
+#' See Meucci's script for "S_NonAnalytical.m".
+#'
 #' @author Xavier Valls \email{flamejat@@gmail.com}
-#' @export
 
 ##################################################################################################################
 ### Input parameters

Modified: pkg/Meucci/demo/S_NormalSample.R
===================================================================
--- pkg/Meucci/demo/S_NormalSample.R	2013-09-16 08:26:10 UTC (rev 3115)
+++ pkg/Meucci/demo/S_NormalSample.R	2013-09-16 09:32:05 UTC (rev 3116)
@@ -2,11 +2,12 @@
 #' A. Meucci, "Risk and Asset Allocation", Springer, 2005,  Chapter 1.
 #'
 #' @references
-#' \url{http://}
+#' A. Meucci - "Exercises in Advanced Risk and Portfolio Management" \url{http://symmys.com/node/170},
+#' "E 23- Simulation of univariate random normal variable".
+#'
 #' See Meucci's script for "S_NormalSample.m"
 #'
 #' @author Xavier Valls \email{flamejat@@gmail.com}
-#' @export
 
 ##################################################################################################################
 ### Input parameters
@@ -50,7 +51,7 @@
 
 # plot empirical quantile
 dev.new();
-u= seq( 0.01, 0.99, 0.01 ); # range of quantiles (values between zero and one)
+u = seq( 0.01, 0.99, 0.01 ); # range of quantiles (values between zero and one)
 q = quantile( X, u );
 plot( u, q, type = "l", xlab="Grade", ylab="Quantile",  lty = 1, col = "red",  main = "quantile of normal distribution" );
 

Modified: pkg/Meucci/demo/S_StudentTSample.R
===================================================================
--- pkg/Meucci/demo/S_StudentTSample.R	2013-09-16 08:26:10 UTC (rev 3115)
+++ pkg/Meucci/demo/S_StudentTSample.R	2013-09-16 09:32:05 UTC (rev 3116)
@@ -2,11 +2,12 @@
 #' A. Meucci, "Risk and Asset Allocation", Springer, 2005,  Chapter 1.
 #'
 #' @references
-#' \url{http://}
+#' A. Meucci - "Exercises in Advanced Risk and Portfolio Management" \url{http://symmys.com/node/170},
+#' "E 24- Simulation of a Student t random variable".
+#'
 #' See Meucci's script for "S_StudentTSample.m"
 #'
 #' @author Xavier Valls \email{flamejat@@gmail.com}
-#' @export
 
 ##################################################################################################################
 ### Input parameters
@@ -38,7 +39,7 @@
 ##################################################################################################################
 ### Generate Student t sample with above parameters using grade inversion
 
-U = runif( nSim );
+U   = runif( nSim );
 X_c = mu + sigma * qt( U, nu );
 
 ##################################################################################################################
@@ -46,21 +47,15 @@
 NumBins = round(10 * log(nSim));
 
 dev.new();
-par( mfrow = c( 3, 1) );
+par( mfrow = c( 3, 1 ) );
 
 hist( X_a, NumBins, main = "built-in generator" );
 hist( X_b, NumBins, main = "stoch. representation" );
 hist( X_c, NumBins, main = "grade inversion" );
 
-
-#axisLimits = [min(axisLimits(:, 1)), max(axisLimits(:, 2)), min(axisLimits(:, 3)), max(axisLimits(:, 4))];
-#subplot(3, 1, 1), axis(axisLimits);
-#subplot(3, 1, 2), axis(axisLimits);
-#subplot(3, 1, 3), axis(axisLimits);
-
 ##################################################################################################################
 ### Compare empirical quantiles of the three simuations
-u= seq( 0.01, 0.99, 0.01 ); # range of quantiles (values between zero and one) = 0.01 : 0.01 : 0.99;  # range of quantiles (values between zero and one)
+u   = seq( 0.01, 0.99, 0.01 ); # range of quantiles (values between zero and one) = 0.01 : 0.01 : 0.99;  # range of quantiles (values between zero and one)
 q_a = quantile( X_a, u );
 q_b = quantile( X_b, u );
 q_c = quantile( X_c, u );

Modified: pkg/Meucci/man/LognormalMoments2Parameters.Rd
===================================================================
--- pkg/Meucci/man/LognormalMoments2Parameters.Rd	2013-09-16 08:26:10 UTC (rev 3115)
+++ pkg/Meucci/man/LognormalMoments2Parameters.Rd	2013-09-16 09:32:05 UTC (rev 3116)
@@ -16,9 +16,15 @@
   sig2 [scalar] variance of the normal distribution
 }
 \description{
-  Computes the mean and standard deviation of a lognormal
-  distribution from its parameters, as described in A.
-  Meucci, "Risk and Asset Allocation", Springer, 2005.
+  determines $\mu$ and $\sigma^2$ from $\Expect\{X\}$ and
+  $\Var\{X\}$, and uses it to determine $\mu$ and
+  $\sigma^{2}$ such that $\Expect\left\{ X\right\} \bydef
+  3$ and $\Var\left\{ X\right\} \bydef 5$, as described in
+  A. Meucci, "Risk and Asset Allocation", Springer, 2005.
+
+  \deqn{\sigma^{2} = \ln \left( 1 + \frac{V}{E^{2}} \right)
+  , } \deqn{\mu = \ln(E) - \frac{1}{2} \ln \left( 1 +
+  \frac{V}{E^{2}} \right) .}
 }
 \note{
   Inverts the formulas (1.98)-(1.99) in "Risk and Asset
@@ -29,8 +35,9 @@
 }
 \references{
   A. Meucci - "Exercises in Advanced Risk and Portfolio
-  Management" \url{http://symmys.com/node/170}., "E 25-
-  Simulation of a lognormal random variable" See Meucci's
-  script for "LognormalMoments2Parameters.m"
+  Management" \url{http://symmys.com/node/170}, "E 25-
+  Simulation of a lognormal random variable".
+
+  See Meucci's script for "LognormalMoments2Parameters.m"
 }
 



More information about the Returnanalytics-commits mailing list