-
Notifications
You must be signed in to change notification settings - Fork 113
Description
I ma trying to set up data for analysis using FMP cloud data. I am not sure how to remove outliers from my data.
In the book you recommend winsorization:
"The winsorization stage must be performed on a feature-by-feature and a date-by-date basis. However, keeping a time series perspective is also useful."
If I get it right, using data.tables this procedure imply:
feature_set <- colnames(DT)[5:ncol(DT)]
DT <- DT[, (feature_set) := lapply(.SD, Winsorize, probs = c(0.05, 0.95)), by = .(date), .SDcols = feature_set] # across dates
DT <- DT[, (feature_set) := lapply(.SD, Winsorize, probs = c(0.05, 0.95)), by = .(symbol), .SDcols = feature_set] # across time
But I am not sure this is the rigt way. For example, lets say we have market cap feature. There is always one firm with highest market cap. If we do winsorization, we will always replace market cap of biggest firm with market cap of firm that belogns to 99 percentil. But this is not due to incorrect data or outliers.
Similar conclusion arise with time dimension. If EPS or examplegrows through time, we would replace highest EPS with 99 percentil even if data is not wrong.