0
$\begingroup$

Let's say I have a dataset where a data point contains information about a group of people. The group can consist of MALE, FEMALE, or BOTH - a variable group_gender. Should I code this as a factor with 3 levels: MALE, FEMALE, BOTH or to use an indicator variables MALE and FEMALE and use it like this.

If the group is MALE code it as: MALE 1, FEMALE 0 If the group is FEMALE code it as: MALE 0, FEMALE 1 If the group is BOTH code it as: MALE 1, FEMALE 1

Similarly, for each group I have age range which can be [18, 24], [25, 34], [35, 44], [45, 54], [55, Inf]. A group can consist of only single age range or it can be any combination of the age ranges.

I am planning to use the data in a logistic regression model.

Please provide some info why one approach is better then the other or the pros and cons of each approach.

$\endgroup$
  • 1
    $\begingroup$ Could you elaborate on this logistic regression? What is your theory concerning how the age and gender makeup of a group might be related to the response variable? $\endgroup$ – whuber Jun 11 '15 at 19:03
0
$\begingroup$

Personally, I think you might consider restructuring your data to better express the overlapping group structure to gender and age. For instance, maintaining the MECE (mutually exclusive, completely exhaustive) nature of that set of groups that are consistent or have a single gender and age assignment would be a start. Then, creating separate rows to decompose the overlapping age and gender categories to get them down to MECE rows would be the next goal. The challenge with this approach, of course, is that you may not have enough information to make such a decomposition even possible. I would have to see a sample of raw observations from your data to be able to say anything definite about this.

Is it possible that your data contains percentages for the proportion of the group that falls into each bucket and that you have, secondarily, reduced that down to 0s and 1s? If so, then I wouldn't use categorical coding as you've outlined. Rather, I would consider using the percentages as main effects and taking a few polynomials to fit your model(s).

If your original data is, in fact, in the form 0s and 1s, the approach you are suggesting amounts to dummy variable coding. I would argue that a better method might be to use effect coding. The advantages of effect coding are that the resulting matrix is orthogonal and you don't "lose" a row or level of the factor to estimating the model intercept (assuming the model has an intercept), i.e., you don't have to restrict one level to be all zero's. Here's an article on effect coding that shows how to do it for a 4-level categorical variable. That you have 3 possible levels for gender suggests using -1, 0 and 1 to capture all of the possible, orthogonal combinations:

http://www.ats.ucla.edu/stat/mult_pkg/faq/general/effect.htm

If age, too, is all 0s and 1s that is crazy and you might consider taking all of the possible combinations of age across the 5 buckets (and, come on, age doesn't range up to "Inf"), and treating the resulting cross-classified "string" as a new, qualitative factor as in an ANOVA. But this could be wasteful in terms of degrees of freedom if you don't have that many data points.

At the end of the day, the original information could not have been grouped like this. In other words, the data you are working with represents a second level of aggregation from the raw, raw data. Frankly, this is a really crappy way to have this information coded up and whoever did it should be fired.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.