Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: Calculating months since entry into risk set by actor_id and month


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Calculating months since entry into risk set by actor_id and month
Date   Fri, 31 Aug 2012 15:42:01 +0100

The variable -wanted- (NO SHOUTING PLEASE ERIK) is in this example just

bysort actor_id (month) : gen wanted = _n -  1

I don't see what you desire if there is right censoring at the end,
but some technique is indicated by

bysort actor_id (month) : gen wanted = cond(event[_N] == 1, _n - 1, .)

Under -by:- the final value of -event- for each actor is just -event[_N]-.

Nick

On Fri, Aug 31, 2012 at 3:23 PM, Erik Aadland <erikaadland@hotmail.com> wrote:

I have an event history dataset in which actors enter the dataset at
different points in time. Entry into the dataset constitutes the onset
of risk, or "contracting the infection" if you will, for that actor.


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index