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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Jan 17 04:13:54 CET 2016


Author: pragnya
Date: 2016-01-17 04:13:53 +0100 (Sun, 17 Jan 2016)
New Revision: 4006

Modified:
   pkg/FactorAnalytics/DESCRIPTION
   pkg/FactorAnalytics/NAMESPACE
   pkg/FactorAnalytics/R/fitFfm.R
   pkg/FactorAnalytics/R/plot.tsfm.r
   pkg/FactorAnalytics/man/CornishFisher.Rd
   pkg/FactorAnalytics/man/fitFfm.Rd
   pkg/FactorAnalytics/man/fitSfm.Rd
   pkg/FactorAnalytics/man/fitTsfm.Rd
   pkg/FactorAnalytics/man/fitTsfm.control.Rd
   pkg/FactorAnalytics/man/fitTsfmLagBeta.Rd
   pkg/FactorAnalytics/man/fitTsfmMT.Rd
   pkg/FactorAnalytics/man/fitTsfmUpDn.Rd
   pkg/FactorAnalytics/man/fmCov.Rd
   pkg/FactorAnalytics/man/fmEsDecomp.Rd
   pkg/FactorAnalytics/man/fmSdDecomp.Rd
   pkg/FactorAnalytics/man/fmVaRDecomp.Rd
   pkg/FactorAnalytics/man/fmmc.Rd
   pkg/FactorAnalytics/man/fmmc.estimate.se.Rd
   pkg/FactorAnalytics/man/fmmcSemiParam.Rd
   pkg/FactorAnalytics/man/paFm.Rd
   pkg/FactorAnalytics/man/plot.pafm.Rd
   pkg/FactorAnalytics/man/plot.sfm.Rd
   pkg/FactorAnalytics/man/plot.tsfm.Rd
   pkg/FactorAnalytics/man/plot.tsfmUpDn.Rd
   pkg/FactorAnalytics/man/predict.sfm.Rd
   pkg/FactorAnalytics/man/predict.tsfm.Rd
   pkg/FactorAnalytics/man/predict.tsfmUpDn.Rd
   pkg/FactorAnalytics/man/print.ffm.Rd
   pkg/FactorAnalytics/man/print.pafm.Rd
   pkg/FactorAnalytics/man/print.sfm.Rd
   pkg/FactorAnalytics/man/print.tsfm.Rd
   pkg/FactorAnalytics/man/print.tsfmUpDn.Rd
   pkg/FactorAnalytics/man/summary.pafm.Rd
   pkg/FactorAnalytics/man/summary.sfm.Rd
   pkg/FactorAnalytics/man/summary.tsfm.Rd
   pkg/FactorAnalytics/man/summary.tsfmUpDn.Rd
Log:
Fixed bugs in plot.tsfm and fitFfm. Updated documentation (Roxygen upgrade)

Modified: pkg/FactorAnalytics/DESCRIPTION
===================================================================
--- pkg/FactorAnalytics/DESCRIPTION	2015-12-09 18:46:21 UTC (rev 4005)
+++ pkg/FactorAnalytics/DESCRIPTION	2016-01-17 03:13:53 UTC (rev 4006)
@@ -1,15 +1,15 @@
 Package: factorAnalytics
 Type: Package
 Title: Factor Analytics
-Version: 2.0.28
-Date: 2015-09-21
+Version: 2.0.29
+Date: 2016-01-16
 Author: Eric Zivot, Sangeetha Srinivasan and Yi-An Chen
 Maintainer: Sangeetha Srinivasan <sangee at uw.edu>
-Description: Linear factor model fitting for asset returns (three major types- 
-    time series, fundamental and statistical factor models); related risk 
-    (volatility, VaR and ES) and performance attribution (factor-contributed vs 
-    idiosyncratic returns); tabular displays of risk and performance reports; 
-    factor model Monte Carlo, single and multiple imputation methods for 
+Description: Linear factor model fitting for asset returns (three major types-
+    time series, fundamental and statistical factor models); related risk
+    (volatility, VaR and ES) and performance attribution (factor-contributed vs
+    idiosyncratic returns); tabular displays of risk and performance reports;
+    factor model Monte Carlo, single and multiple imputation methods for
     simulating returns and backfilling unequal histories.
 License: GPL-2
 Depends:
@@ -17,13 +17,13 @@
     xts (>= 0.9),
     foreach (>= 1.4),
     rrcov (>= 1.3)
-Imports: 
+Imports:
     PerformanceAnalytics(>= 1.4),
     zoo,
     corrplot,
     robustbase,
-    robust, 
-    leaps, 
+    robust,
+    leaps,
     lars,
     strucchange,
     lmtest,
@@ -42,3 +42,4 @@
 LazyLoad: yes
 LazyDataCompression: xz
 URL: http://r-forge.r-project.org/projects/returnanalytics/
