Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: superposed rolled windows


From   "irodriguez" <[email protected]>
To   [email protected]
Subject   Re: st: superposed rolled windows
Date   Tue, 27 Jun 2006 13:05:22 -0300

Michael, in your command:
   tsset Firms Years     // Declare data as a panel
   forval i = 1/3 {
         local j = `i'-1
        gen Profit`i' = F`j'.Profit
    }
   drop if missing(Profit3)
    
what is the significate of 1/3, because in the reality i need to make 
superposed rolled windows for 5 years and I want to know if I have to change 
the command and consider 1/5
Thanks a lot
 
-----Original Message-----
From: "Michael S. Hanson" <[email protected]>
To: [email protected]
Date: Tue, 27 Jun 2006 10:46:38 -0400
Subject: Re: st: superposed rolled windows

> On Jun 27, 2006, at 9:59 AM, irodriguez wrote:
> 
> > I have a panel data with firms, and profits for the period 
> > 1990/2004 No all the firms have the same period of data
> > I need to calculate others 4 columns for profit
> > superposing a rolling period window of 3 periods.
> > Example:
> > original data base
> > Firms    Years   Profits   
> > firm 1     1990     7
> > firm 1      1991     9
> > firm 1      1992      2
> > firm 1      1993       6
> > firm 1       1994      5    
> > firm 1       1995     4
> > firm 2      1990      3
> > firm 2      1991      2
> > firm 2      1992      1
> > firm 2       1993     3
> > ...
> >  
> > New data base
> >  Firms    Years   Profits1    Profit2   Profit3   
> > firm 1     1990     7                9         2
> > firm 1      1991     9               2         6
> > firm 1      1992      2              6         5
> > firm 1      1993       6            5          4
> > firm 2      1990      3             2           1
> > firm 2      1991      2              1          3
> >                                          
> > How can I do it
> 
> 
>    To work effectively with panel data, you should read -help xt-.  -help
> tsvarlist- will also be useful;  it will explain the forward operator 
> (the "F" in the -gen- command) used below.  -help forvalues- will 
> explain the looping.  Make sure you copy the quotes *exactly*:  the 
> left tick (`) and right tick (') are *not* the same character.
> 
> 
> tsset Firms Years     // Declare data as a panel
> forval i = 1/3 {
>      local j = `i'-1
>      gen Profit`i' = F`j'.Profit
> }
> drop if missing(Profit3)
> 
> 
>    Note: Be very careful about the -drop- command!  Although you stated 
> that you wanted your dataset to only have observations when 'Profit3' 
> was defined, you might be better off just leaving those observations in
> your dataset.  Most commands in Stata will deal with the missing 
> observations in a statistically appropriate manner.
> 
>    Hope this helps.
> 
>                                          -- Mike
> 
> 
> *
> *   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/


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