Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Exponentially Weighted Moving Average (EWMA) Control Chart

    Hi Statalisters

    I was wondering if anyone can share example codes for graphing Exponentially Weighted Moving Average (EWMA) Control Chart in Stata?

    I have searched endlessly online without some success. Example data is below:

    Code:
    clear
    set obs 50
    gen month = _n
    gen infect =  runiformint(3,12)
    My interest is to overlay an EWMA control chart with a Stewart control chart. Stata already has a command for Stewart control chart (-cchart-). Since -cchart- is not a -two way- graph, I have constructed mine as below (just as example only):

    Code:
    sum infect
    local u = r(mean) + 1 * r(sd)  
    local t = r(mean) - 1 * r(sd)  
    display "mean `r(mean)' lower `t' upper `u'"
    tw connected infect month, sort yline(`r(mean)' `u' `t')
    Now my major challenge is the ewma control chart.

    Nick Cox please are you able to provide some advice as to how to make work your very old ewma code, possibly made for Stata 6.0?

    When I try to use it to generate a new variable like
    Code:
    ewma infect, generate(ewm)
    It returns an error that says

    Code:
    infect not found
    r(111);
    Any advice will be highly appreciated.

    Madu

  • #2
    This is what

    Code:
    ssc describe ewma
    advises:


    --------------------------------------------------------------------------------------------------------------
    package ewma from http://fmwww.bc.edu/repec/bocode/e
    --------------------------------------------------------------------------------------------------------------

    TITLE
    'EWMA': module to calculate exponentially weighted moving average

    DESCRIPTION/AUTHOR(S)

    ewma calculates an exponentially weighted moving average of the
    series named in the generate() option. This is kept in the
    archive only for any users of Stata 5.0. Users of Stata 6.0
    upwards should instead install the egenmore package, including
    the ewma( ) function, which requires and respects a prior tsset,
    and (e.g.) works properly for xt data.

    Author: Nicholas J. Cox, University of Durham
    Support: email [email protected]

    Distribution-Date: 19980327

    INSTALLATION FILES (type net install ewma)
    ewma.ado
    --------------------------------------------------------------------------------------------------------------
    (type ssc install ewma to install)
    and that's outdated too: the place to start now is surely

    Code:
    help tssmooth

    Comment

    Working...
    X