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]
st: Assign year to observations (failures) based on proportion of successes in each year.
From
Brad Fedy <[email protected]>
To
[email protected]
Subject
st: Assign year to observations (failures) based on proportion of successes in each year.
Date
Sat, 12 Jun 2010 00:17:44 -0600
I am interested in conducting a logistic regression with success=1 and
failure =0. My success cases have a specific year associated with
them - my failures do not. I have annual columns for each covariate
that are structured as: x_year, e.g. x_1998, x_1999, x1_1998, x1_1999.
I have extracted the correct annual covariate value for the successes
(1) using code similar to this:
gen x_correct=.
forval i=1998/2008 {
replace x_correct if x_year == `i' & success==1
}
I have many more failures than successes. I want to assign a
particular year to each of the failures. I want to distribute the
assignment of years to the failures based on the proportion of
successes that fell in a particular year. For example: if 25% of the
successful observations were in 1998, and 75% in 1999 I want to assign
a year value of 1998 to 25% of the failures and 1999 to the remaining
75% of the failures. The data is panel structured, and therefore I
have to do this across multiple grouping variables e.g. households.
I would really appreciate any suggestions.
Thanks,
*
* 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/