s-news
[Top] [All Lists]

a movjng average median

To: <s-news@wubios.wustl.edu>
Subject: a movjng average median
From: "Leeds, Mark" <mleeds@mlp.com>
Date: Mon, 20 Oct 2003 16:24:25 -0400
Thread-index: AcOXSCeB/Vmwp+KVRyyaZg+HLhMqLg==
Thread-topic: a movjng average median
does anyone have or know of an easy way to calculate
the "windowLength" day moving median given a vector of numbers.
 
one can use filter to calculate the "windowLength" day moving average
as shown below but i can't think of a good way to
do the median.
 
"backwardsmovingaverage<-function(series,windowLength)
{
return(  c(filter( series, sides=1, filter=rep(1/windownlength,windowlength))))
}
 
thanks.
 
                                            mark
<Prev in Thread] Current Thread [Next in Thread>