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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Aug 5 20:27:47 CEST 2013


Author: chenyian
Date: 2013-08-05 20:27:47 +0200 (Mon, 05 Aug 2013)
New Revision: 2721

Removed:
   pkg/FactorAnalytics/R/portfolioSdDecomposition.R
Modified:
   pkg/FactorAnalytics/R/
   pkg/FactorAnalytics/R/factorModelCovariance.r
   pkg/FactorAnalytics/R/factorModelMonteCarlo.R
   pkg/FactorAnalytics/man/factorModelMonteCarlo.Rd
Log:
debug export tag and returnItem issues. 


Property changes on: pkg/FactorAnalytics/R
___________________________________________________________________
Modified: svn:ignore
   - FactorAnalytics-package.R
bootstrapFactorESdecomposition.r
bootstrapFactorVaRdecomposition.r
chart.RollingStyle.R
chart.Style.R
covEWMA.R
dCornishFisher.R
factorModelFactorRiskDecomposition.r
factorModelGroupRiskDecomposition.r
factorModelPerformanceAttribution.r
factorModelPortfolioRiskDecomposition.r
factorModelRiskAttribution.r
factorModelRiskDecomposition.r
factorModelSimulation.r
impliedFactorReturns.R
modifiedEsReport.R
modifiedIncrementalES.R
modifiedIncrementalVaR.R
modifiedPortfolioEsDecomposition.R
modifiedPortfolioVaRDecomposition.R
modifiedVaRReport.R
nonparametricEsReport.R
nonparametricIncrementalES.R
nonparametricIncrementalVaR.R
nonparametricPortfolioEsDecomposition.R
nonparametricPortfolioVaRDecomposition.R
nonparametricVaRReport.R
normalEsReport.R
normalIncrementalES.R
normalIncrementalVaR.R
normalPortfolioEsDecomposition.R
normalPortfolioVaRDecomposition.R
normalVaRReport.R
pCornishFisher.R
plot.FM.attribution.r
plot.MacroFactorModel.r
print.MacroFactorModel.r
qCornishFisher.R
rCornishFisher.R
scenarioPredictions.r
scenarioPredictionsPortfolio.r
style.QPfit.R
style.fit.R
summary.FM.attribution.r
summary.MacroFactorModel.r
table.RollingStyle.R

   + FactorAnalytics-package.R
bootstrapFactorESdecomposition.r
bootstrapFactorVaRdecomposition.r
chart.RollingStyle.R
chart.Style.R
covEWMA.R
dCornishFisher.R
factorModelFactorRiskDecomposition.r
factorModelGroupRiskDecomposition.r
factorModelPerformanceAttribution.r
factorModelPortfolioRiskDecomposition.r
factorModelRiskAttribution.r
factorModelRiskDecomposition.r
factorModelSimulation.r
impliedFactorReturns.R
modifiedEsReport.R
modifiedIncrementalES.R
modifiedIncrementalVaR.R
modifiedPortfolioEsDecomposition.R
modifiedPortfolioVaRDecomposition.R
modifiedVaRReport.R
nonparametricEsReport.R
nonparametricIncrementalES.R
nonparametricIncrementalVaR.R
nonparametricPortfolioEsDecomposition.R
nonparametricPortfolioVaRDecomposition.R
nonparametricVaRReport.R
normalEsReport.R
normalIncrementalES.R
normalIncrementalVaR.R
normalPortfolioEsDecomposition.R
normalPortfolioVaRDecomposition.R
normalVaRReport.R
pCornishFisher.R
plot.FM.attribution.r
plot.MacroFactorModel.r
portfolioSdDecomposition.R
print.MacroFactorModel.r
qCornishFisher.R
rCornishFisher.R
scenarioPredictions.r
scenarioPredictionsPortfolio.r
style.QPfit.R
style.fit.R
summary.FM.attribution.r
summary.MacroFactorModel.r
table.RollingStyle.R


Modified: pkg/FactorAnalytics/R/factorModelCovariance.r
===================================================================
--- pkg/FactorAnalytics/R/factorModelCovariance.r	2013-08-05 17:25:28 UTC (rev 2720)
+++ pkg/FactorAnalytics/R/factorModelCovariance.r	2013-08-05 18:27:47 UTC (rev 2721)
@@ -60,6 +60,8 @@
 #' ret.cov.fundm <- factorModelCovariance(beta.mat1,fit.fund$factor.cov$cov,fit.fund$resid.variance)
 #' fit.fund$returns.cov$cov == ret.cov.fundm
 #' }
