[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
"Nick Cox" <n.j.cox@durham.ac.uk> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
RE: st: RE: Re: How to detect the change of i over t? |

Date |
Mon, 9 Feb 2009 15:58:23 -0000 |

No; I didn't mean that; but it is clearly another way to handle the possibility of missing values, with different results. Whether it is what Benson wants only Benson can say. Nick n.j.cox@durham.ac.uk Austin Nichols Nick-- I think you mean: tsset i t bysort i (t) : gen become = cond(mi(L.x,x), ., x == 1 & L.x == 0) since _n!=1 is no guarantee that x and L.x are nonmissing. On Mon, Feb 9, 2009 at 7:37 AM, Nick Cox <n.j.cox@durham.ac.uk> wrote: > Your primary concern should be the unbalanced panels. Does t - 1 mean > what it says, or you intend the previous observation? > > For _balanced panels_, one line of code > > bysort i (t) : gen become = x == 1 & x[_n-1] == 0 > > gets you most if not all of the way. > > The right-hand side (RHS) > > x == 1 & x[_n-1] == 0 > > is either true (numerically 1) or false (numerically 0). > > Benson is right to be concerned about boundary conditions. > > For the first observation in each panel, we are asking whether > > x[1] == 1 & x[0] == 0 > > subscripts being evaluated within panels under the aegis of -by:-. > > But x[0] is evaluated as missing, and the RHS will be 0 (false). > > If Benson wants . for the first observation in each panel, then you can > do this > > bysort i (t) : gen become = cond(_n == 1, ., x == 1 & x[_n-1] == 0) > > For _unbalanced panels_, you may want something more like > > bysort i (t) : gen become = cond(_n == 1, ., x == 1 & L.x == 0) > * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**References**:**st: How to detect the change of i over t?***From:*Benson Limann <benli2@live.com>

**st: Re: How to detect the change of i over t?***From:*"Martin Weiss" <martin.weiss1@gmx.de>

**st: RE: Re: How to detect the change of i over t?***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

**Re: st: RE: Re: How to detect the change of i over t?***From:*Austin Nichols <austinnichols@gmail.com>

- Prev by Date:
**Re: st: Estimating rare event logistic model (Relogit) with instrumental variable** - Next by Date:
**st: -triplot- revised on SSC** - Previous by thread:
**Re: st: RE: Re: How to detect the change of i over t?** - Next by thread:
**RE: st: Re: How to detect the change of i over t?** - Index(es):

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