4
$\begingroup$

currently I'm trying to model a response variable y, and I have zip code as my independent variable, my model is logistic regression. When it comes to nominal variable, the text book method is to create k-1 dummy variable (assuming the nominal variable have k different levels), but zip code's k is too big, I can't create that amount of dummy variables, is there any other ways to deal with this?

Or more generally, how to deal with nominal variables with too many levels (k>=100)?

$\endgroup$
  • 1
    $\begingroup$ there are a few options that I know of, none great. One common option is to convert zip code into another continuos variable - usually some measure of social economic status and use that variable in the regression. this makes sense if you're using zip code as a surrogate. $\endgroup$ – charles Mar 12 '14 at 22:27
  • $\begingroup$ @Charles It is difficult to see how a continuous version of a zip code could be used as a surrogate for anything. $\endgroup$ – whuber Mar 28 '14 at 16:53
  • 1
    $\begingroup$ @whuber if zip code is being used as a marker for distance from something or socioeconomic status (1) zip--> distance (2) zip--> SES index. So only possible if you are using zip code was measured because it was thought to be a reasonable surrogate for distance or SES. $\endgroup$ – charles Mar 28 '14 at 19:21
  • $\begingroup$ @charles Unfortunately that's not how zip codes work. If in fact they are intended to be surrogates for SES data, then it's far better actually to use those data. Except in localized areas zip codes as a "continuous" variable will bear little relationship to any SES variable. $\endgroup$ – whuber Mar 28 '14 at 19:24
  • $\begingroup$ @whuber I do think that there is some merit to the argument of charles. See this infographic which details how zip codes are associated with different income levels and levels of education: washingtonpost.com/sf/local/2013/11/09/washington-a-world-apart $\endgroup$ – goldisfine Jun 24 '14 at 18:06
2
$\begingroup$

Instead of ZIP code use something else. Some options:

First 3 digits of ZIP code - this might work if you had data from a medium sized region; it would not work if you had data from the whole USA

County - not great but used often. Problem is counties vary greatly in population.

Congressional district - these are weird geographically, but have roughly equal populations

State - has some problems with population size (although at least all are large).

Region or division, as defined by the Census . Other people have come up with other variations of regions.

you might also be able to combine county, state, region or division with a variable for urban/suburban/rural

$\endgroup$
0
$\begingroup$

I'm not sure whether this is 100 percent valid, but one thing that strikes me is that you might convert all zip codes where the number of observations is too small to an 'other' zip code. So then your zip code column would contain zip codes where the number of observations, N is greater than some cutoff k.

If you're regression your dependent variable on zip and some additional regressors, then when the number of observations is sufficient to measure the effect of a zip code, then you should be fine. Otherwise, when the number of observations is too few, it will regress on the other category, which will probably have no relationship with the response, but will allow you to keep those observations in the model and consider other predictor variables.

$\endgroup$
  • $\begingroup$ why the downvote? $\endgroup$ – user90772 Jul 9 '17 at 10:30
-5
$\begingroup$

use bit code to do this. for example if a nominal variable have 1000 categories, then use variable u1,u2,u3... u10 then represent each category as binary number i.e. level 10=1010 then use u4-u1 to represent them

$\endgroup$
  • 3
    $\begingroup$ Unless you have some special clever way to process these codes in your statistical procedures, this method will have the doubly unfortunate characteristic of (a) actually allowing the procedures to produce output that (b) is wholly erroneous. $\endgroup$ – whuber Mar 28 '14 at 16:52

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.