Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[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
Erik Aadland <[email protected]>
To
<[email protected]>
Subject
RE: st: Calculating months since entry into risk set by actor_id and month
Date
Mon, 3 Sep 2012 09:07:19 +0000
Thank you so much, Nick.
Kind regards,
Erik.
> Date: Fri, 31 Aug 2012 15:42:01 +0100
> Subject: Re: st: Calculating months since entry into risk set by actor_id and month
> From: [email protected]
> To: [email protected]
>
> 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 <[email protected]> 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.
> From this point on, I follow this actor monthly (MONTH) tracking
> whether the actor "gets sick" or not (EVENT). If the actor actor "gets
> sick", the actor is given an event score 1 as opposed to 0. If the
> actor never gets "sick" the actor is right censored at the end of the
> observation period.
> > By ACTOR_ID MONTH, I want to calculate the number of months since ACTOR_ID entered the risk set (or "contracted the infection) yielding the variable WANTED.
> > The dataset looks like this:
> > MONTH ACTOR_ID EVENT WANTED
> > 1 1 0 0
> > 2 1 0 1
> > 3 1 0 2
> > 4 1 1 3
> > .. .. ..
> > 1 2 0 0
> > 2 2 1 1
> > .. .. ..
> > 3 3 0 0
> > 4 3 0 1
> > 5 3 0 2
> > 6 3 0 3
> > 7 3 0 4
> > 8 3 1 5
> > Any input on this problem would be very much appreciated.
> *
> * 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/
*
* 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/