Hi All, I have data on the sequence of births for families with completed fertility cycle (in a data frame); the relevant variables are called b1, b2, b3, b4, b5, b6 and record the birth of the first, second, ..., sixth child. So, b1=1 if the first birth is male, b1=2 if the first birth is female, and b1=NA if the family did not record any first birth.
Similarly for b2, b3, b4, b5 and b6. I want to record the positions of the male children within their family's birth history. So, I was thinking of creating six variables boy_1, boy_2, ..., boy_6. boy_1 would record the position of the first boy, boy_2 would record the position of the second boy and so on till boy_6. I want to assign a value of zero to boy_i if the family in question did not have the i_th boy. I am not sure how best to do this (i.e., whether to create variables as I have suggested or do something else) and would appreciate any suggestions. Later, I want to use the information on the position of the male births to compute a likelihood function and do an MLE. Here is how my data frame would look: b1 b2 b3 b4 b5 b6 1 2 1 2 NA NA 2 2 NA NA NA NA 1 2 1 1 1 NA 2 1 NA NA NA NA 1 NA NA NA NA NA 2 1 2 1 NA NA Thanks in advance. Deepankar ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.