[Returnanalytics-commits] r3849 - in pkg/FactorAnalytics: . R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Jul 24 08:38:57 CEST 2015


Author: pragnya
Date: 2015-07-24 08:38:57 +0200 (Fri, 24 Jul 2015)
New Revision: 3849

Modified:
   pkg/FactorAnalytics/DESCRIPTION
   pkg/FactorAnalytics/NAMESPACE
   pkg/FactorAnalytics/R/CornishFisher.R
   pkg/FactorAnalytics/R/fitTsfm.R
   pkg/FactorAnalytics/R/zzz.R
   pkg/FactorAnalytics/man/CornishFisher.Rd
   pkg/FactorAnalytics/man/fitTsfm.Rd
Log:
Add semi-parametric factor model Monte Carlo

Modified: pkg/FactorAnalytics/DESCRIPTION
===================================================================
--- pkg/FactorAnalytics/DESCRIPTION	2015-07-22 21:32:02 UTC (rev 3848)
+++ pkg/FactorAnalytics/DESCRIPTION	2015-07-24 06:38:57 UTC (rev 3849)
@@ -1,8 +1,8 @@
 Package: factorAnalytics
 Type: Package
 Title: Factor Analytics
-Version:2.0.21
-Date:2015-05-28
+Version:2.0.22
+Date:2015-07-23
 Author: Eric Zivot, Sangeetha Srinivasan and Yi-An Chen
 Maintainer: Sangeetha Srinivasan <sangee at uw.edu>
 Description: An R package for the estimation and risk analysis of linear factor
@@ -36,7 +36,8 @@
     parallel,
     doSNOW,
     RCurl,
-    bestglm
+    bestglm,
+    tseries
 Suggests:
     testthat
 LazyLoad: yes

Modified: pkg/FactorAnalytics/NAMESPACE
===================================================================
--- pkg/FactorAnalytics/NAMESPACE	2015-07-22 21:32:02 UTC (rev 3848)
+++ pkg/FactorAnalytics/NAMESPACE	2015-07-24 06:38:57 UTC (rev 3849)
@@ -83,5 +83,7 @@
 importFrom(sandwich,vcovHAC.default)
 importFrom(sandwich,vcovHC.default)
 importFrom(sn,dst)
+importFrom(sn,rst)
 importFrom(sn,st.mple)
 importFrom(strucchange,efp)
+importFrom(tseries,tsbootstrap)

Modified: pkg/FactorAnalytics/R/CornishFisher.R
===================================================================
--- pkg/FactorAnalytics/R/CornishFisher.R	2015-07-22 21:32:02 UTC (rev 3848)
+++ pkg/FactorAnalytics/R/CornishFisher.R	2015-07-24 06:38:57 UTC (rev 3849)
@@ -22,6 +22,9 @@
 #' @param sigma scalar standard deviation.
 #' @param skew scalar; skewness.
 #' @param ekurt scalar; excess kurtosis.
+#' @param dp a vector of length 3, whose elements represent sigma, skew and 
+#' ekurt, respectively. If dp is specified, the individual parameters cannot be 
+#' set. Default is \code{NULL}.
 #' @param seed scalar; set seed. Default is \code{NULL}.
 #' @param x,q vector of standardized quantiles.
 #' @param p vector of probabilities.
@@ -95,16 +98,26 @@
 #' @rdname CornishFisher
 #' @export
 