+#' @export
+#' 
 
 factorModelCovariance <-
 function(beta, factor.cov, resid.variance) {

Modified: pkg/FactorAnalytics/R/factorModelMonteCarlo.R
===================================================================
--- pkg/FactorAnalytics/R/factorModelMonteCarlo.R	2013-08-05 17:25:28 UTC (rev 2720)
+++ pkg/FactorAnalytics/R/factorModelMonteCarlo.R	2013-08-05 18:27:47 UTC (rev 2721)
@@ -36,12 +36,14 @@
 #' @param return.residuals logical; if \code{TRUE} then return simulated
 #' residuals in output list object.
 #' @return A list with the following components:
-#' @returnItem returns \code{n.boot x n.funds} matrix of simulated fund
+#' \itemize{
+#' \item returns \code{n.boot x n.funds} matrix of simulated fund
 #' returns.
-#' @returnItem factors \code{n.boot x n.factors} matrix of resampled factor
+#' \item factors \code{n.boot x n.factors} matrix of resampled factor
 #' returns. Returned only if \code{return.factors = TRUE}.
-#' @returnItem residuals \code{n.boot x n.funds} matrix of simulated fund
+#' \item residuals \code{n.boot x n.funds} matrix of simulated fund
 #' residuals. Returned only if \code{return.residuals = TRUE}.
+#' }
 #' @author Eric Zivot and Yi-An Chen.
 #' @references Jiang, Y. (2009). UW PhD Thesis.
 #' @export

Deleted: pkg/FactorAnalytics/R/portfolioSdDecomposition.R
===================================================================
--- pkg/FactorAnalytics/R/portfolioSdDecomposition.R	2013-08-05 17:25:28 UTC (rev 2720)
+++ pkg/FactorAnalytics/R/portfolioSdDecomposition.R	2013-08-05 18:27:47 UTC (rev 2721)
@@ -1,79 +0,0 @@
-#' Compute portfolio sd (risk) decomposition by asset.
-#' 
-#' Compute portfolio sd (risk) decomposition by asset.
-#' 
-#' 
-#' @param w.vec N x 1 vector of portfolio weights
-#' @param cov.assets N x N asset covariance matrix
-#' @return an S3 list containing
-#' @returnItem sd.p Scalar, portfolio standard deviation.
-#' @returnItem mcsd.p 1 x N vector, marginal contributions to portfolio
-#' standard deviation.
-#' @returnItem csd.p 1 x N vector, contributions to portfolio standard
-#' deviation.
-#' @returnItem pcsd.p 1 x N vector, percent contribution to portfolio standard
-#' deviation.
-#' @author Eric Zivot and Yi-An Chen
-#' @references Qian, Hua and Sorensen (2007) Quantitative Equity Portfolio
-#' Management, chapter 3.
-#' @examples
-#' 
-#' # load data from the database
-#' data(managers.df)
-#' ret.assets = managers.df[,(1:6)]
-#' factors    = managers.df[,(7:9)]
-#' # fit the factor model with OLS
-#' fit <-fitMacroeconomicFactorModel(ret.assets,factors,fit.method="OLS",
-#'                                   variable.selection="all subsets", factor.set = 3)
-#' # factor SD decomposition for HAM1
-#' cov.factors = var(factors)
-#' manager.names = colnames(managers.df[,(1:6)])
-#' factor.names  = colnames(managers.df[,(7:9)])
-#' # assuming equal weight vector
-#' w.vec = rep(1/6,6)
-#' # compute with sample covariance matrix (omit NA)
-#' cov.sample = ccov(managers.df[,manager.names],na.action=na.omit)
-#' port.sd.decomp.sample = portfolioSdDecomposition(w.vec, cov.sample$cov)
-#' # show bar chart
-#' barplot(port.sd.decomp.sample$pcsd.p,
-#'         main="Fund Percent Contributions to Portfolio SD",
-#'         ylab="Percent Contribution", legend.text=FALSE,
-#'         col="blue")
-#' 
-#' # compute with factor model covariance matrix
-#' returnCov.mat<- factorModelCovariance(fit$beta.mat,var(factors),fit$residVars.vec)
-#' port.sd.decomp.fm = portfolioSdDecomposition(w.vec, returnCov.mat)                                                         
-#' 
-#' 
-portfolioSdDecomposition <-
-function(w.vec, cov.assets) {
-## Inputs:
-## w.vec         n x 1 vector of portfolio weights
-## cov.assets		 n x n asset covariance matrix
-## Output:
-## A list with the following components:
-## sd.p          scalar, portfolio sd
-## mcsd.p        1 x n vector, marginal contributions to portfolio sd
-## csd.p         1 x n vector, contributions to portfolio sd
-## pcsd.p        1 x n vector, percent contribution to portfolio sd
-	
- if (any(diag(chol(cov.assets)) == 0))
-    warning("Asset covariance matrix is not positive definite")
- ## compute portfolio level variance
- var.p = as.numeric(t(w.vec) %*% cov.assets %*% w.vec)
- sd.p = sqrt(var.p)
- ## compute marginal, component and percentage contributions to risk
- mcsd.p = (cov.assets %*% w.vec)/sd.p
- csd.p = w.vec*mcsd.p
- pcsd.p = csd.p/sd.p
- colnames(mcsd.p) = "MCSD"
- colnames(csd.p) = "CSD"
- colnames(pcsd.p) = "PCSD"
- ## return results
- ans = list(sd.p=sd.p,
-            mcsd.p=t(mcsd.p),
-            csd.p=t(csd.p),
-            pcsd.p=t(pcsd.p))
- return(ans)
-}
-

Modified: pkg/FactorAnalytics/man/factorModelMonteCarlo.Rd
===================================================================
--- pkg/FactorAnalytics/man/factorModelMonteCarlo.Rd	2013-08-05 17:25:28 UTC (rev 2720)
+++ pkg/FactorAnalytics/man/factorModelMonteCarlo.Rd	2013-08-05 18:27:47 UTC (rev 2721)
@@ -56,7 +56,14 @@
   return simulated residuals in output list object.}
 }
 \value{
-  A list with the following components:
+  A list with the following components: \itemize{ \item
+  returns \code{n.boot x n.funds} matrix of simulated fund
+  returns. \item factors \code{n.boot x n.factors} matrix
+  of resampled factor returns. Returned only if
+  \code{return.factors = TRUE}. \item residuals
+  \code{n.boot x n.funds} matrix of simulated fund
+  residuals. Returned only if \code{return.residuals =
+  TRUE}. }
 }
 \description{
   Simulate returns using factor model Monte Carlo method.



More information about the Returnanalytics-commits mailing list