proc_SP500 {bspcov} | R Documentation |
Preprocess SP500 data
Description
The proc_SP500
function preprocesses the SP500 stock data by calculating monthly
returns for selected sectors and generating idiosyncratic errors.
Usage
proc_SP500(SP500data, sectors)
Arguments
SP500data |
A data frame containing SP500 stock data with columns including:
|
sectors |
A character vector specifying the sectors to include in the analysis. |
Details
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
Value
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 |
Examples
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)
[Package bspcov version 1.0.2 Index]