proc_SP500 | R Documentation |
The proc_SP500
function preprocesses the SP500 stock data by calculating monthly
returns for selected sectors and generating idiosyncratic errors.
proc_SP500(SP500data, sectors)
SP500data |
A data frame containing SP500 stock data with columns including:
|
sectors |
A character vector specifying the sectors to include in the analysis. |
Calculates monthly returns for each stock in the specified sectors
Estimates the number of factors via hdbinseg::get.factor.model(ic="ah")
Uses POET::POET()
to extract factor loadings/factors and form idiosyncratic errors
A list with components:
Uhat |
A matrix of idiosyncratic errors. |
Khat |
Estimated number of factors. |
factorparthat |
Estimated factor returns. |
sectornames |
Sector for each column of |
data("SP500")
set.seed(1234)
sectors <- c("Energy", "Financials", "Materials",
"Real Estate", "Utilities", "Information Technology")
Uhat <- proc_SP500(SP500, sectors)$Uhat
PPPres <- thresPPP(Uhat, eps = 0, thres = list(value = 0.0020, fun = "hard"), nsample = 100)
postmean <- estimate(PPPres)
diag(postmean) <- 0 # hide color for diagonal
plot(postmean)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.