Skip to content

Commit

Permalink
fixed #51 with PerformanceAnalytics::ExcessReturns, issues remain wit…
Browse files Browse the repository at this point in the history
…h the function related to #43
  • Loading branch information
JustinMShea committed Aug 21, 2021
1 parent 68213ee commit b1573ec
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
16 changes: 6 additions & 10 deletions R/fitTsfmUpDn.R
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@
#' summary(fitUpDn$Dn)
#'
#' @export


fitTsfmUpDn <- function(asset.names, mkt.name, rf.name=NULL,
data=data, fit.method=c("LS","DLS","Robust"),
control=fitTsfm.control(...),...) {
Expand All @@ -117,15 +115,13 @@ fitTsfmUpDn <- function(asset.names, mkt.name, rf.name=NULL,
# extract columns to be used in the time series regression
dat.xts <- merge(data.xts[,asset.names], data.xts[,mkt.name])

### After merging xts objects, the spaces in names get converted to periods

# BROKEN convert all asset and factor returns to excess returns if specified
# if (!is.null(rf.name)) {
# dat.xts <- "[<-"(dat.xts,,vapply(dat.xts, function(x) x-data.xts[,rf.name],
# FUN.VALUE = numeric(nrow(dat.xts))))
#}
# Note `Return.excess` will modify variable names, so change back
dat.xts.names <- colnames(dat.xts)
dat.xts <- PerformanceAnalytics::Return.excess(R = dat.xts,
Rf = data.xts[ ,rf.name])
colnames(dat.xts) <- dat.xts.names

mkt <- dat.xts[,mkt.name]
mkt <- dat.xts[ ,mkt.name]
# up market
dataUp.xts <- dat.xts[mkt >= 0]

Expand Down
2 changes: 1 addition & 1 deletion man/fitTsfmUpDn.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b1573ec

Please sign in to comment.