+RoxygenNote: 5.0.1

Modified: pkg/FactorAnalytics/NAMESPACE
===================================================================
--- pkg/FactorAnalytics/NAMESPACE	2015-12-09 18:46:21 UTC (rev 4005)
+++ pkg/FactorAnalytics/NAMESPACE	2016-01-17 03:13:53 UTC (rev 4006)
@@ -1,4 +1,4 @@
-# Generated by roxygen2 (4.1.1): do not edit by hand
+# Generated by roxygen2: do not edit by hand
 
 S3method(coef,ffm)
 S3method(coef,sfm)

Modified: pkg/FactorAnalytics/R/fitFfm.R
===================================================================
--- pkg/FactorAnalytics/R/fitFfm.R	2015-12-09 18:46:21 UTC (rev 4005)
+++ pkg/FactorAnalytics/R/fitFfm.R	2016-01-17 03:13:53 UTC (rev 4006)
@@ -40,7 +40,8 @@
 #' in S-PLUS by a number of University of Washington Ph.D. students:
 #' Christopher Green, Eric Aldrich, and Yindeng Jiang. Guy Yollin ported the
 #' function to R and Yi-An Chen modified that code. Sangeetha Srinivasan
-#' re-factored, updated and expanded the functionalities and S3 methods.
+#' re-factored, tested, corrected and expanded the functionalities and S3 
+#' methods.
 #'
 #' @param data data.frame of the balanced panel data containing the variables 
 #' \code{asset.var}, \code{ret.var}, \code{exposure.vars}, \code{date.var} and 
@@ -76,9 +77,9 @@
 #' 
 #' An object of class \code{"ffm"} is a list containing the following 
 #' components:
-#' \item{asset.fit}{list of fitted objects for each asset. Each object is of 
-#' class \code{lm} if \code{fit.method="LS" or "WLS"}, or, class \code{lmRob} 
-#' if \code{fit.method="Rob" or "W-Rob"}.}
+#' \item{factor.fit}{list of fitted objects for each time period. Each object 
+#' is of class \code{lm} if \code{fit.method="LS" or "WLS"}, or, class 
+#' \code{lmRob} if \code{fit.method="Rob" or "W-Rob"}.}
 #' \item{beta}{N x K matrix of factor exposures for the last time period.}
 #' \item{factor.returns}{xts object of K-factor returns (including intercept).}
 #' \item{residuals}{xts object of residuals for N-assets.}
@@ -87,9 +88,6 @@
 #' \item{resid.cov}{N x N covariance matrix of residuals.}
 #' \item{return.cov}{N x N return covariance estimated by the factor model, 
 #' using the factor exposures from the last time period.}
-#' \item{factor.corr}{N x N correlation matrix of the factor returns.}
-#' \item{resid.corr}{N x N correlation matrix of residuals.}
-#' \item{return.corr}{N x N correlation matrix of asset returns.}
 #' \item{resid.var}{length-N vector of residual variances.}
 #' \item{call}{the matched function call.}
 #' \item{data}{data frame object as input.}
@@ -105,7 +103,7 @@
 #' Where N is the number of assets, K is the number of factors (including the 
 #' intercept or dummy variables) and T is the number of unique time periods.
 #'
-#' @author Guy Yollin, Yi-An Chen and Sangeetha Srinivasan
+#' @author Sangeetha Srinivasan, Guy Yollin and Yi-An Chen
 #'
 #' @references
 #' Menchero, J. (2010). The Characteristics of Factor Portfolios. Journal of
@@ -192,6 +190,10 @@
     stop("Invalid args: control parameter 'z.score' must be logical")
   }
   
+  # initialize to avoid R CMD check's NOTE: no visible binding for global var
+  DATE=NULL 
+  W=NULL
+  
   # ensure dates are in required format
   data[[date.var]] <- as.Date(data[[date.var]])
   # extract unique time periods from data
@@ -268,7 +270,7 @@
       resid.var <- apply(sapply(reg.list, residuals), 1, var)
     }
     # add column of weights to data replicating resid.var for each period
-    data <- cbind(data, W=resid.var)
+    data <- cbind(data, W=1/resid.var)
   }
   
   # estimate factor returns using WLS or weighted-Robust regression
@@ -277,13 +279,13 @@
     reg.list <- by(data=data, INDICES=data[[date.var]], 
                    FUN=function(x) {
                      lm(data=x, formula=fm.formula, contrasts=contrasts.list, 
-                        na.action=na.fail, weights=~W)
+                        na.action=na.fail, weights=W)
                    })
   } else if (fit.method=="W-Rob") {
     reg.list <- by(data=data, INDICES=data[[date.var]], 
                    FUN=function(x) {
                      lmRob(data=x, formula=fm.formula, contrasts=contrasts.list, 
-                           na.action=na.fail, weights=~W, 
+                           na.action=na.fail, weights=W, 
                            mxr=200, mxf=200, mxs=200)
                    })
   }
@@ -300,7 +302,6 @@
   K <- length(factor.names)
   
   # exposure matrix B or beta for the last time period - N x K
-  DATE=NULL # to avoid R CMD check's NOTE: no visible binding for global var
   beta <- model.matrix(fm.formula, data=subset(data, DATE==time.periods[TP]))
   rownames(beta) <- asset.names
   
@@ -353,17 +354,11 @@
   # return covariance estimated by the factor model
   return.cov <-  beta %*% factor.cov %*% t(beta) + resid.cov
   
-  # factor, residual and return correlations
-  factor.corr <- cov2cor(factor.cov)
-  resid.corr <- cov2cor(resid.cov)
-  return.corr <- cov2cor(return.cov)
-  
   # create list of return values.
-  result <- list(asset.fit=reg.list, beta=beta, factor.returns=factor.returns, 
+  result <- list(factor.fit=reg.list, beta=beta, factor.returns=factor.returns, 
                  residuals=residuals, r2=r2, factor.cov=factor.cov, 
                  resid.cov=resid.cov, return.cov=return.cov, 
-                 factor.corr=factor.corr, resid.corr=resid.corr, 
-                 return.corr=return.corr, resid.var=resid.var, call=this.call, 
+                 resid.var=resid.var, call=this.call, 
                  data=data, date.var=date.var, ret.var=ret.var, 
                  asset.var=asset.var, exposure.vars=exposure.vars, 
                  weight.var=weight.var, fit.method=fit.method, 

Modified: pkg/FactorAnalytics/R/plot.tsfm.r
===================================================================
--- pkg/FactorAnalytics/R/plot.tsfm.r	2015-12-09 18:46:21 UTC (rev 4005)
+++ pkg/FactorAnalytics/R/plot.tsfm.r	2016-01-17 03:13:53 UTC (rev 4006)
@@ -396,6 +396,12 @@
     if (!(all(f.sub %in% x$factor.names)) && !(all(f.sub %in% 1:k))) {
       stop("Invalid argument: f.sub is not a valid subset of factor names.") 
     }
+    if (is.character(f.sub)) {
+      f.sub <- which(f.sub %in% x$factor.names)
+    }
+    if (is.character(a.sub)) {
+      f.sub <- which(x$asset.names==a.sub)
+    }
     
     # plot selection
     repeat {

Modified: pkg/FactorAnalytics/man/CornishFisher.Rd
===================================================================
--- pkg/FactorAnalytics/man/CornishFisher.Rd	2015-12-09 18:46:21 UTC (rev 4005)
+++ pkg/FactorAnalytics/man/CornishFisher.Rd	2016-01-17 03:13:53 UTC (rev 4006)
@@ -1,4 +1,4 @@
-% Generated by roxygen2 (4.1.1): do not edit by hand
+% Generated by roxygen2: do not edit by hand
 % Please edit documentation in R/CornishFisher.R
 \name{dCornishFisher}
 \alias{Cornish-Fisher}
@@ -17,9 +17,9 @@
 rCornishFisher(n, sigma, skew, ekurt, dp = NULL, seed = NULL)
 }
 \arguments{
-\item{x,q}{vector of standardized quantiles.}
+\item{x, q}{vector of standardized quantiles.}
 
-\item{n}{scalar; number of simulated values in random simulation, sample
+\item{n}{scalar; number of simulated values in random simulation, sample 
 length in density, distribution and quantile functions.}
 
 \item{skew}{scalar; skewness.}
@@ -30,38 +30,38 @@
 
 \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
+\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{
-\code{dCornishFisher} gives the density, \code{pCornishFisher} gives the
-distribution function, \code{qCornishFisher} gives the quantile function,
+\code{dCornishFisher} gives the density, \code{pCornishFisher} gives the 
+distribution function, \code{qCornishFisher} gives the quantile function, 
 and \code{rCornishFisher} generates \code{n} random simulations.
 }
 \description{
-Density, distribution function, quantile function and random
+Density, distribution function, quantile function and random 
 generation using Cornish-Fisher approximation.
 }
 \details{
 CDF(q) = Pr(sqrt(n)*(x_bar-mu)/sigma < q)
-\code{dCornishFisher} Computes Cornish-Fisher density from two term Edgeworth
+\code{dCornishFisher} Computes Cornish-Fisher density from two term Edgeworth 
 expansion given mean, standard deviation, skewness and excess kurtosis.
-\code{pCornishFisher} Computes Cornish-Fisher CDF from two term Edgeworth
+\code{pCornishFisher} Computes Cornish-Fisher CDF from two term Edgeworth 
 expansion given mean, standard deviation, skewness and excess kurtosis.
-\code{qCornishFisher} Computes Cornish-Fisher quantiles from two term
-Edgeworth expansion given mean, standard deviation, skewness and excess
+\code{qCornishFisher} Computes Cornish-Fisher quantiles from two term 
+Edgeworth expansion given mean, standard deviation, skewness and excess 
 kurtosis.
-\code{rCornishFisher} simulates observations based on Cornish-Fisher quantile
+\code{rCornishFisher} simulates observations based on Cornish-Fisher quantile 
 expansion given mean, standard deviation, skewness and excess kurtosis.
 }
 \examples{
 \dontrun{
 # generate 1000 observation from Cornish-Fisher distribution
 rc <- rCornishFisher(1000,1,0,5)
-hist(rc, breaks=100, freq=FALSE,
+hist(rc, breaks=100, freq=FALSE, 
      main="simulation of Cornish Fisher Distribution", xlim=c(-10,10))
 lines(seq(-10,10,0.1), dnorm(seq(-10,10,0.1), mean=0, sd=1), col=2)
 # compare with standard normal curve
@@ -77,14 +77,15 @@
 # use edgeworth expansion
 pCornishFisher(q, n=5, skew=2, ekurt=6)
 }
+
 }
 \author{
 Eric Zivot and Yi-An Chen.
 }
 \references{
-DasGupta, A. (2008). Asymptotic theory of statistics and probability.
+DasGupta, A. (2008). Asymptotic theory of statistics and probability. 
 Springer.
-Severini, T. A., (2000). Likelihood Methods in Statistics. Oxford University
+Severini, T. A., (2000). Likelihood Methods in Statistics. Oxford University 
 Press.
 }
 

Modified: pkg/FactorAnalytics/man/fitFfm.Rd
===================================================================
--- pkg/FactorAnalytics/man/fitFfm.Rd	2015-12-09 18:46:21 UTC (rev 4005)
+++ pkg/FactorAnalytics/man/fitFfm.Rd	2016-01-17 03:13:53 UTC (rev 4006)
@@ -1,4 +1,4 @@
-% Generated by roxygen2 (4.1.1): do not edit by hand
+% Generated by roxygen2: do not edit by hand
 % Please edit documentation in R/fitFfm.R
 \name{fitFfm}
 \alias{coef.ffm}
@@ -18,68 +18,65 @@
 \method{residuals}{ffm}(object, ...)
 }
 \arguments{
-\item{data}{data.frame of the balanced panel data containing the variables
-\code{asset.var}, \code{ret.var}, \code{exposure.vars}, \code{date.var} and
+\item{data}{data.frame of the balanced panel data containing the variables 
+\code{asset.var}, \code{ret.var}, \code{exposure.vars}, \code{date.var} and 
 optionally, \code{weight.var}.}
 
 \item{asset.var}{character; name of the variable for asset names.}
 
 \item{ret.var}{character; name of the variable for asset returns.}
 
-\item{date.var}{character; name of the variable containing the dates
+\item{date.var}{character; name of the variable containing the dates 
 coercible to class \code{Date}.}
 
-\item{exposure.vars}{vector; names of the variables containing the
+\item{exposure.vars}{vector; names of the variables containing the 
 fundamental factor exposures.}
 
-\item{weight.var}{character; name of the variable containing the weights
-used when standarizing style factor exposures. Default is \code{NULL}. See
+\item{weight.var}{character; name of the variable containing the weights 
+used when standarizing style factor exposures. Default is \code{NULL}. See 
 Details.}
 
-\item{fit.method}{method for estimating factor returns; one of "LS", "WLS"
+\item{fit.method}{method for estimating factor returns; one of "LS", "WLS" 
 "Rob" or "W-Rob". See details. Default is "LS".}
 
-\item{rob.stats}{logical; If \code{TRUE}, robust estimates of covariance,
-correlation, location and univariate scale are computed as appropriate (see
+\item{rob.stats}{logical; If \code{TRUE}, robust estimates of covariance, 
+correlation, location and univariate scale are computed as appropriate (see 
 Details). Default is \code{FALSE}.}
 
-\item{full.resid.cov}{logical; If \code{TRUE}, a full residual covariance
-matrix is estimated. Otherwise, a diagonal residual covariance matrix is
+\item{full.resid.cov}{logical; If \code{TRUE}, a full residual covariance 
+matrix is estimated. Otherwise, a diagonal residual covariance matrix is 
 estimated. Default is \code{FALSE}.}
 
-\item{z.score}{logical; If \code{TRUE}, style exposures will be converted to
+\item{z.score}{logical; If \code{TRUE}, style exposures will be converted to 
 z-scores; weights given by \code{weight.var}. Default is \code{FALSE}.}
 
 \item{...}{potentially further arguments passed.}
 
-\item{object}{a fit object of class \code{ffm} which is returned by
+\item{object}{a fit object of class \code{ffm} which is returned by 
 \code{fitFfm}}
 }
 \value{
-\code{fitFfm} returns an object of class \code{"ffm"} for which
-\code{print}, \code{plot}, \code{predict} and \code{summary} methods exist.
+\code{fitFfm} returns an object of class \code{"ffm"} for which 
+\code{print}, \code{plot}, \code{predict} and \code{summary} methods exist. 
 
-The generic accessor functions \code{coef}, \code{fitted} and
-\code{residuals} extract various useful features of the fit object.
-Additionally, \code{fmCov} computes the covariance matrix for asset returns
+The generic accessor functions \code{coef}, \code{fitted} and 
+\code{residuals} extract various useful features of the fit object. 
+Additionally, \code{fmCov} computes the covariance matrix for asset returns 
 based on the fitted factor model.
 
-An object of class \code{"ffm"} is a list containing the following
+An object of class \code{"ffm"} is a list containing the following 
 components:
-\item{asset.fit}{list of fitted objects for each asset. Each object is of
-class \code{lm} if \code{fit.method="LS" or "WLS"}, or, class \code{lmRob}
-if \code{fit.method="Rob" or "W-Rob"}.}
+\item{factor.fit}{list of fitted objects for each time period. Each object 
+is of class \code{lm} if \code{fit.method="LS" or "WLS"}, or, class 
+\code{lmRob} if \code{fit.method="Rob" or "W-Rob"}.}
 \item{beta}{N x K matrix of factor exposures for the last time period.}
 \item{factor.returns}{xts object of K-factor returns (including intercept).}
 \item{residuals}{xts object of residuals for N-assets.}
 \item{r2}{length-T vector of R-squared values.}
 \item{factor.cov}{N x N covariance matrix of the factor returns.}
 \item{resid.cov}{N x N covariance matrix of residuals.}
-\item{return.cov}{N x N return covariance estimated by the factor model,
+\item{return.cov}{N x N return covariance estimated by the factor model, 
 using the factor exposures from the last time period.}
-\item{factor.corr}{N x N correlation matrix of the factor returns.}
-\item{resid.corr}{N x N correlation matrix of residuals.}
-\item{return.corr}{N x N correlation matrix of asset returns.}
 \item{resid.var}{length-N vector of residual variances.}
 \item{call}{the matched function call.}
 \item{data}{data frame object as input.}
@@ -92,7 +89,7 @@
 \item{asset.names}{length-N vector of asset names.}
 \item{factor.names}{length-K vector of factor.names.}
 \item{time.periods}{length-T vector of dates.}
-Where N is the number of assets, K is the number of factors (including the
+Where N is the number of assets, K is the number of factors (including the 
 intercept or dummy variables) and T is the number of unique time periods.
 }
 \description{
@@ -104,63 +101,66 @@
 is returned.
 }
 \details{
-Estimation method "LS" corresponds to ordinary least squares using
-\code{\link[stats]{lm}} and "Rob" is robust regression using
-\code{\link[robust]{lmRob}}. "WLS" is weighted least squares using estimates
-of the residual variances from LS regression as weights (feasible GLS).
+Estimation method "LS" corresponds to ordinary least squares using 
+\code{\link[stats]{lm}} and "Rob" is robust regression using 
+\code{\link[robust]{lmRob}}. "WLS" is weighted least squares using estimates 
+of the residual variances from LS regression as weights (feasible GLS). 
 Similarly, "W-Rob" is weighted robust regression.
 
 Standardizing style factor exposures: The exposures can be standardized into
-z-scores using regular or robust (see \code{rob.stats}) measures of location
-and scale. Further, \code{weight.var}, a variable such as market-cap, can be
-used to compute the weighted mean exposure, and an equal-weighted standard
-deviation of the exposures about the weighted mean. This may help avoid an
-ill-conditioned covariance matrix. Default option equally weights exposures
-of different assets each period.
+z-scores using regular or robust (see \code{rob.stats}) measures of location 
+and scale. Further, \code{weight.var}, a variable such as market-cap, can be 
+used to compute the weighted mean exposure, and an equal-weighted standard 
+deviation of the exposures about the weighted mean. This may help avoid an 
+ill-conditioned covariance matrix. Default option equally weights exposures 
+of different assets each period. 
 
-If \code{rob.stats=TRUE}, \code{\link[robust]{covRob}} is used to compute a
-robust estimate of the factor covariance/correlation matrix, and,
-\code{\link[robustbase]{scaleTau2}} is used to compute robust tau-estimates
-of univariate scale for residuals during "WLS" or "W-Rob" regressions. When
-standardizing style exposures, the \code{\link[stats]{median}} and
+If \code{rob.stats=TRUE}, \code{\link[robust]{covRob}} is used to compute a 
+robust estimate of the factor covariance/correlation matrix, and, 
+\code{\link[robustbase]{scaleTau2}} is used to compute robust tau-estimates 
+of univariate scale for residuals during "WLS" or "W-Rob" regressions. When 
+standardizing style exposures, the \code{\link[stats]{median}} and 
 \code{\link[stats]{mad}} are used for location and scale respectively.
 
-At this time, the regression can contain only one dummy exposure (one of
-industry, sector, country etc.) or intercept term, otherwise the exposure
-matrix will become singular. We plan to expand the function to allow
-specifying more than one dummy variable, and, dummy variable(s) in
-combination with an intercept term in the future. (Ex: Country + Sector +
+At this time, the regression can contain only one dummy exposure (one of 
+industry, sector, country etc.) or intercept term, otherwise the exposure 
+matrix will become singular. We plan to expand the function to allow 
+specifying more than one dummy variable, and, dummy variable(s) in 
+combination with an intercept term in the future. (Ex: Country + Sector + 
 Intercept)
 
 The original function was designed by Doug Martin and initially implemented
 in S-PLUS by a number of University of Washington Ph.D. students:
 Christopher Green, Eric Aldrich, and Yindeng Jiang. Guy Yollin ported the
 function to R and Yi-An Chen modified that code. Sangeetha Srinivasan
-re-factored, updated and expanded the functionalities and S3 methods.
+re-factored, tested, corrected and expanded the functionalities and S3 
+methods.
 }
 \examples{
+
 # Load fundamental and return data
 data(Stock.df)
 
 # fit a fundamental factor model
 exposure.vars <- c("BOOK2MARKET", "LOG.MARKETCAP")
-fit <- fitFfm(data=stock, asset.var="TICKER", ret.var="RETURN",
+fit <- fitFfm(data=stock, asset.var="TICKER", ret.var="RETURN", 
               date.var="DATE", exposure.vars=exposure.vars)
 names(fit)
 
 # fit a BARRA Industry Factor Model
 exposure.vars <- c("GICS.SECTOR")
-fit1 <- fitFfm(data=stock, asset.var="TICKER", ret.var="RETURN",
-               date.var="DATE", exposure.vars=exposure.vars,
+fit1 <- fitFfm(data=stock, asset.var="TICKER", ret.var="RETURN", 
+               date.var="DATE", exposure.vars=exposure.vars, 
                fit.method="Rob", rob.stats=TRUE)
 
 # example with sector dummy included
 exposure.vars <- c("BOOK2MARKET", "LOG.MARKETCAP", "GICS.SECTOR")
-fit2 <- fitFfm(data=stock, asset.var="TICKER", ret.var="RETURN",
+fit2 <- fitFfm(data=stock, asset.var="TICKER", ret.var="RETURN", 
               date.var="DATE", exposure.vars=exposure.vars)
+
 }
 \author{
-Guy Yollin, Yi-An Chen and Sangeetha Srinivasan
+Sangeetha Srinivasan, Guy Yollin and Yi-An Chen
 }
 \references{
 Menchero, J. (2010). The Characteristics of Factor Portfolios. Journal of
@@ -170,13 +170,13 @@
 Ed.). New York: McGraw-Hill.
 }
 \seealso{
-The \code{ffm} methods for generic functions:
-\code{\link{plot.ffm}}, \code{\link{predict.ffm}},
-\code{\link{print.ffm}} and \code{\link{summary.ffm}}.
+The \code{ffm} methods for generic functions: 
+\code{\link{plot.ffm}}, \code{\link{predict.ffm}}, 
+\code{\link{print.ffm}} and \code{\link{summary.ffm}}. 
 
-And, the following extractor functions: \code{\link[stats]{coef}},
+And, the following extractor functions: \code{\link[stats]{coef}}, 
 \code{\link[stats]{fitted}}, \code{\link[stats]{residuals}},
-\code{\link{fmCov}}, \code{\link{fmSdDecomp}}, \code{\link{fmVaRDecomp}}
+\code{\link{fmCov}}, \code{\link{fmSdDecomp}}, \code{\link{fmVaRDecomp}} 
 and \code{\link{fmEsDecomp}}.
 
 \code{\link{paFm}} for Performance Attribution.

Modified: pkg/FactorAnalytics/man/fitSfm.Rd
===================================================================
--- pkg/FactorAnalytics/man/fitSfm.Rd	2015-12-09 18:46:21 UTC (rev 4005)
+++ pkg/FactorAnalytics/man/fitSfm.Rd	2016-01-17 03:13:53 UTC (rev 4006)
@@ -1,4 +1,4 @@
-% Generated by roxygen2 (4.1.1): do not edit by hand
+% Generated by roxygen2: do not edit by hand
 % Please edit documentation in R/fitSfm.R
 \name{fitSfm}
 \alias{coef.sfm}
@@ -17,108 +17,109 @@
 \method{residuals}{sfm}(object, ...)
 }
 \arguments{
-\item{data}{vector, matrix, data.frame, xts, timeSeries or zoo object with
+\item{data}{vector, matrix, data.frame, xts, timeSeries or zoo object with 
 asset returns. See details.}
 
-\item{k}{number of factors (or) a method for determining the optimal number
+\item{k}{number of factors (or) a method for determining the optimal number 
 of factors, one of "bn" or "ck". See details. Default is 1.}
 
-\item{max.k}{scalar; the maximum number of factors to be considered for
+\item{max.k}{scalar; the maximum number of factors to be considered for 
 methods "bn" or "ck". Default is \code{NULL}. See details.}
 
-\item{refine}{logical; whether to use the Connor-Korajczyk refinement for
+\item{refine}{logical; whether to use the Connor-Korajczyk refinement for 
 APCA. Default is \code{TRUE}.}
 
-\item{sig}{scalar; desired level of significance when "ck" method is
+\item{sig}{scalar; desired level of significance when "ck" method is 
 specified. Default is 0.05.}
 
-\item{check}{logical; to check if any asset has identical observations.
+\item{check}{logical; to check if any asset has identical observations. 
 Default is \code{FALSE}.}
 
-\item{corr}{logical; whether to use the correlation instead of the covariance
+\item{corr}{logical; whether to use the correlation instead of the covariance 
 matrix when finding the principal components. Default is \code{FALSE}.}
 
 \item{...}{optional arguments passed to \code{\link[stats]{lm}}.}
 
-\item{object}{a fit object of class \code{sfm} which is returned by
+\item{object}{a fit object of class \code{sfm} which is returned by 
 \code{fitSfm}}
 }
 \value{
-fitTsfm returns an object of class \code{"sfm"} for which
-\code{print}, \code{plot}, \code{predict} and \code{summary} methods exist.
+fitTsfm returns an object of class \code{"sfm"} for which 
+\code{print}, \code{plot}, \code{predict} and \code{summary} methods exist. 
 
-The generic accessor functions \code{coef}, \code{fitted} and
-\code{residuals} extract various useful features of the fit object.
-Additionally, \code{fmCov} computes the covariance matrix for asset returns
+The generic accessor functions \code{coef}, \code{fitted} and 
+\code{residuals} extract various useful features of the fit object. 
+Additionally, \code{fmCov} computes the covariance matrix for asset returns 
 based on the fitted factor model
 
-An object of class \code{"sfm"} is a list containing the following
+An object of class \code{"sfm"} is a list containing the following 
 components:
-\item{asset.fit}{fitted object of class \code{"mlm"} or \code{"lm"} from the
+\item{asset.fit}{fitted object of class \code{"mlm"} or \code{"lm"} from the 
 time-series LS regression of asset returns on estimated factors.}
 \item{k}{number of factors; as input or determined by "ck" or "bn" methods.}
 \item{factors}{T x K xts object of estimated factor realizations.}
-\item{loadings}{N x K matrix of factor loadings estimated by
+\item{loadings}{N x K matrix of factor loadings estimated by 
 regressing the asset returns on estimated factors.}
 \item{alpha}{length-N vector of estimated alphas.}
 \item{r2}{length-N vector of R-squared values.}
 \item{resid.sd}{length-N vector of residual standard deviations.}
 \item{residuals}{T x N xts object of residuals from the LS regression.}
 \item{Omega}{N x N return covariance matrix estimated by the factor model.}
-\item{eigen}{length-N (or length-T for APCA) vector of eigenvalues of the
+\item{eigen}{length-N (or length-T for APCA) vector of eigenvalues of the 
 sample covariance matrix.}
 \item{mimic}{N x K matrix of factor mimicking portfolio weights.}
 \item{call}{the matched function call.}
 \item{data}{T x N xts data object containing the asset returns.}
 \item{asset.names}{length-N vector of column names from data.}
-Where N is the number of assets, K is the number of factors, and T is the
+Where N is the number of assets, K is the number of factors, and T is the 
 number of observations.
 }
 \description{
-Fits a statistical factor model using Principal Component
-Analysis (PCA) for one or more asset returns or excess returns. When the
-number of assets exceeds the number of time periods, Asymptotic Principal
-Component Analysis (APCA) is performed. An object of class \code{"sfm"} is
+Fits a statistical factor model using Principal Component 
+Analysis (PCA) for one or more asset returns or excess returns. When the 
+number of assets exceeds the number of time periods, Asymptotic Principal 
+Component Analysis (APCA) is performed. An object of class \code{"sfm"} is 
 returned. This function is based on the S+FinMetric function \code{mfactor}.
 }
 \details{
-If \code{data} is not of class \code{"xts"}, rownames must provide an
-\code{"xts"} compatible time index. Before model fitting, incomplete cases in
-\code{data} are removed using \code{\link[stats]{na.omit}}. Specifying
-\code{check=TRUE}, issues a warning if any asset is found to have identical
-observations.
+If \code{data} is not of class \code{"xts"}, rownames must provide an 
+\code{"xts"} compatible time index. Before model fitting, incomplete cases in 
+\code{data} are removed using \code{\link[stats]{na.omit}}. Specifying 
+\code{check=TRUE}, issues a warning if any asset is found to have identical 
+observations. 
 
-Let \code{N} be the number of columns or assets and \code{T} be the number
-of rows or observations. When \code{N < T}, Principal Component Analysis
-(PCA) is performed. Any number of factors less than \code{min(N,T)} can be
-chosen via argument \code{k}. Default is 1. Refer to Zivot and Wang (2007)
+Let \code{N} be the number of columns or assets and \code{T} be the number 
+of rows or observations. When \code{N < T}, Principal Component Analysis 
+(PCA) is performed. Any number of factors less than \code{min(N,T)} can be 
+chosen via argument \code{k}. Default is 1. Refer to Zivot and Wang (2007) 
 for more details and references.
 
-When \code{N >= T}, Asymptotic Principal Component Analysis (APCA) is
-performed. The user can directly specify \code{k} similar to PCA above, or a
-method to automatically determine the number of factors can be specified:
-\code{k="bn"} corresponds to Bai and Ng (2002) and \code{k="ck"} corresponds
-to Connor and Korajczyk (1993). Users can choose the maximum number of
-factors, \code{max.k}, to consider with these methods. The default for
-\code{max.k} is set to be 10 or $T-1$, whichever is smaller.
+When \code{N >= T}, Asymptotic Principal Component Analysis (APCA) is 
+performed. The user can directly specify \code{k} similar to PCA above, or a 
+method to automatically determine the number of factors can be specified: 
+\code{k="bn"} corresponds to Bai and Ng (2002) and \code{k="ck"} corresponds 
+to Connor and Korajczyk (1993). Users can choose the maximum number of 
+factors, \code{max.k}, to consider with these methods. The default for 
+\code{max.k} is set to be 10 or $T-1$, whichever is smaller. 
 
-\code{refine} specifies whether a refinement of the APCA procedure from
-Connor and Korajczyk (1988), that may improve efficiency, is to be used.
+\code{refine} specifies whether a refinement of the APCA procedure from 
+Connor and Korajczyk (1988), that may improve efficiency, is to be used. 
 
-When \code{corr=TRUE}, the correlation matrix of returns are used for
-finding the principal components instead of the covariance matrix. This is
-typically decided by practioners on a case-by-case basis. The variable with
-the highest variance dominates the PCA when the covariance matrix is used.
-However, this may be justified if a volatile asset is more interesting for
-some reason and volatility information shouldn't be discarded. On the other
-hand, using the correlation matrix standardizes the variables and makes them
-comparable, avoiding penalizing variables with less dispersion.
+When \code{corr=TRUE}, the correlation matrix of returns are used for 
+finding the principal components instead of the covariance matrix. This is 
+typically decided by practioners on a case-by-case basis. The variable with 
+the highest variance dominates the PCA when the covariance matrix is used. 
+However, this may be justified if a volatile asset is more interesting for 
+some reason and volatility information shouldn't be discarded. On the other 
+hand, using the correlation matrix standardizes the variables and makes them 
+comparable, avoiding penalizing variables with less dispersion. 
 
 Finally, if the median of the 1st principal component is negative, all it's
-factor realizations are automatically inverted to enable more meaningful
+factor realizations are automatically inverted to enable more meaningful 
 interpretation.
 }
 \examples{
+
 # load return data
 data(StockReturns)
 
@@ -148,32 +149,33 @@
 
 # APCA with the Connor-Korajczyk method
 fit.apca.ck <- fitSfm(r.W, k="ck")
+
 }
 \author{
 Eric Zivot, Sangeetha Srinivasan and Yi-An Chen
 }
 \references{
-Bai, J., & Ng, S. (2002). Determining the number of factors in approximate
+Bai, J., & Ng, S. (2002). Determining the number of factors in approximate 
 factor models. Econometrica, 70(1), 191-221.
 
-Connor, G., & Korajczyk, R. A. (1988). Risk and return in an equilibrium
-APT: Application of a new test methodology. Journal of Financial Economics,
+Connor, G., & Korajczyk, R. A. (1988). Risk and return in an equilibrium 
+APT: Application of a new test methodology. Journal of Financial Economics, 
 21(2), 255-289.
 
-Connor, G., & Korajczyk, R. A. (1993). A test for the number of factors in
+Connor, G., & Korajczyk, R. A. (1993). A test for the number of factors in 
[TRUNCATED]

To get the complete diff run:
    svnlook diff /svnroot/returnanalytics -r 4006


More information about the Returnanalytics-commits mailing list