# How to include 29 colleges as an independent variable in logistic regression

I am working on a model that predicts gestation period of new hires. By gestation period, I mean the period between when they completed their training and the time they start working on their first real live project. I have data for gestation period in months. I classified the time into two parts - "0 - 3 months" and "3 months or more". The purpose of the model is to reduce gestation time. It means the HR will recruit from only those colleges in which the students had performed well in the past and they went live early (i.e., low gestation time).

I have run logistic regression using gestation time as dependent variable - 1 for "0-3 months" and 0 for "3 months or more".

The independent variables are their college names, education qualification, specialization subject, graduation scores, training scores etc. Under the college name variable, I have data for 29 colleges. In other words, there are 29 options in this variable. How can I use this information as an independent variable in developing a predictive model? Should I take "1-29" options? Or is there any other way to group the data for this variable in logistic regression? Are there any other statistical technique you would suggest?

• It would seem more useful to predict exact gestation time and then bin it at the end if you really want to. As for including college as an independent variable, the standard ways to start would be to include it as either a fixed or random effect. Any introductory book on linear models will help with that. Jun 16, 2014 at 17:16

A few points

1. This sounds like a survival analysis/event history analysis model (e.g. discrete time survival analysis, Cox proportional hazards model, etc.) because you are measuring time to event (time to working on first project). Such models are described as explaining the probability of whether and when an event will occur.

2. It also sounds like it is a mixed model because of the colleges.

These two points are quite compatible, as the hierarchical data format required for event history analysis is more or less precisely what is needed for mixed models as well. My suggestion would be to nest individual employees within colleges, so you might have (in the discrete time case) a college-person-period data format like this:

College   PersonID    Period    FirstProj  Covariates
1         1           1         0
1         1           2         0
1         1           3         1
1         2           1         0
1         2           2         1
2         3           1         0
2         3           2         0
2         3           3         0
2         3           4         0
2         3           5         0
2         3           3         1


The first three variables are identifiers of the factor/unit at-that-level defining the data hierarchy. Notice that these variables are sorted which is necessary to do explicitly in many statistical software packages for these kinds of analyses. Note also the the variable Period is not calendar time, but time that the subject was observed so the beginning of study time (perhaps in work days, or in weeks, depending on your needs) corresponds to the value 1 for every subject, even though they were began training/were first observed on different calendar dates.

The College-level residuals will tell you which colleges are at either extreme. Such models will also permit college, individual, and period-level (time-varying) predictors.

• Given the nature of the question, it would seem to be important to clarify that the numbers for College and PersonID in this example are not meant to be used in the models as numeric values per se but as factor identifiers. Explaining the meaning of FirstProj would also be essential for any readers who are not familiar with how survival data tend to be encoded.
– whuber
Jun 16, 2014 at 18:36
• Thank you! I still wonder about one thing, though. The sorting by College and PersonID appears to be meaningless, because these things have no natural order and therefore their numeric values are just unordered factors. But the numbers used to encode Period do matter, because there is a natural temporal ordering to this variable. Therefore this must be maintained and analyzed either as an ordered factor or as a number (a "continuous variable"), but not as a factor. Even better--as @Gregor has suggested--Period should be replaced by the actual gestation time.
– whuber
Jun 17, 2014 at 19:34
• @whuber Period is the units by which gestation time is measured ("period" is a common way of describing length to event in the literature). Don't know what to tell you about the sorting, but it does indeed make a difference from implementation to implementation. I don't think this is a stats issue per se, but an algorithmic issue. Jun 18, 2014 at 0:41
• I am curious about what implementations (statistical platform?) you have encountered whose calculations are dependent on the physical order in which the data have been stored. This makes for such unreliable computing--and so thoroughly violates fundamental rules of data management--that it's an important issue to pursue. (I have not seen any platforms that behave like this in over 30 years.)
– whuber
Jun 18, 2014 at 14:02
• And in fact, from the MLwiN manual "Sorting your data set The most common mistake new users make when trying to fit a multilevel model to their data set is that they do not sort the data set to reflect the data’s hierarchical or nested structure. (This is an easy mistake to make.) All the examples in this manual have already been sorted into the correct structure — students within schools, in the case of the data set used in the previous chapters." Jun 18, 2014 at 17:18