[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sas-l
Subject:    Re: moving averages and proc expand
From:       rss <rslotpole () FMR ! COM>
Date:       2006-11-30 16:25:45
[Download RAW message or body]

Richard A. DeVenezia wrote:
> rss wrote:
> > Hi,
> >
> > I've been trying to compute a moving average within a dataset that is
> > sorted by peer_id and Fnd_name.  For each Fnd_name we have monthly
> > observations.  I'm trying to create a moving average of those monthly
> > observations for each Fnd_name.
> >
> > I've tried using the Proc Expand procedure but that just gives really
> > weird results. I ran a test with a dummy variable that was a counter
> > from 1 to 150,000.  ran the following:
> >
> > proc expand data=ipq.rankings_nrm4 out=ipq.x method=none;
> >
> >    convert cnt = cntave / transformout=(movave 6);
> > run;
> >
> > the results didn't make any sense.
> >
> >   cnt   cntave
> > 1     1
> > 2     1.5
> > 3     2
> > 4     2.5
> > 5     3
> > 6     3.5
> > 7     4.5
> > 8     5.5
> >
> >
> > so after 3.5 they both increment by 1.  Now where does that come from
> > a movave 6?
>
> Totally expected.
>
> S(n,m) is
>     sum of s(n-m+1) ... s(n)
> but given series s(i) = i, we have
>     sum of n-m+1 ... n
> and
> S(n+1,m) is
>     sum of n-m+2 ... n, or
>     S(n) - (n-m+1) + (n+1), or
>     S(n) + m, or
>     m more than prior sum
>
> The moving average
> MA(n,m) = S(n,m) / m
> and
> MA(n+1,m) = S(n+1,m) / m = (S(n,m) + m) / m
> clearly have a difference of
> m/m, or simply 1.
>
> --
> Richard A. DeVenezia
> http://www.devenezia.com/

Yes, but since this is a moving average of 6 shouldn't the first 5
observations be missing?

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic