# st: Re: mvsumm

 From "Scott Merryman" To Subject st: Re: mvsumm Date Fri, 5 Mar 2004 17:29:35 -0600

```Adrian,

-tssmooth ma- gives missing obersvations a zero weight in calculating the moving
average.  This would seem to give you what you want.

Example:

. tsset var1
time variable:  var1, 1990 to 2003

. tssmooth ma ma2= var2, w(4 1)
The smoother applied was
(1/5)*[x(t-4) + x(t-3) + x(t-2) + x(t-1) + 1*x(t)]; x(t)= var2

. l

+--------------------+
| var1   var2    ma2 |
|--------------------|
1. | 1990      .      . |
2. | 1991      .      . |
3. | 1992      3      3 |
4. | 1993      4    3.5 |
5. | 1994      5      4 |
|--------------------|
6. | 1995      5   4.25 |
7. | 1996      4    4.2 |
8. | 1997      6    4.8 |
9. | 1998      5      5 |
10. | 1999      3    4.6 |
|--------------------|
11. | 2000      4    4.4 |
12. | 2001      5    4.6 |
13. | 2002      6    4.6 |
14. | 2003      .    4.5 |
+--------------------+

Hope this helps,
Scott

----- Original Message -----
To: <statalist@hsphsun2.harvard.edu>
Sent: Friday, March 05, 2004 4:23 PM
Subject: st: mvsumm

> Dear Stata users,
>
> I am using Chris Baum's and Nick Fox's -mvsumm- and I'd like to know if
> there is a way to account for averages (or any other desc stats) when
> there are missing observations (e.g., the way -collapse- accounts for
> them). What I mean  is the following:
>
> 1990   .
> 1991   .
> 1992   3
> 1993   4
> 1994   5
> 1995   5
> 1996   4
> 1997   6
> 1998   5
> 1999   3
> 2000   4
> 2001   5
> 2002   6
> 2003   .
>
> If I use -mvsumm- to generate 5-year moving averages, I'd like it to
> even give me a number in year 1994 (when there are already 5
> observations to compute the average, even though 2 are missing--so the
> generated number would be the average of 3, 4, and 5) and also in 2003
> (which would be the average of 3, 4, 5, and 6). Is this possible?
>
> Thank you.
>

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```

• References:
• st: mvsumm