-rCornishFisher <- function(n, sigma, skew, ekurt, seed=NULL) {
+rCornishFisher <- function(n, sigma, skew, ekurt, dp=NULL, seed=NULL) {
   
   ## inputs:
   ## n          scalar, number of simulated values
   ## sigma      scalar, standard deviation
   ## skew       scalar, skewness
   ## ekurt      scalar, excess kurtosis
+  ## dp         vector of values for sigma, skew and ekurt respectively
   ## outputs:
   ## n simulated values from Cornish-Fisher distribution
   
+  if (!is.null(dp)) {
+    if (!missing(sigma)) {
+      stop("Invalid argument: Cannot set both component parameters and dp")
+    } 
+    sigma <- dp[1]
+    skew <- dp[2]
+    ekurt <- dp[3]
+  }
+  
   if (!is.null(seed)) set.seed(seed)
   zc <- rnorm(n)
   z.cf <- zc + 

Modified: pkg/FactorAnalytics/R/fitTsfm.R
===================================================================
--- pkg/FactorAnalytics/R/fitTsfm.R	2015-07-22 21:32:02 UTC (rev 3848)
+++ pkg/FactorAnalytics/R/fitTsfm.R	2015-07-24 06:38:57 UTC (rev 3849)
@@ -54,10 +54,10 @@
 #' @param asset.names vector containing names of assets, whose returns or 
 #' excess returns are the dependent variable.
 #' @param factor.names vector containing names of the macroeconomic factors.
-#' @param mkt.name name of the column for market returns. Default is NULL.
+#' @param mkt.name name of the column for market returns. Default is \code{NULL}.
 #' @param rf.name name of the column of risk free rate variable to calculate 
 #' excess returns for all assets (in \code{asset.names}) and factors (in 
-#' \code{factor.names}). Default is NULL, and no action is taken.
+#' \code{factor.names}). Default is \code{NULL}, and no action is taken.
 #' @param data vector, matrix, data.frame, xts, timeSeries or zoo object  
 #' containing column(s) named in \code{asset.names}, \code{factor.names} and 
 #' optionally, \code{mkt.name} and \code{rf.name}.
@@ -125,17 +125,17 @@
 #' \code{\link{paFm}} for Performance Attribution. 
 #' 
 #' @examples
-#' # load data from the database
 #' data(managers)
 #' fit <- fitTsfm(asset.names=colnames(managers[,(1:6)]),
 #'                factor.names=colnames(managers[,(7:9)]), data=managers)
 #' summary(fit)
 #' fitted(fit)
+#' 
 #' # plot actual returns vs. fitted factor model returns for HAM1
 #' plot(fit, plot.single=TRUE, asset.name="HAM1", which=1)
-#' # group plot; type selected from menu prompt; auto-looped for multiple plots
-#' # plot(fit)
 #' 
+#' # plot(fit) # this presents a menu for group plots
+#' # select desired plot from the menu (auto-looped for multiple plots)
 #' 
 #' # example using "subsets" variable selection
 #' fit.sub <- fitTsfm(asset.names=colnames(managers[,(1:6)]),

Modified: pkg/FactorAnalytics/R/zzz.R
===================================================================
--- pkg/FactorAnalytics/R/zzz.R	2015-07-22 21:32:02 UTC (rev 3848)
+++ pkg/FactorAnalytics/R/zzz.R	2015-07-24 06:38:57 UTC (rev 3849)
@@ -9,13 +9,14 @@
 #' @importFrom lmtest coeftest.default
 #' @importFrom sandwich vcovHC.default vcovHAC.default
 #' @importFrom MASS ginv
+#' @importFrom tseries tsbootstrap
 
 #' @importFrom PerformanceAnalytics chart.TimeSeries chart.ACFplus 
 #' chart.Histogram chart.QQPlot chart.Correlation
 #' @importFrom lattice barchart xyplot panel.barchart panel.grid
 #' @importFrom corrplot corrplot.mixed
 #' @importFrom strucchange efp
-#' @importFrom sn dst st.mple
+#' @importFrom sn dst rst st.mple
 
 #' @importFrom parallel makeCluster detectCores clusterEvalQ clusterExport 
 #' stopCluster

Modified: pkg/FactorAnalytics/man/CornishFisher.Rd
===================================================================
--- pkg/FactorAnalytics/man/CornishFisher.Rd	2015-07-22 21:32:02 UTC (rev 3848)
+++ pkg/FactorAnalytics/man/CornishFisher.Rd	2015-07-24 06:38:57 UTC (rev 3849)
@@ -14,7 +14,7 @@
 
 qCornishFisher(p, n, skew, ekurt)
 
-rCornishFisher(n, sigma, skew, ekurt, seed = NULL)
+rCornishFisher(n, sigma, skew, ekurt, dp = NULL, seed = NULL)
 }
 \arguments{
 \item{x,q}{vector of standardized quantiles.}
@@ -30,6 +30,10 @@
 
 \item{sigma}{scalar standard deviation.}
 
+\item{dp}{a vector of length 3, whose elements represent sigma, skew and
+ekurt, respectively. If dp is specified, the individual parameters cannot be
+set. Default is \code{NULL}.}
+
 \item{seed}{scalar; set seed. Default is \code{NULL}.}
 }
 \value{

Modified: pkg/FactorAnalytics/man/fitTsfm.Rd
===================================================================
--- pkg/FactorAnalytics/man/fitTsfm.Rd	2015-07-22 21:32:02 UTC (rev 3848)
+++ pkg/FactorAnalytics/man/fitTsfm.Rd	2015-07-24 06:38:57 UTC (rev 3849)
@@ -24,11 +24,11 @@
 
 \item{factor.names}{vector containing names of the macroeconomic factors.}
 
-\item{mkt.name}{name of the column for market returns. Default is NULL.}
+\item{mkt.name}{name of the column for market returns. Default is \code{NULL}.}
 
 \item{rf.name}{name of the column of risk free rate variable to calculate
 excess returns for all assets (in \code{asset.names}) and factors (in
-\code{factor.names}). Default is NULL, and no action is taken.}
+\code{factor.names}). Default is \code{NULL}, and no action is taken.}
 
 \item{data}{vector, matrix, data.frame, xts, timeSeries or zoo object
 containing column(s) named in \code{asset.names}, \code{factor.names} and
@@ -133,17 +133,17 @@
 }
 }
 \examples{
-# load data from the database
 data(managers)
 fit <- fitTsfm(asset.names=colnames(managers[,(1:6)]),
                factor.names=colnames(managers[,(7:9)]), data=managers)
 summary(fit)
 fitted(fit)
+
 # plot actual returns vs. fitted factor model returns for HAM1
 plot(fit, plot.single=TRUE, asset.name="HAM1", which=1)
-# group plot; type selected from menu prompt; auto-looped for multiple plots
-# plot(fit)
 
+# plot(fit) # this presents a menu for group plots
+# select desired plot from the menu (auto-looped for multiple plots)
 
 # example using "subsets" variable selection
 fit.sub <- fitTsfm(asset.names=colnames(managers[,(1:6)]),



More information about the Returnanalytics-commits mailing list