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: Re: How do I create a calendar year variable by person id before reshaping to person-year dataset?
From
Holly E Reed <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: st: Re: How do I create a calendar year variable by person id before reshaping to person-year dataset?
Date
Thu, 13 Feb 2014 15:29:09 +0000
Well, thank you for trying, Nick. I appreciate you following up. I'll let Statalist know
if I ever solve the problem.
Best regards,Holly
__________________
For completeness: sorry that I didn't reply, I didn't see that your
extra detail changed my impression that your data structure is fine as
it is. I was hoping that someone who does more of what you do would
chime in, but they didn't.
I couldn't comment on your failed attempt to replicate what you did previously.
Nick
[email protected]
On 12 February 2014 19:08, Holly E Reed <[email protected]> wrote:
> I am reposting this as I never received a reply to my last question. I hope that someone can help me to figure out the best way to approach this.
>
> I am trying to create a person-year dataset for use in a binomial logit event history model. I want to have one observation for each year of a person's life (one record per person-year), but I also need the calendar years as the variables, so that I can create covariates such as whether a woman had a birth in a particular year (0/1 dummy), whether a woman moved in a particular year (0/1 dummy), etc. There will be some non-time-varying covariates, of course, but for the data where I do have time covariance, I want to create dummies for events in each specific year.I will probably create parity as a covariate also, as Steve mentions, but the main question of interest is whether a woman gives birth in a particular year (this will be lagged by one year) and whether that predicts the probability of migration in the next year.
>
> Does that make sense? If you have a better suggestion, please let me know. I did create a migration dataset from this same data several years ago, but I did not have the birth data at the time and I simply want to merge it with the migration dataset I already have, but I need it to be in the same format and I can't seem to get it work the way it did the last time.
>
> Thanks,
> Holly
> ______________
> As you point out, Nick, Holly has not told us what she wants to do. I'm
> not sure either, as she's tried reshapes both long and wide.
>
> I've analyzed many data sets of reproductive histories, and I always use
> the long format. With this format, it's easy to create running totals of
> different kinds, for example parity, the number of births + stillbirths
> at a given time. We also can merge in dates of different risk factor
> exposures and so easily assign a prior or recent exposure to each
> pregnancy. In fact, we always *collect* the data in long format,
> as it shortens the codebook and greatly simplifies the edit process. It
> also allows a woman to recall a pregnancy out of order, because one
> can re-order by date.
>
> Steve
> [email protected]
>
>
> On Feb 6, 2014, at 6:14 PM, Nick Cox <[email protected]> wrote:
>
> Thanks. That helps. I have already explained why -reshape wide-
> doesn't work. -reshape- maps one variable to several, but the "birth"
> you feed to it is the stub for several variables.
>
> Otherwise, I don't see why you want or need to -reshape- at all.
> Several variables are repeated for each woman and some vary. Depending
> on what you want to do, you either reduce the dataset by removing
> duplicates or keep the whole dataset.
>
> Alternatively, if you explain why you (think you) need to -reshape-
> that might illuminate what is being misunderstood, or what you need to
> do.
> Nick
> [email protected]
<snip>
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/