|
WEIGHTED TRIMMED MEANName:
In some cases, you can also apply weights in computing the means. For example, this may be done when your data is in the form of a frequency table (i.e., the frequencies define the weights). The weighted trimmed mean is used to apply weights to the trimmed mean command. The formula for computing the weighted trimmed mean is
where X is the sorted response variable, W is the weights variable, and kstrt and kstop define the indices of the first and last observations that are not trimmed. The response variable and weights variable must have the same number of observations. At least one of the weights must be positive and none of the weights can be negative. Otherwise, an error message is reported.
<SUBSET/EXCEPT/FOR qualification> where <x> is the response variable; <w> is the weights variable; <par> is a parameter where the weighted trimmed mean is saved; and where the <SUBSET/EXCEPT/FOR qualification> is optional.
LET A = WEIGHTED TRIMMED MEAN Y1 WEIGHT SUBSET Y1 > 0
LET P2 = 10 LET A = WEIGHTED TRIMMED MEAN Y W
let y = double exponential random numbers for i = 1 1 10000 set histogram empty bins off set histogram class width normal corrected let y2 x2 = binned y . let ymean = mean y let ymed = median y let wmean = weighted mean x2 y2 let p1 = 10 let p2 = 10 let wtrim = weighted trimmed mean x2 y2 . set write decimals 3 print ymean ymed wmean wtrimThe following output is generated. PARAMETERS AND CONSTANTS-- YMEAN -- 0.008 YMED -- 0.004 WMEAN -- 0.011 WTRIM -- 0.005
Date created: 06/29/2012 |