[Returnanalytics-commits] r2457 - in pkg/FactorAnalytics: R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Jun 28 01:09:58 CEST 2013
Author: chenyian
Date: 2013-06-28 01:09:58 +0200 (Fri, 28 Jun 2013)
New Revision: 2457
Modified:
pkg/FactorAnalytics/R/factorModelCovariance.r
pkg/FactorAnalytics/man/factorModelCovariance.Rd
Log:
modify factorModelCovariance.Rd
Modified: pkg/FactorAnalytics/R/factorModelCovariance.r
===================================================================
--- pkg/FactorAnalytics/R/factorModelCovariance.r 2013-06-27 22:39:32 UTC (rev 2456)
+++ pkg/FactorAnalytics/R/factorModelCovariance.r 2013-06-27 23:09:58 UTC (rev 2457)
@@ -47,14 +47,8 @@
#'
factorModelCovariance <-
function(beta.mat, factor.cov, residVars.vec) {
-## Inputs:
-## beta.mat n x k matrix of factor betas
-## factor.cov k x k factor return covariance matrix
-## residVars.vec n x 1 vector of residual variances from factor model
-## Output:
-## cov.fm n x n return covariance matrix based on
-## estimated factor model.
- beta.mat = as.matrix(beta.mat)
+
+ beta.mat = as.matrix(beta.mat)
factor.cov = as.matrix(factor.cov)
sig.e = as.vector(residVars.vec)
if (length(sig.e) > 1) {
Modified: pkg/FactorAnalytics/man/factorModelCovariance.Rd
===================================================================
--- pkg/FactorAnalytics/man/factorModelCovariance.Rd 2013-06-27 22:39:32 UTC (rev 2456)
+++ pkg/FactorAnalytics/man/factorModelCovariance.Rd 2013-06-27 23:09:58 UTC (rev 2457)
@@ -1,57 +1,71 @@
-\name{factorModelCovariance}
-\alias{factorModelCovariance}
-\title{Compute Factor Model Covariance Matrix.}
-\usage{
- factorModelCovariance(beta.mat, factor.cov,
- residVars.vec)
-}
-\arguments{
- \item{beta.mat}{\code{N x K} matrix of factor betas,
- where \code{N} is the number of assets and \code{K} is
- the number of factors.}
-
- \item{factor.cov}{\code{K x K} factor return covariance
- matrix.}
-
- \item{residVars.vec}{\code{N x 1} vector of asset
- specific residual variances from the factor model.}
-}
-\value{
- \code{N x N} return covariance matrix based on factor
- model parameters.
-}
-\description{
- Compute asset return covariance matrix from factor model
- parameters.
-}
-\details{
- The return on asset \code{i} (\code{i = 1,...,N}) is
- assumed to follow the factor model \cr \code{R(i,t) =
- alpha + t(beta)*F(t) + e(i,t), e(i,t) ~ iid (0,
- sig(i)^2)} \cr where \code{beta} is a \code{K x 1} vector
- of factor exposures. The return variance is then \cr
- \code{var(R(i,t) = t(beta)*var(F(t))*beta + sig(i)^2},
- \cr and the \code{N x N} covariance matrix of the return
- vector \code{R} is \cr \code{var(R) = B*var(F(t))*t(B) +
- D} \cr where B is the \code{N x K} matrix of asset betas
- and \code{D} is a diagonal matrix with \code{sig(i)^2}
- values along the diagonal.
-}
-\examples{
-# factorModelCovariance
-data(managers.df)
-factors = managers.df[,(7:9)]
-ret.assets = managers.df[,(1:6)]
-fit <-fitMacroeconomicFactorModel(ret.assets,factors,fit.method="OLS",
- variable.selection="all subsets", factor.set = 3)
-factorModelCovariance(fit$beta.mat,var(factors),fit$residVars.vec)
-}
-\author{
- Eric Zivot and Yi-An Chen.
-}
-\references{
- Zivot, E. and J. Wang (2006), \emph{Modeling Financial
- Time Series with S-PLUS, Second Edition},
- Springer-Verlag.
-}
-
+\name{factorModelCovariance}
+\alias{factorModelCovariance}
+\title{Compute Factor Model Covariance Matrix.}
+\usage{
+ factorModelCovariance(beta.mat, factor.cov,
+ residVars.vec)
+}
+\arguments{
+ \item{beta}{\code{N x K} matrix of factor betas, where
+ \code{N} is the number of assets and \code{K} is the
+ number of factors.}
+
+ \item{factor.cov}{\code{K x K} factor return covariance
+ matrix.}
+
+ \item{resid.variance}{\code{N x 1} vector of asset
+ specific residual variances from the factor model.}
+}
+\value{
+ \code{N x N} return covariance matrix based on factor
+ model parameters.
+}
+\description{
+ Compute asset return covariance matrix from factor model
+ parameters.
+}
+\details{
+ The return on asset \code{i} (\code{i = 1,...,N}) is
+ assumed to follow the factor model \cr \code{R(i,t) =
+ alpha + t(beta)*F(t) + e(i,t), e(i,t) ~ iid (0,
+ sig(i)^2)} \cr where \code{beta} is a \code{K x 1} vector
+ of factor exposures. The return variance is then \cr
+ \code{var(R(i,t) = t(beta)*var(F(t))*beta + sig(i)^2},
+ \cr and the \code{N x N} covariance matrix of the return
+ vector \code{R} is \cr \code{var(R) = B*var(F(t))*t(B) +
+ D} \cr where B is the \code{N x K} matrix of asset betas
+ and \code{D} is a diagonal matrix with \code{sig(i)^2}
+ values along the diagonal.
+}
+\examples{
+# Time Series model
+
+data(managers.df)
+factors = managers.df[,(7:9)]
+fit <- fitTimeseriesFactorModel(assets.names=colnames(managers.df[,(1:6)]),
+ factors.names=c("EDHEC.LS.EQ","SP500.TR"),
+ data=managers.df,fit.method="OLS")
+factorModelCovariance(fit$beta,var(factors),fit$resid.variance)
+
+# Statistical Model
+data(stat.fm.data)
+fit <- fitStatisticalFactorModel(sfm.dat,k=2,
+ ckeckData.method="data.frame")
+
+factorModelCovariance(t(sfm.pca.fit$loadings),var(sfm.pca.fit$factors),sfm.pca.fit$resid.variance)
+
+sfm.apca.fit <- fitStatisticalFactorModel(sfm.apca.dat,k=2
+,ckeckData.method="data.frame")
+
+factorModelCovariance(t(sfm.apca.fit$loadings),
+ var(sfm.apca.fit$factors),sfm.apca.fit$resid.variance)
+}
+\author{
+ Eric Zivot and Yi-An Chen.
+}
+\references{
+ Zivot, E. and J. Wang (2006), \emph{Modeling Financial
+ Time Series with S-PLUS, Second Edition},
+ Springer-Verlag.
+}
+
More information about the Returnanalytics-commits
mailing list