Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: Re: egen mean function


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: Re: egen mean function
Date   Thu, 18 Aug 2005 22:08:38 +0100

I suspect that you need to -collapse- 
first, then do your -tssmooth-, and then 
-merge- with the original dataset. 

Nick 
[email protected] 

James Avery
 
> Nick,
> 
> I have a survey that was conducted over many days
> (390) with many interviews each day (58,373 cases
> total). So I have a numeric variable "day" (which runs
> from 1 to 390) and another numeric variable - campaign
> statements (st) - that is daily (see below). I want to
> create a new variable (st_7) that is the mean
> statements for the prior 7 days. Of course, I want
> values for all cases.
> 
> Thanks!
> 
> James
> 
>            day         st
> 25014. |   237        154 |
> 25015. |   237        154 |
>        |------------------|
> 25016. |   237        154 |
> 25017. |   237        154 |
> 25018. |   237        154 |
> 25019. |   238     162.67 |
> 25020. |   238     162.67 |
>        |------------------|
> 25021. |   238     162.67 |
> 25022. |   238     162.67 |
> 
> 
> --- Nick Cox <[email protected]> wrote:
> 
> > This really is in your court. Why do you 
> > have these multiples? 
> > 
> > It seems that your data are not appropriate for
> > -tssmooth-, 
> > given what you said in a prior -tsset- (did you
> > declare
> > the panel variable?). I don't think there is 
> > any question of a work-around until the data 
> > set-up is clear. 
> > 
> > Nick 
> > [email protected] 
> > 
> > James Avery
> >  
> > > Nick, Kit,
> > > 
> > > Thanks. But when I use tssmooth, I am told there
> > are
> > > repeated time values in sample:
> > > 
> > > tssmooth ma st_7 = st, window(7 1)
> > > repeated time values in sample
> > > 
> > > I have a number of cases for each time period. Any
> > way
> > > to get around this?
> >  
> > n j cox 
> > 
> > > > Kit is referring to a function in the -egenmore-
> > > > package on SSC.
> > > > 
> > > > In official Stata, see -tssmooth-.
> > 
> > Kit Baum
> >  
> > > > egen filter
> >  
> > James
> >  
> > > > I am using a rolling cross-sectional survey. So
> > I
> > > > have
> > > > individual-level data. There are many days and
> > many
> > > > individuals interviewed each day. I have a
> > variable
> > > > for day and another variable for campaign news
> > > > volume
> > > > (CNV). I would like to create a new variable,
> > prior
> > > > week campaign news volume (PWCNV) that is the
> > mean
> > > > CNV
> > > > for the prior 7 days. Is it possible to do this
> > with
> > > > the egen mean function or with another egen
> > > > function?

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



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index