Products | Versions |
---|---|
Spotfire Analyst | All Versions |
2). Enter the following details:
Name: WinsorizedMean
Description: Calculates the mean after replacing certain parts of a probability distribution at the high and low ends with the most extreme remaining values, typically doing so for an equal amount at both extremes.Script:
# Define the TrimmedMeanWinsor function: WinsorizedMean <- function( input ) { p95 <- quantile( input, .95 ) p05 <- quantile( input, .05 ) input <- replace( input, input < p05, p05 ) input <- replace( input, input > p95, p95 ) out <- mean( input ) out } # Run the function to produce the output output <- rep( WinsorizedMean( input1 ), length( input1 ) )
When using custom expressions in Spotfire, you can now use the custom WinsorizedMean() function by passing it a single column. For example:
WinsorizedMean([myColumn1])
See the attached (Filename: WinsorizedMean.png).
Note:
This uses a hard coded p95 and p05 percentiles for the upper and lower limits used in the Winsorizing. The .95 and .05 values can be manually adjusted as required. Additionally, you could modify the Expression Function to take two additional arguments, so you pass the upper and lower limits explicitly.
Disclaimer: