st: Re: mvsumm and missing obs

 From Kit Baum To "Nick Cox" Subject st: Re: mvsumm and missing obs Date Tue, 10 Aug 2004 12:38:27 -0400

I agree; I'm not thrilled about the notion of adding this flexibility to mvsumm. One would then have to compute, for each statistic and each point in time, the number of data points that went into it, and would have to be able to specify what a minimum amount of information might be to calculate anything at all. Neither of those are technically daunting, but the concept of a moving statistic based upon a variable amount of information should be treated with extreme caution (e.g. say that I am calculating 24-month averages, but for some periods only my minimum of 4 data points are available. The standard errors of those means would vary radically). Users are free to create 'mvsumm2', 'mvsumm3', etc. but I am not keen on this flexibility for mvsumm or mvcorr.

A solution not involving programming would be to generate, e.g., mvsumm for 5 obs. as one variable, mvsumm for 4 as another, and mvsumm for 3 as a third, and then use simple logic to define your result as that based on the largest sample for which the statistic is non-missing (taking 3 as the minimum). Imagine that stat5, stat4, stat3 in the table are mvsumm results for 5, 4 and 3 obs respectively. Then

. g mystat = cond(stat5<.,stat5,cond(stat4<.,stat4,stat3))

. l

+--------------------------------+
| stat3 stat4 stat5 mystat |
|--------------------------------|
1. | 10 16 . 16 |
2. | 11 . . 11 |
3. | 12 13 14 14 |
+--------------------------------+

Kit

On Aug 10, 2004, at 12:18 PM, Nick Cox wrote:

```I think you need to clone -mvsumm- and
get your clone, called something else,
to do what you want. It's not difficult,
but speaking as a co-author of -mvsumm-
you don't have my support in this aim.
Insisting on complete windows is, I suggest,
to be regarded as a small feature
in -mvsumm-. You can nobble the code if you wish,

Kit Baum may or may not agree with me on this.

Nick
n.j.cox@durham.ac.uk

jansoko@umich.edu
```
```I have a similar question to Adrian's about -mvsumm-.
Unfortunately, the
proposed solution (using -tssmooth-) doesn't work as I am
interested in moving
variances, not moving averages.

How can I get create a variable that contains the variance of
the five preceding
observations in a panel data set, even if one or two of the
those preceding
observations are missing?  And how can I specify the minimum number of
non-missing observations within the window?

```
```*
*   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/
```