Skip to content

Commit

Permalink
Updated fitFfm example to solve #69 and hopefully clear an -R CMD che…
Browse files Browse the repository at this point in the history
…ck error in #43, but ran into #73. Reprioritize project board issues
  • Loading branch information
JustinMShea committed Dec 22, 2021
1 parent c8d23f5 commit 7ada2bc
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 40 deletions.
52 changes: 32 additions & 20 deletions R/fitFfm.R
Original file line number Diff line number Diff line change
Expand Up @@ -175,33 +175,45 @@
#'
#' @examples
#'
#'#' # load data
#'data(stocksCRSP)
#'data(factorsSPGMI)
#'
#'stocks_factors <- selectCRSPandSPGMI(stocks = stocksCRSP, factors = factorsSPGMI,
#' dateSet = c("2006-01-31", "2010-12-31"),
#' stockItems = c("Date", "TickerLast",
#' "CapGroup", "Sector",
#' "Return", "Ret13WkBill",
#' "mktIndexCRSP"),
#' factorItems = c("BP", "LogMktCap", "SEV"),
#' capChoice = "SmallCap",
#' Nstocks = 20)
#'
#' # Load fundamental and return data
#' data("factorDataSetDjia5Yrs")
#' # fit a fundamental factor model with style variables BP and LogMktCap
#'
#' # fit a fundamental factor model
#' exposure.vars <- c("P2B", "MKTCAP")
#' fit <- fitFfm(data=factorDataSetDjia5Yrs, asset.var="TICKER", ret.var="RETURN",
#' date.var="DATE", exposure.vars=exposure.vars)
#' names(fit)
#'fundamental_model <- fitFfm(data = stocks_factors,
#' asset.var = "TickerLast",
#' ret.var = "Return",
#' date.var = "Date",
#' exposure.vars = c("BP", "LogMktCap")
#' )
#'
#' # fit a Industry Factor Model with Intercept
#' exposure.vars <- c("SECTOR","P2B")
#' fit1 <- fitFfm(data=factorDataSetDjia5Yrs, asset.var="TICKER", ret.var="RETURN",
#' date.var="DATE", exposure.vars=exposure.vars, addIntercept=TRUE)
#'
#' # Fit a SECTOR+COUNTRY+Style model with Intercept
#' # Create a COUNTRY column with just 3 countries
#' summary(fundamental_model)
#'
#' factorDataSetDjia5Yrs$COUNTRY = rep(rep(c(rep("US", 1 ),rep("GERMANY", 1 )), 11), 60)
#' exposure.vars= c("SECTOR", "COUNTRY","P2B", "MKTCAP")
#' # Fit a Fundamental Sector Factor Model with Intercept
#'
#' # fit.MICM <- fitFfm(data=factorDataSetDjia5Yrs, asset.var="TICKER", ret.var="RETURN",
#' # date.var="DATE", exposure.vars=exposure.vars, addIntercept=TRUE)
#' sector_model <- fitFfm(data = stocks_factors,
#' asset.var = "TickerLast",
#' ret.var = "Return",
#' date.var = "Date",
#' exposure.vars = c("Sector", "BP"),
#' addIntercept = TRUE)
#'
#' summary(sector_model)
#'
#'
#'
#' @export


fitFfm <- function(data, asset.var, ret.var, date.var, exposure.vars,
weight.var = NULL,
fit.method = c("LS","WLS","Rob","W-Rob"),
Expand Down
54 changes: 34 additions & 20 deletions man/fitFfm.Rd

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

0 comments on commit 7ada2bc

Please sign in to comment.