Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Examples removed from fmXXDecomp.R manual pages, and saved for future replacement #58

Open
martinrd3D opened this issue Sep 2, 2021 · 4 comments
Assignees

Comments

@martinrd3D
Copy link
Collaborator

martinrd3D commented Sep 2, 2021

Manual page examples to be removed from factor model risk decomposition
functions for now, due to removal of data sets for the examples, and saved
here for adding back once new data sets are provided for these examples

fmSdDecomp.R:

Statistical Factor Model:

data(StockReturns)
sfm.pca.fit <- fitSfm(r.M, k=2)
decomp <- fmSdDecomp(sfm.pca.fit)
decomp$pcSd

fmVaRDecomp.R:

Statistical Factor Model:

data(StockReturns)
sfm.pca.fit <- fitSfm(r.M, k=2)
VaR.decomp <- fmVaRDecomp(sfm.pca.fit, type="normal")
VaR.decomp$cVaR

Fundamental Factor Model:

data(Stocks.df)
exposure.vars <- c("BOOK2MARKET", "LOG.MARKETCAP")
fit <- fitFfm(data=stock, asset.var="TICKER", ret.var="RETURN",
date.var="DATE", exposure.vars=exposure.vars)
VaR.decomp <- fmVaRDecomp(fit, type="normal")
VaR.decomp$cVaR

fmESDecomp.R:

Statistical Factor Model:

data(StockReturns)
sfm.pca.fit <- fitSfm(r.M, k=2)
ES.decomp <- fmEsDecomp(sfm.pca.fit, type="normal")
ES.decomp$cES

Fundamental Factor Model:

data(Stocks.df)
exposure.vars <- c("BOOK2MARKET", "LOG.MARKETCAP")
fit <- fitFfm(data=stock, asset.var="TICKER", ret.var="RETURN",
date.var="DATE", exposure.vars=exposure.vars)
ES.decomp <- fmEsDecomp(fit, type="normal")
head(ES.decomp$cES)

fmCov.R

Statistical Factor Model:

data(StockReturns)
sfm.pca.fit <- fitSfm(r.M, k=2)
fmCov(sfm.pca.fit)

Fundamental factor Model:

data(Stocks.df)
exposure.vars <- c("BOOK2MARKET", "LOG.MARKETCAP", "GICS.SECTOR")
fit2 <- fitFfm(data=stock, asset.var="TICKER", ret.var="RETURN",
date.var="DATE", exposure.vars=exposure.vars)
fmCov(fit2)

summary.ffm

#' data(Stocks.df)
#' exposure.vars <- c("BOOK2MARKET", "LOG.MARKETCAP", "GICS.SECTOR")
#' fit2 <- fitFfm(data=stock, asset.var="TICKER", ret.var="RETURN",
#' date.var="DATE", exposure.vars=exposure.vars)
#'
#' # summary of factor returns estimated in each time period
#' summary(fit2)
#'
#' # summary of lm fit for a single period
#' summary(fit2$factor.fit[[1]])

JustinMShea referenced this issue Sep 9, 2021
remove dependencies on stocks.df
fix fitTfsm on missing beta rownames
@JustinMShea
Copy link
Collaborator

JustinMShea commented Sep 13, 2021

@martinrd3D we could replace the stocks.df and other legacy data sets with something like this:

data("stocksCRSP")
data("scoresSPGMI")

CRSP_SPGMI <- merge(x = stocksCRSP,  y = scoresSPGMI, 
                    by = intersect(names(stocksCRSP), names(scoresSPGMI)) 
                    )

Let me know what you think

@martinrd3D
Copy link
Collaborator Author

martinrd3D commented Sep 13, 2021 via email

@martinrd3D
Copy link
Collaborator Author

martinrd3D commented Dec 22, 2021 via email

@martinrd3D
Copy link
Collaborator Author

martinrd3D commented Dec 22, 2021 via email

JustinMShea added a commit that referenced this issue Mar 26, 2022
Code fix to address plotting problems in ffm and tsfm objects. Also, see issue #41 and #58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants