[Returnanalytics-commits] r3498 - in pkg/FactorAnalytics: R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Aug 5 12:32:43 CEST 2014
Author: pragnya
Date: 2014-08-05 12:32:43 +0200 (Tue, 05 Aug 2014)
New Revision: 3498
Modified:
pkg/FactorAnalytics/R/fitTsfm.R
pkg/FactorAnalytics/R/fitTsfm.control.R
pkg/FactorAnalytics/R/fmEsDecomp.R
pkg/FactorAnalytics/R/paFm.r
pkg/FactorAnalytics/R/plot.tsfm.r
pkg/FactorAnalytics/R/summary.tsfm.r
pkg/FactorAnalytics/man/CommonFactors.Rd
pkg/FactorAnalytics/man/fitTsfm.Rd
pkg/FactorAnalytics/man/fitTsfm.control.Rd
pkg/FactorAnalytics/man/paFm.Rd
pkg/FactorAnalytics/man/plot.tsfm.Rd
pkg/FactorAnalytics/man/summary.tsfm.Rd
Log:
Corrected typos
Modified: pkg/FactorAnalytics/R/fitTsfm.R
===================================================================
--- pkg/FactorAnalytics/R/fitTsfm.R 2014-08-05 01:32:33 UTC (rev 3497)
+++ pkg/FactorAnalytics/R/fitTsfm.R 2014-08-05 10:32:43 UTC (rev 3498)
@@ -487,7 +487,6 @@
#' @param object a fit object of class \code{tsfm} which is returned by
#' \code{fitTsfm}
-#' @param ... further arguments passed to or from other methods
#' @rdname fitTsfm
#' @method coef tsfm
Modified: pkg/FactorAnalytics/R/fitTsfm.control.R
===================================================================
--- pkg/FactorAnalytics/R/fitTsfm.control.R 2014-08-05 01:32:33 UTC (rev 3497)
+++ pkg/FactorAnalytics/R/fitTsfm.control.R 2014-08-05 10:32:43 UTC (rev 3498)
@@ -108,10 +108,8 @@
#' @author Sangeetha Srinivasan
#'
#' @references
-#' \enumerate{
-#' \item Efron, Bradley, Trevor Hastie, Iain Johnstone, and Robert Tibshirani.
-#' "Least angle regression." The Annals of statistics 32, no.2 (2004): 407-499.
-#' }
+#' Efron, B., Hastie, T., Johnstone, I., & Tibshirani, R. (2004). Least angle
+#' regression. The Annals of statistics, 32(2), 407-499.
#'
#' @seealso \code{\link{fitTsfm}}, \code{\link[stats]{lm}},
#' \code{\link[robust]{lmRob}}, \code{\link[stats]{step}},
Modified: pkg/FactorAnalytics/R/fmEsDecomp.R
===================================================================
--- pkg/FactorAnalytics/R/fmEsDecomp.R 2014-08-05 01:32:33 UTC (rev 3497)
+++ pkg/FactorAnalytics/R/fmEsDecomp.R 2014-08-05 10:32:43 UTC (rev 3498)
@@ -93,8 +93,8 @@
#' @export
fmEsDecomp.tsfm <- function(object, p=0.95,
- method=c("modified","gaussian","historical",
- "kernel"), invert=FALSE, ...) {
+ method=c("modified","gaussian","historical",
+ "kernel"), invert=FALSE, ...) {
# set defaults and check input vailidity
method = method[1]
@@ -110,7 +110,8 @@
# factor returns and residuals data
factors.xts <- object$data[,object$factor.names]
- resid.xts <- t(t(residuals(object))/object$resid.sd)
+ resid.xts <- as.xts(t(t(residuals(object))/object$resid.sd))
+ time(resid.xts) <- as.Date(time(resid.xts))
# initialize lists and matrices
N <- length(object$asset.names)
@@ -167,59 +168,4 @@
ES.fm=ES.fm, mES=mES, cES=cES, pcES=pcES)
return(fm.ES.decomp)
- }
-
-
-
-
-
-factorModelEsDecomposition <-
- function(Data, beta.vec, sig.e, tail.prob = 0.05,
- VaR.method=c("modified", "gaussian", "historical", "kernel")) {
-
- Data = as.matrix(Data)
- ncol.Data = ncol(Data)
- if(is.matrix(beta.vec)) {
- beta.names = c(rownames(beta.vec), "residual")
- } else if(is.vector(beta.vec)) {
- beta.names = c(names(beta.vec), "residual")
- } else {
- stop("beta.vec is not an n x 1 matrix or a vector")
- }
- beta.names = c(names(beta.vec), "residual")
- beta.star.vec = c(beta.vec, sig.e)
- names(beta.star.vec) = beta.names
-
- ## epsilon is calculated in the sense of minimizing mean square error by Silverman 1986
- epi <- 2.575*sd(Data[,1]) * (nrow(Data)^(-1/5))
- VaR.fm = as.numeric(VaR(Data[, 1], p=(1-tail.prob), method=VaR.method))
- idx = which(Data[, 1] <= VaR.fm + epi & Data[,1] >= VaR.fm - epi)
-
-
-
- ES.fm = -mean(Data[idx, 1])
-
- ##
- ## compute marginal contribution to ES
- ##
- ## compute marginal ES as expected value of factor return given fund
- ## return is less than or equal to VaR
- mcES.fm = -as.matrix(colMeans(Data[idx, -1]))
-
- ## compute correction factor so that sum of weighted marginal ES adds to portfolio ES
- cf = as.numeric( ES.fm / sum(mcES.fm*beta.star.vec) )
- mcES.fm = cf*mcES.fm
- cES.fm = mcES.fm*beta.star.vec
- pcES.fm = cES.fm/ES.fm
- colnames(mcES.fm) = "MCES"
- colnames(cES.fm) = "CES"
- colnames(pcES.fm) = "PCES"
- ans = list(VaR.fm = -VaR.fm,
- n.exceed = length(idx),
- idx.exceed = idx,
- ES.fm = ES.fm,
- mES.fm = t(mcES.fm),
- cES.fm = t(cES.fm),
- pcES.fm = t(pcES.fm))
- return(ans)
- }
+}
Modified: pkg/FactorAnalytics/R/paFm.r
===================================================================
--- pkg/FactorAnalytics/R/paFm.r 2014-08-05 01:32:33 UTC (rev 3497)
+++ pkg/FactorAnalytics/R/paFm.r 2014-08-05 10:32:43 UTC (rev 3498)
@@ -1,34 +1,38 @@
#' @title Compute cumulative mean attribution for factor models
#'
#' @description Decompose total returns into returns attributed to factors and
-#' specific returns. An object of class \code{"pafm"} is generated and generic
-#' functions such as \code{plot}, \code{summary} and \code{print} can be used.
+#' specific returns. An object of class \code{"pafm"} is generated, with
+#' methods for generic functions \code{plot}, \code{summary} and \code{print}.
#'
#' @details Total returns can be decomposed into returns attributed to factors
-#' and specific returns. \cr \eqn{R_t = \sum b_j * f_jt + u_t,t=1...T} \cr
-#' \code{b_j} is exposure to factor j and \code{f_jt} is factor j.
-#' The returns attributed to factor j is \code{b_j * f_jt} and specific
-#' returns is \code{u_t}.
+#' and specific returns. \cr \eqn{R_t = \sum b_k * f_kt + u_t, t=1...T} \cr
+#' \code{b_k} is exposure to factor k and \code{f_kt} is factor k's return at
+#' time t. The return attributed to factor k is \code{b_k * f_kt} and specific
+#' return is \code{u_t}.
#'
#' @param fit an object of class \code{tsfm}, \code{sfm} or \code{ffm}.
#' @param ... other arguments/controls passed to the fit methods.
#'
#' @return The returned object is of class \code{"pafm"} containing
-#' \describe{
-#' \item{cum.ret.attr.f}{N X J matrix of cumulative return attributed to
+#' \item{cum.ret.attr.f}{N X K matrix of cumulative return attributed to
#' factors.}
-#' \item{cum.spec.ret}{1 x N vector of cumulative specific returns.}
+#' \item{cum.spec.ret}{length-N vector of cumulative specific returns.}
#' \item{attr.list}{list of time series of attributed returns for every
#' portfolio.}
-#' }
#'
#' @author Yi-An Chen and Sangeetha Srinivasan
#'
-#' @references Grinold, R. and Kahn, R. \emph{Active Portfolio Management},
+#' @references Grinold, R. and Kahn, R. (1999) Active Portfolio Management: A
+#' Quantitative Approach for Producing Superior Returns and Controlling Risk.
#' McGraw-Hill.
#'
-#' @seealso \code{\link{fitTsfm}}, \code{\link{fitSfm}}, \code{\link{fitFfm}}
+#' @seealso \code{\link{fitTsfm}}, \code{\link{fitSfm}}, \code{\link{fitFfm}}
+#' for the factor model fitting functions.
#'
+#' The \code{pafm} methods for generic functions:
+#' \code{\link{plot.pafm}}, \code{\link{print.pafm}} and
+#' \code{\link{summary.pafm}}.
+#'
#' @examples
#' data(managers)
#' fit <- fitTsfm(asset.names=colnames(managers[, (1:6)]),
@@ -41,8 +45,9 @@
paFm <- function(fit, ...) {
- if (class(fit)!="tsfm" & class(fit)!="ffm" & class(fit)!="sfm") {
- stop("Class has to be one of 'tsfm', 'ffm' or 'sfm'.")
+ # check input object validity
+ if (!inherits(fit, c("tsfm", "sfm", "ffm"))) {
+ stop("Invalid argument: fit should be of class 'tsfm', 'sfm' or 'ffm'.")
}
# TSFM chunk
@@ -52,18 +57,18 @@
# return attributed to factors
cum.attr.ret <- fit$beta
cum.spec.ret <- fit$alpha
- factorNames = fit$factor.names
- fundNames = fit$asset.names
+ factorNames <- fit$factor.names
+ fundNames <- fit$asset.names
attr.list <- list()
for (k in fundNames) {
- fit.lm = fit$asset.fit[[k]]
+ fit.lm <- fit$asset.fit[[k]]
## extract information from lm, lmRob or lars object
reg.xts <- na.omit(fit$data[, c(k, factorNames)])
dates <- as.Date(index(reg.xts))
- actual.xts = xts(fit.lm$model[1], dates)
+ actual.xts <- xts(fit.lm$model[1], dates)
# attributed returns
# active portfolio management p.512 17A.9
# top-down method
@@ -83,16 +88,16 @@
xts(as.matrix(fit.lm$model[i])%*%as.matrix(fit.lm$coef[i]),
dates)
cum.attr.ret[k, i] <- cum.ret -
- Return.cumulative(actual.xts - attr.ret.xts)
+ Return.cumulative(actual.xts-attr.ret.xts)
attr.ret.xts.all <- merge(attr.ret.xts.all, attr.ret.xts)
}
}
# specific returns
spec.ret.xts <- actual.xts -
- xts(as.matrix(fit.lm$model[, factorNames])%*%as.matrix(fit.lm$coef[-1]),
+ xts(as.matrix(fit.lm$model[,factorNames])%*%as.matrix(fit.lm$coef[-1]),
dates)
- cum.spec.ret[k,1] <- cum.ret - Return.cumulative(actual.xts - spec.ret.xts)
+ cum.spec.ret[k,1] <- cum.ret - Return.cumulative(actual.xts-spec.ret.xts)
attr.list[[k]] <- merge(attr.ret.xts.all, spec.ret.xts)
colnames(attr.list[[k]]) <- c(factorNames, "specific.returns")
}
@@ -155,8 +160,8 @@
# return attributed to factors
cum.attr.ret <- t(fit$loadings)
cum.spec.ret <- fit$r2
- factorNames = rownames(fit$loadings)
- fundNames = colnames(fit$loadings)
+ factorNames <- rownames(fit$loadings)
+ fundNames <- colnames(fit$loadings)
data <- checkData(fit$data)
# create list for attribution
attr.list <- list()
@@ -165,11 +170,11 @@
if ( dim(fit$asset.ret)[1] > dim(fit$asset.ret)[2] ) {
for (k in fundNames) {
- fit.lm = fit$asset.fit[[k]]
+ fit.lm <- fit$asset.fit[[k]]
## extract information from lm object
date <- index(data[, k])
# probably needs more general Date setting
- actual.xts = xts(fit.lm$model[1], as.Date(date))
+ actual.xts <- xts(fit.lm$model[1], as.Date(date))
# attributed returns
# active portfolio management p.512 17A.9
cum.ret <- Return.cumulative(actual.xts)
@@ -220,15 +225,16 @@
}
}
- ans = list(cum.ret.attr.f=cum.attr.ret, cum.spec.ret=cum.spec.ret,
+ ans <- list(cum.ret.attr.f=cum.attr.ret, cum.spec.ret=cum.spec.ret,
attr.list=attr.list)
- class(ans) = "pafm"
+ class(ans) <- "pafm"
return(ans)
}
# If benchmark is provided, active return attribution will be calculated.
# active returns = total returns - benchmark returns. Specifically,
-# \eqn{R_t^A = \sum_j b_{j}^A * f_{jt} + u_t^A},t=1..T, \eqn{b_{j}^A} is \emph{active exposure} to factor j
-# and \eqn{f_{jt}} is factor j. The active returns attributed to factor j is
-# \eqn{b_{j}^A * f_{jt}} specific returns is \eqn{u_t^A}
+# \eqn{R_t^A = \sum_j b_{j}^A * f_{jt} + u_t^A},t=1..T, \eqn{b_{j}^A} is
+# \emph{active exposure} to factor j and \eqn{f_{jt}} is factor j. The active
+# returns attributed to factor j is \eqn{b_{j}^A * f_{jt}} specific returns is
+# \eqn{u_t^A}
Modified: pkg/FactorAnalytics/R/plot.tsfm.r
===================================================================
--- pkg/FactorAnalytics/R/plot.tsfm.r 2014-08-05 01:32:33 UTC (rev 3497)
+++ pkg/FactorAnalytics/R/plot.tsfm.r 2014-08-05 10:32:43 UTC (rev 3498)
@@ -68,6 +68,9 @@
#' to suppress the legend.
#' @param las one of {0, 1, 2, 3} to set the direction of axis labels, same as
#' in \code{plot}. Default here is 1.
+#' @param horiz a logical value. If \code{FALSE}, the bars are drawn vertically
+#' with the first bar to the left. If \code{TRUE}, the bars are drawn
+#' horizontally with the first at the bottom. Default here is \code{TRUE}.
#' @param VaR.method a method for computing VaR; one of "modified", "gaussian",
#' "historical" or "kernel". VaR is computed using
#' \code{\link[PerformanceAnalytics]{VaR}}. Default is "historical".
@@ -91,9 +94,8 @@
#' \code{\link[graphics]{barplot}} and
#' \code{\link[corrplot]{corrplot}} for plotting methods used.
#'
-#' \code{\link{factorModelSDDecomposition}},
-#' \code{\link{factorModelEsDecomposition}},
-#' \code{\link{factorModelVaRDecomposition}} for factor model risk measures.
+#' \code{\link{fmSdDecomp}}, \code{\link{fmEsDecomp}},
+#' \code{\link{fmVaRDecomp}} for factor model risk measures.
#'
#' @examples
#'
@@ -105,7 +107,7 @@
#'
#' # plot the factor betas of 1st 4 assets fitted above.
#' plot(fit.macro, max.show=4, which.plot.group=2, loop=FALSE)
-#' # plot the factor model return correlation, order = hierarchical clustering
+#' # plot factor model return correlation; angular order of the eigenvectors
#' plot(fit.macro, which.plot.group=7, loop=FALSE,
#' order="AOE", method="ellipse", tl.pos = "d")
#'
@@ -121,7 +123,7 @@
plot.tsfm <- function(x, which.plot.group=NULL, max.show=6, plot.single=FALSE,
asset.name, which.plot.single=NULL, colorset=(1:12),
- legend.loc="topleft", las=1,
+ legend.loc="topleft", las=1, horiz=TRUE,
VaR.method="historical", loop=TRUE, ...) {
if (plot.single==TRUE) {
@@ -311,10 +313,10 @@
switch(which.plot.group,
"1L" = {
## Factor model coefficients: Alpha
- # ylab="Intercept estimate"
+ # xlab="Intercept estimate", ylab="Assets"
barplot(coef(x)[,1], main="Factor model Alpha (Intercept)",
- xlab="Assets", col="darkblue", las=las, ...)
- abline(h=0, lwd=1, lty=1, col=1)
+ col="darkblue", las=las, horiz=horiz, ...)
+ abline(v=0, lwd=1, lty=1, col=1)
},
"2L" = {
## Factor model coefficients: Betas
@@ -326,10 +328,11 @@
}
par(mfrow=c(ceiling(k/2),2))
for (i in 2:(k+1)) {
- main=paste("Factor Betas:", colnames(coef(x))[i])
- barplot(coef(x)[,i], main=main, col="darkblue", xlab="Assets",
- ylab="Coefficient estimate", las=las, ...)
- abline(h=0, lwd=1, lty=1, col=1)
+ main=paste(colnames(coef(x))[i], "factor Betas")
+ # xlab="Beta estimate", ylab="Assets"
+ barplot(coef(x)[,i], main=main, col="darkblue", las=las,
+ horiz=horiz, ...)
+ abline(v=0, lwd=1, lty=1, col=1)
}
par(mfrow=c(1,1))
},
@@ -337,8 +340,8 @@
## Actual and Fitted asset returns
n <- length(x$asset.names)
if (n > max.show) {
- cat(paste("Displaying only the first", max.show,"assets, since the
- number of assets > 'max.show' =", max.show))
+ cat(paste("Displaying only the first", max.show,
+ "assets, since the number of assets > 'max.show'"))
n <- max.show
}
par(mfrow=c(ceiling(n/2),2))
@@ -354,17 +357,17 @@
},
"4L" ={
## R-squared
+ # ylab="Assets", xlab="R-squared"
barplot(x$r2, main="R-squared values for factor model fits",
- xlab="Assets", ylab="R-squared", col="darkblue",
- las=las, ...)
- abline(h=0, lwd=1, lty=1, col=1)
+ col="darkblue", las=las, horiz=horiz, ...)
+ abline(v=0, lwd=1, lty=1, col=1)
},
"5L" = {
## Residual Volatility
- barplot(x$resid.sd, xlab="Assets", ylab="Residual volatility",
- main="Residual volatility for factor model fits",
- col="darkblue", las=las, ...)
- abline(h=0, lwd=1, lty=1, col=1)
+ # ylab="Assets", xlab="Residual volatility"
+ barplot(x$resid.sd, col="darkblue", las=las, horiz=horiz,
+ main="Residual volatility for factor model fits", ...)
+ abline(v=0, lwd=1, lty=1, col=1)
},
"6L" = {
## Factor Model Residual Correlation
@@ -380,24 +383,24 @@
## Factor Contribution to SD
cSd.fm <- fmSdDecomp(x)$cSd
barplot(t(cSd.fm), main="Factor Contributions to SD",
- xlab="Assets", legend.text=T, args.legend=legend.loc,
- col=colorset, ...)
+ legend.text=T, args.legend=legend.loc, col=colorset,
+ horiz=horiz, ...)
mtext("(pairwise complete obs)", line=0.5)
},
"9L"={
## Factor Contribution to ES
- cES.fm <- fmVaRDecomp(x)$cES
+ cES.fm <- fmEsDecomp(x)$cES
barplot(t(cES.fm), main="Factor Contributions to ES",
- xlab="Assets", legend.text=T, args.legend=legend.loc,
- col=colorset, ...)
+ legend.text=T, args.legend=legend.loc, col=colorset,
+ horiz=horiz, ...)
mtext("(pairwise complete obs)", line=0.5)
},
"10L" ={
## Factor Contribution to VaR
cVaR.fm <- fmVaRDecomp(x)$cVaR
barplot(t(cVaR.fm), main="Factor Contributions to VaR",
- xlab="Assets", legend.text=T, args.legend=legend.loc,
- col=colorset, ...)
+ legend.text=T, args.legend=legend.loc, col=colorset,
+ horiz=horiz, ...)
mtext("(pairwise complete obs)", line=0.5)
},
invisible()
Modified: pkg/FactorAnalytics/R/summary.tsfm.r
===================================================================
--- pkg/FactorAnalytics/R/summary.tsfm.r 2014-08-05 01:32:33 UTC (rev 3497)
+++ pkg/FactorAnalytics/R/summary.tsfm.r 2014-08-05 10:32:43 UTC (rev 3498)
@@ -9,8 +9,8 @@
#' heteroskedasticity-consistent (HC) or
#' heteroskedasticity-autocorrelation-consistent (HAC) standard errors and
#' t-statistics using \code{\link[lmtest]{coeftest}}. This option is meaningful
-#' only if \code{fit.method = "OLS" or "DLS"}. This option is currently not
-#' available for \code{variable.selection = "lar" or "lasso"}.
+#' only if \code{fit.method = "OLS" or "DLS"}. HC/HAC errors are currently not
+#' available for \code{variable.selection = "lars"}.
#'
#' @param object an object of class \code{tsfm} returned by \code{fitTsfm}.
#' @param se.type one of "Default", "HC" or "HAC"; option for computing
@@ -61,6 +61,7 @@
if (!inherits(object, "tsfm")) {
stop("Invalid 'tsfm' object")
}
+ # note: fit.method=NULL for "lars" objects
if (!(object$fit.method %in% c("OLS","DLS")) && se.type!="Default") {
stop("Invalid argument: HC/HAC standard errors are applicable only if
fit.method = 'OLS' or 'DLS'")
Modified: pkg/FactorAnalytics/man/CommonFactors.Rd
===================================================================
--- pkg/FactorAnalytics/man/CommonFactors.Rd 2014-08-05 01:32:33 UTC (rev 3497)
+++ pkg/FactorAnalytics/man/CommonFactors.Rd 2014-08-05 10:32:43 UTC (rev 3498)
@@ -1,39 +1,39 @@
-\name{CommonFactors}
-\alias{CommonFactors}
-\alias{factors.M}
-\alias{factors.Q}
-\docType{data}
-\title{
-Factor set of several commonly used factors
-}
-\description{
-Collection of common factors as both monthly and quarterly time series
-\itemize{
-\item SP500: S&P 500 composite index returns. (Yahoo)
-\item GS10TR: US Treasury 10y yields total returns from the yeild of the 10 year constant maturity. (FRED)
-\item USD.Index: Trade Weighted U.S. Dollar Index: Major Currencies - TWEXMMTH. (FRED)
-\item Term.Spread: Yield spread of Merrill Lynch High-Yield Corporate Master II Index minus 10-year Treasury. (FRED)
-\item TED.Spread: 3-Month Treasury Bill: Secondary Market Rate(TB3MS) - 3-Month Eurodollar Deposit Rate (MED3). (FRED)
-\item dVIX: First difference of the end-of-month value of the CBOE Volatility Index (VIX). (Yahoo)
-\item OILPRICE: Monthly returns of spot price of West Texas Intermediate. (FRED)
-\item TB3MS: 3-Month Treasury Bill Secondary Market Rate (TB3MS). (FRED)
-}
-
-}
-\usage{data(CommonFactors)}
-\format{
- xts time series object
- \describe{
- \item{\code{factor.M}}{Jan-1997 through May-2014}
- \item{\code{factor.Q}}{Q1-1997 through Q1-2014}
- }
-}
-\source{
-\itemize{
-\item Federal Reserve Economic Data (FRED): \url{http://research.stlouisfed.org/fred2/}
-\item Yahoo Finance: \url{http://finance.yahoo.com/}
-}
-}
-
-
-
+\name{CommonFactors}
+\alias{CommonFactors}
+\alias{factors.M}
+\alias{factors.Q}
+\docType{data}
+\title{
+Factor set of several commonly used factors
+}
+\description{
+Collection of common factors as both monthly and quarterly time series
+\itemize{
+\item SP500: S&P 500 composite index returns. (Yahoo)
+\item GS10TR: US Treasury 10y yields total returns from the yeild of the 10 year constant maturity. (FRED)
+\item USD.Index: Trade Weighted U.S. Dollar Index: Major Currencies - TWEXMMTH. (FRED)
+\item Term.Spread: Yield spread of Merrill Lynch High-Yield Corporate Master II Index minus 10-year Treasury. (FRED)
+\item TED.Spread: 3-Month Treasury Bill: Secondary Market Rate(TB3MS) - 3-Month Eurodollar Deposit Rate (MED3). (FRED)
+\item dVIX: First difference of the end-of-month value of the CBOE Volatility Index (VIX). (Yahoo)
+\item OILPRICE: Monthly returns of spot price of West Texas Intermediate. (FRED)
+\item TB3MS: 3-Month Treasury Bill Secondary Market Rate (TB3MS). (FRED)
+}
+
+}
+\usage{data(CommonFactors)}
+\format{
+ xts time series object
+ \describe{
+ \item{\code{factors.M}}{Jan-1997 through May-2014}
+ \item{\code{factors.Q}}{Q1-1997 through Q1-2014}
+ }
+}
+\source{
+\itemize{
+\item Federal Reserve Economic Data (FRED): \url{http://research.stlouisfed.org/fred2/}
+\item Yahoo Finance: \url{http://finance.yahoo.com/}
+}
+}
+
+
+
Modified: pkg/FactorAnalytics/man/fitTsfm.Rd
===================================================================
--- pkg/FactorAnalytics/man/fitTsfm.Rd 2014-08-05 01:32:33 UTC (rev 3497)
+++ pkg/FactorAnalytics/man/fitTsfm.Rd 2014-08-05 10:32:43 UTC (rev 3498)
@@ -52,8 +52,6 @@
\item{object}{a fit object of class \code{tsfm} which is returned by
\code{fitTsfm}}
-
-\item{...}{further arguments passed to or from other methods}
}
\value{
fitTsfm returns an object of class \code{tsfm} for which
Modified: pkg/FactorAnalytics/man/fitTsfm.control.Rd
===================================================================
--- pkg/FactorAnalytics/man/fitTsfm.control.Rd 2014-08-05 01:32:33 UTC (rev 3497)
+++ pkg/FactorAnalytics/man/fitTsfm.control.Rd 2014-08-05 10:32:43 UTC (rev 3498)
@@ -157,11 +157,9 @@
Sangeetha Srinivasan
}
\references{
-\enumerate{
-\item Efron, Bradley, Trevor Hastie, Iain Johnstone, and Robert Tibshirani.
-"Least angle regression." The Annals of statistics 32, no.2 (2004): 407-499.
+Efron, B., Hastie, T., Johnstone, I., & Tibshirani, R. (2004). Least angle
+regression. The Annals of statistics, 32(2), 407-499.
}
-}
\seealso{
\code{\link{fitTsfm}}, \code{\link[stats]{lm}},
\code{\link[robust]{lmRob}}, \code{\link[stats]{step}},
Modified: pkg/FactorAnalytics/man/paFm.Rd
===================================================================
--- pkg/FactorAnalytics/man/paFm.Rd 2014-08-05 01:32:33 UTC (rev 3497)
+++ pkg/FactorAnalytics/man/paFm.Rd 2014-08-05 10:32:43 UTC (rev 3498)
@@ -12,25 +12,23 @@
}
\value{
The returned object is of class \code{"pafm"} containing
-\describe{
-\item{cum.ret.attr.f}{N X J matrix of cumulative return attributed to
+\item{cum.ret.attr.f}{N X K matrix of cumulative return attributed to
factors.}
-\item{cum.spec.ret}{1 x N vector of cumulative specific returns.}
+\item{cum.spec.ret}{length-N vector of cumulative specific returns.}
\item{attr.list}{list of time series of attributed returns for every
portfolio.}
}
-}
\description{
Decompose total returns into returns attributed to factors and
-specific returns. An object of class \code{"pafm"} is generated and generic
-functions such as \code{plot}, \code{summary} and \code{print} can be used.
+specific returns. An object of class \code{"pafm"} is generated, with
+methods for generic functions \code{plot}, \code{summary} and \code{print}.
}
\details{
Total returns can be decomposed into returns attributed to factors
-and specific returns. \cr \eqn{R_t = \sum b_j * f_jt + u_t,t=1...T} \cr
-\code{b_j} is exposure to factor j and \code{f_jt} is factor j.
-The returns attributed to factor j is \code{b_j * f_jt} and specific
-returns is \code{u_t}.
+and specific returns. \cr \eqn{R_t = \sum b_k * f_kt + u_t, t=1...T} \cr
+\code{b_k} is exposure to factor k and \code{f_kt} is factor k's return at
+time t. The return attributed to factor k is \code{b_k * f_kt} and specific
+return is \code{u_t}.
}
\examples{
data(managers)
@@ -43,10 +41,16 @@
Yi-An Chen and Sangeetha Srinivasan
}
\references{
-Grinold, R. and Kahn, R. \emph{Active Portfolio Management},
+Grinold, R. and Kahn, R. (1999) Active Portfolio Management: A
+Quantitative Approach for Producing Superior Returns and Controlling Risk.
McGraw-Hill.
}
\seealso{
\code{\link{fitTsfm}}, \code{\link{fitSfm}}, \code{\link{fitFfm}}
+for the factor model fitting functions.
+
+The \code{pafm} methods for generic functions:
+\code{\link{plot.pafm}}, \code{\link{print.pafm}} and
+\code{\link{summary.pafm}}.
}
Modified: pkg/FactorAnalytics/man/plot.tsfm.Rd
===================================================================
--- pkg/FactorAnalytics/man/plot.tsfm.Rd 2014-08-05 01:32:33 UTC (rev 3497)
+++ pkg/FactorAnalytics/man/plot.tsfm.Rd 2014-08-05 10:32:43 UTC (rev 3498)
@@ -5,7 +5,7 @@
\usage{
\method{plot}{tsfm}(x, which.plot.group = NULL, max.show = 6,
plot.single = FALSE, asset.name, which.plot.single = NULL,
- colorset = (1:12), legend.loc = "topleft", las = 1,
+ colorset = (1:12), legend.loc = "topleft", las = 1, horiz = TRUE,
VaR.method = "historical", loop = TRUE, ...)
}
\arguments{
@@ -63,6 +63,10 @@
\item{las}{one of {0, 1, 2, 3} to set the direction of axis labels, same as
in \code{plot}. Default here is 1.}
+\item{horiz}{a logical value. If \code{FALSE}, the bars are drawn vertically
+with the first bar to the left. If \code{TRUE}, the bars are drawn
+horizontally with the first at the bottom. Default here is \code{TRUE}.}
+
\item{VaR.method}{a method for computing VaR; one of "modified", "gaussian",
"historical" or "kernel". VaR is computed using
\code{\link[PerformanceAnalytics]{VaR}}. Default is "historical".}
@@ -105,7 +109,7 @@
# plot the factor betas of 1st 4 assets fitted above.
plot(fit.macro, max.show=4, which.plot.group=2, loop=FALSE)
-# plot the factor model return correlation, order = hierarchical clustering
+# plot factor model return correlation; angular order of the eigenvectors
plot(fit.macro, which.plot.group=7, loop=FALSE,
order="AOE", method="ellipse", tl.pos = "d")
@@ -134,8 +138,7 @@
\code{\link[graphics]{barplot}} and
\code{\link[corrplot]{corrplot}} for plotting methods used.
-\code{\link{factorModelSDDecomposition}},
-\code{\link{factorModelEsDecomposition}},
-\code{\link{factorModelVaRDecomposition}} for factor model risk measures.
+\code{\link{fmSdDecomp}}, \code{\link{fmEsDecomp}},
+\code{\link{fmVaRDecomp}} for factor model risk measures.
}
Modified: pkg/FactorAnalytics/man/summary.tsfm.Rd
===================================================================
--- pkg/FactorAnalytics/man/summary.tsfm.Rd 2014-08-05 01:32:33 UTC (rev 3497)
+++ pkg/FactorAnalytics/man/summary.tsfm.Rd 2014-08-05 10:32:43 UTC (rev 3498)
@@ -44,8 +44,8 @@
heteroskedasticity-consistent (HC) or
heteroskedasticity-autocorrelation-consistent (HAC) standard errors and
t-statistics using \code{\link[lmtest]{coeftest}}. This option is meaningful
-only if \code{fit.method = "OLS" or "DLS"}. This option is currently not
-available for \code{variable.selection = "lar" or "lasso"}.
+only if \code{fit.method = "OLS" or "DLS"}. HC/HAC errors are currently not
+available for \code{variable.selection = "lars"}.
}
\note{
For a more detailed printed summary for each asset, refer to
More information about the Returnanalytics-commits
mailing list