SED navigation bar go to SED home page go to Dataplot home page go to NIST home page SED Home Page SED Staff SED Projects SED Products and Publications Search SED Pages
Dataplot Vol 2 Vol 1

WEIGHTED TRIMMED MEAN

Name:
    WEIGHTED TRIMMED MEAN (LET)
Type:
    Let Subcommand
Purpose:
    Compute the weighted trimmed mean of a variable.
Description:
    The mean is the sum of the observations divided by the number of observations. The mean can be heavily influenced by extreme values in the tails of a variable. The trimmed mean compensates for this by dropping a certain percentage of values on the tails. For example, the 50% trimmed mean is the mean of the values between the upper and lower quartiles. The 90% trimmed mean is the mean of the values after truncating the lowest and highest 5% of the values.

    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

      WTM = SUM[i=kstrt to kstop][W(i)*X(i)]/SUM[i=kstrt to kstop][W(i)]

    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.

Syntax:
    LET <par> = WEIGHTED TRIMMED MEAN <x> <w>
                            <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.
Examples:
    LET A = WEIGHTED TRIMMED MEAN Y1 WEIGHT
    LET A = WEIGHTED TRIMMED MEAN Y1 WEIGHT SUBSET Y1 > 0
Note:
    The analyst must specify the percentages to trim in each tail. This is done by defining the internal variables P1 (the lower tail) and P2 (the upper tail). For example, to trim 10% off each tail, do the following:

      LET P1 = 10
      LET P2 = 10
      LET A = WEIGHTED TRIMMED MEAN Y W
Default:
    None
Synonyms:
    None
Related Commands: Applications:
    Data Analysis
Implementation Date:
    2012/06
Program:
     
    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 wtrim
        
    The following output is generated.
     PARAMETERS AND CONSTANTS--
    
        YMEAN   --          0.008
        YMED    --          0.004
        WMEAN   --          0.011
        WTRIM   --          0.005
        

Date created: 06/29/2012
Last updated: 06/29/2012
Please email comments on this WWW page to alan.heckert@nist.gov.