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

st: RE: Lags (verification)


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: Lags (verification)
Date   Mon, 11 Nov 2002 16:48:35 -0000

Maureen Paul
> 
> Just would like to verify that the following works. I am 
> mainly concerned because the gap between the last two years 
> is three while for the others the gap is two.
> Here goes:
> I have data for years 1991 1993 1995 1997 and 2000. I would 
> like to create the lags of a variable LAGVAR, this is what 
> I have done:
> 
> ge LAGVAR1=VAR-L2.VAR
>           foreach i of numlist 2000 { replace LAGVAR1=. if 
> wave==`i' }
> ge LAGVARl2=LAGVAR-L3.LAGVAR
> 	foreach i of numlist 1991 1993 1995 1997 { replace 
> LAGVAR2=. if wave==`i' }
> ge LAGVAR=LAGVAR1 if LAGVAR1~=.
> replace LAGVAR=LAGVAR2 if LAGVAR2~=.
> 

I am not clear what you are 
trying to do: every lagged result depends 
on your previous setting of a time 
variable, which is not spelled out 
here. 

In general, note that the d. operator
is available to create differences, 
so it should not be necessary to 
create your own. 

You have two choices, it seems: 

1. regard the years 1991 ... 2000 
as times 1 ... 5 and -tsset- in 
terms of those times. 

2. regard years as the time variable, 
in which case it would seem that 
all your lagged values and differences
are inevitably missing, as no two years are 
consecutive. 

Nick 
[email protected] 
*
*   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