[Returnanalytics-commits] r3633 - in pkg/FactorAnalytics: R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Apr 17 21:57:46 CEST 2015
Author: arorar
Date: 2015-04-17 21:57:45 +0200 (Fri, 17 Apr 2015)
New Revision: 3633
Modified:
pkg/FactorAnalytics/R/fmmc.R
pkg/FactorAnalytics/man/fmmc.Rd
Log:
Fixed calculation of estimates and se when se is set to false.
Modified: pkg/FactorAnalytics/R/fmmc.R
===================================================================
--- pkg/FactorAnalytics/R/fmmc.R 2015-04-17 16:38:40 UTC (rev 3632)
+++ pkg/FactorAnalytics/R/fmmc.R 2015-04-17 19:57:45 UTC (rev 3633)
@@ -303,8 +303,8 @@
#' time series with different starting dates are merged together. It then
#' computes FMMC objects as described in Jiang and Martin (2013)
#'
-#' @param R matrix of returns
-#' @param factors matrix of factor returns
+#' @param R matrix of returns in xts format
+#' @param factors matrix of factor returns in xts format
#' @param parallel flag to utilize multiplecores on the cpu. All cores are used.
#' @param ... Arguments that must be passed to fitTsfm
#'
@@ -318,6 +318,10 @@
#'
#' @return returns an list of fmmc objects
#'
+#' @references
+#' Yindeng Jiang and Richard Doug Martin. Better Risk and Performance
+#' Estimates with Factor Model Monte Carlo. SSRN Electronic Journal, July 2013.
+#'
#' @author Rohit Arora
#' @export
#'
@@ -364,8 +368,7 @@
fmmc.estimate.se <- function(fmmcObjs, fun=NULL, se=FALSE, nboot=100,
parallel = FALSE) {
- est <- se.est <- rep(NA, length(fmmcObjs))
- result <- cbind(est, se.est); colnames(result) <- c("estimate","se")
+ result <- as.matrix(rep(NA, length(fmmcObjs))); colnames(result) <- "estimate"
rownames(result) <- unlist(lapply(fmmcObjs, function(obj) colnames(obj$data$R)))
if(is.null(fun)) return(result)
@@ -377,8 +380,12 @@
}
result[,1] <- unlist(lapply(fmmcObjs, function(obj) fun(obj$bootdist$returns)))
- result[,2] <- if(se) unlist(
- lapply(fmmcObjs, function(obj) .fmmc.se(obj, nboot, fun, cl)))
+ if(se) {
+ serr <- unlist(
+ lapply(fmmcObjs, function(obj) .fmmc.se(obj, nboot, fun, cl)))
+ result <- cbind(result, serr)
+ colnames(result) <- c("estimate", "se")
+ }
if(parallel) stopCluster(cl)
Modified: pkg/FactorAnalytics/man/fmmc.Rd
===================================================================
--- pkg/FactorAnalytics/man/fmmc.Rd 2015-04-17 16:38:40 UTC (rev 3632)
+++ pkg/FactorAnalytics/man/fmmc.Rd 2015-04-17 19:57:45 UTC (rev 3633)
@@ -1,34 +1,38 @@
-% Generated by roxygen2 (4.1.0): do not edit by hand
-% Please edit documentation in R/fmmc.R
-\name{fmmc}
-\alias{fmmc}
-\title{Compute fmmc objects that can be used for calcuation of estimates and their
-standard errors}
-\usage{
-fmmc(R, factors, parallel = FALSE, ...)
-}
-\arguments{
-\item{R}{matrix of returns}
-
-\item{factors}{matrix of factor returns}
-
-\item{parallel}{flag to utilize multiplecores on the cpu. All cores are used.}
-
-\item{...}{Arguments that must be passed to fitTsfm}
-}
-\value{
-returns an list of fmmc objects
-}
-\description{
-Compute fmmc objects that can be used for calcuation of estimates and their
-standard errors
-}
-\details{
-This method takes in data and factors as xts objects where multiple
-time series with different starting dates are merged together. It then
-computes FMMC objects as described in Jiang and Martin (2013)
-}
-\author{
-Rohit Arora
-}
-
+% Generated by roxygen2 (4.1.0): do not edit by hand
+% Please edit documentation in R/fmmc.R
+\name{fmmc}
+\alias{fmmc}
+\title{Compute fmmc objects that can be used for calcuation of estimates and their
+standard errors}
+\usage{
+fmmc(R, factors, parallel = FALSE, ...)
+}
+\arguments{
+\item{R}{matrix of returns in xts format}
+
+\item{factors}{matrix of factor returns in xts format}
+
+\item{parallel}{flag to utilize multiplecores on the cpu. All cores are used.}
+
+\item{...}{Arguments that must be passed to fitTsfm}
+}
+\value{
+returns an list of fmmc objects
+}
+\description{
+Compute fmmc objects that can be used for calcuation of estimates and their
+standard errors
+}
+\details{
+This method takes in data and factors as xts objects where multiple
+time series with different starting dates are merged together. It then
+computes FMMC objects as described in Jiang and Martin (2013)
+}
+\author{
+Rohit Arora
+}
+\references{
+Yindeng Jiang and Richard Doug Martin. Better Risk and Performance
+Estimates with Factor Model Monte Carlo. SSRN Electronic Journal, July 2013.
+}
+
More information about the Returnanalytics-commits
mailing list