[Returnanalytics-commits] r2698 - in pkg/FactorAnalytics: . R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Aug 2 02:57:10 CEST 2013
Author: chenyian
Date: 2013-08-02 02:57:09 +0200 (Fri, 02 Aug 2013)
New Revision: 2698
Modified:
pkg/FactorAnalytics/DESCRIPTION
pkg/FactorAnalytics/R/fitStatisticalFactorModel.R
pkg/FactorAnalytics/R/fitTimeSeriesFactorModel.R
pkg/FactorAnalytics/R/plot.TimeSeriesFactorModel.r
Log:
debug
Modified: pkg/FactorAnalytics/DESCRIPTION
===================================================================
--- pkg/FactorAnalytics/DESCRIPTION 2013-08-02 00:13:20 UTC (rev 2697)
+++ pkg/FactorAnalytics/DESCRIPTION 2013-08-02 00:57:09 UTC (rev 2698)
@@ -7,5 +7,5 @@
Maintainer: Yi-An Chen <chenyian at uw.edu>
Description: An R package for estimation and risk analysis of linear factor models for asset returns and portfolios. It contains three major fitting method for the factor models: fitting macroeconomic factor model, fitting fundamental factor model and fitting statistical factor model and some risk analysis tools like VaR, ES to use the result of the fitting method. It also provides the different type of distribution to fit the fat-tail behavior of the financial returns, including edgeworth expansion type distribution.
License: GPL-2
-Depends: robust, robustbase, leaps, lars, zoo, MASS, PerformanceAnalytics, ff, sn, tseries, strucchange
+Depends: robust, robustbase, leaps, lars, zoo, MASS, PerformanceAnalytics, ff, sn, tseries, strucchange,xts,ellipse
LazyLoad: yes
\ No newline at end of file
Modified: pkg/FactorAnalytics/R/fitStatisticalFactorModel.R
===================================================================
--- pkg/FactorAnalytics/R/fitStatisticalFactorModel.R 2013-08-02 00:13:20 UTC (rev 2697)
+++ pkg/FactorAnalytics/R/fitStatisticalFactorModel.R 2013-08-02 00:57:09 UTC (rev 2698)
@@ -209,7 +209,7 @@
if(is.null(ret.cov)) {
ret.cov <- crossprod(xc)/m
}
- eigen.tmp <- eigen(ret.cov, symm = TRUE)
+ eigen.tmp <- eigen(ret.cov, symmetric = TRUE)
# compute loadings beta
B <- t(eigen.tmp$vectors[, 1:k, drop = FALSE])
# compute estimated factors
@@ -288,7 +288,7 @@
if(refine) {
xs <- t(xc)/sqrt(sigma)
ret.cov <- crossprod(xs)/n
- eig.tmp <- eigen(ret.cov, symm = TRUE)
+ eig.tmp <- eigen(ret.cov, symmetric = TRUE)
f <- eig.tmp$vectors[, 1:k, drop = FALSE]
f1 <- cbind(1, f)
B <- backsolve(chol(crossprod(f1)), diag(k + 1))
Modified: pkg/FactorAnalytics/R/fitTimeSeriesFactorModel.R
===================================================================
--- pkg/FactorAnalytics/R/fitTimeSeriesFactorModel.R 2013-08-02 00:13:20 UTC (rev 2697)
+++ pkg/FactorAnalytics/R/fitTimeSeriesFactorModel.R 2013-08-02 00:57:09 UTC (rev 2698)
@@ -176,7 +176,7 @@
# sum weigth to unitary
w <- w/sum(w)
fm.formula = as.formula(paste(i,"~", ".", sep=""))
- fm.fit = lm(fm.formula, data=reg.df,weight=w)
+ fm.fit = lm(fm.formula, data=reg.df,weights=w)
fm.summary = summary(fm.fit)
reg.list[[i]] = fm.fit
Alphas[i] = coef(fm.fit)[1]
@@ -301,7 +301,7 @@
# sum weigth to unitary
w <- w/sum(w)
fm.formula = as.formula(paste(i,"~", ".", sep=""))
- fm.fit = lm(fm.formula, data=reg.df,weight=w)
+ fm.fit = lm(fm.formula, data=reg.df,weights=w)
fm.summary = summary(fm.fit)
reg.list[[i]] = fm.fit
Alphas[i] = coef(fm.fit)[1]
@@ -333,7 +333,7 @@
reg.df = merge(reg.df,quadratic.term)
colnames(reg.df)[dim(reg.df)[2]] <- "quadratic.term"
}
- fm.fit = lm(fm.formula, data=reg.df,weight=w)
+ fm.fit = lm(fm.formula, data=reg.df,weights=w)
fm.summary = summary(fm.fit)
reg.list[[i]] = fm.fit
Alphas[i] = coef(fm.fit)[1]
@@ -425,7 +425,7 @@
# sum weigth to unitary
w <- w/sum(w)
fm.formula = as.formula(paste(i,"~", ".", sep=""))
- fm.fit = step(lm(fm.formula, data=reg.df,weight=w),trace=0)
+ fm.fit = step(lm(fm.formula, data=reg.df,weights=w),trace=0)
fm.summary = summary(fm.fit)
reg.list[[i]] = fm.fit
Alphas[i] = coef(fm.fit)[1]
Modified: pkg/FactorAnalytics/R/plot.TimeSeriesFactorModel.r
===================================================================
--- pkg/FactorAnalytics/R/plot.TimeSeriesFactorModel.r 2013-08-02 00:13:20 UTC (rev 2697)
+++ pkg/FactorAnalytics/R/plot.TimeSeriesFactorModel.r 2013-08-02 00:57:09 UTC (rev 2698)
@@ -197,7 +197,7 @@
}
w <- w/sum(w)
rollReg <- function(data.z, formula,w) {
- coef(lm(formula,weight=w, data = as.data.frame(data.z)))
+ coef(lm(formula,weights=w, data = as.data.frame(data.z)))
}
reg.z = zoo(fit.lm$model[-length(fit.lm$model)], as.Date(rownames(fit.lm$model)))
factorNames = colnames(fit.lm$model)[c(-1,-length(fit.lm$model))]
More information about the Returnanalytics-commits
mailing list