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

Sorting out problems with gaps in lags (Was Re: st: Re: xtreg v

From   "Clive Nicholas" <>
Subject   Sorting out problems with gaps in lags (Was Re: st: Re: xtreg v
Date   Sat, 19 Jun 2004 11:09:48 +0100 (BST)

I wrote:

> The second problem is that I wish to include a lagged term on the depvar.
> I know how to do this correctly (gen lag = l.edconch), but there are two
> problems here. First, there are gaps in the time series. Now I could use
> -tsfill-, but I want the lag to latch on the correct EDYEAR, rather than
> incorrectly onto a year for which there no elections. The second problem
> is that adding the lagged term knocks out a lot of the time dummies. Is
> there a way round this?

OK, I've found the solution to this, which I should have known:

. bysort pano (edyear): gen edid=_n if edmarker==1

Where EDMARKER is a -tag- variable marking out duplicates. Those
parentheses are very important! As I discovered, without them, Stata
generates a series of 1's. Then:

. tsset pano edid

Hopefully, this makes the rest of my post rather more digestible than it
was before!

CLIVE NICHOLAS        |t: 0(044)191 222 5969
Politics              |e:
Newcastle University  |
*   For searches and help try:

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