I have a data set of 4 predictors and 1 response, all of which are categorical.

I'm looking to answer questions like: (for the sample below) Of the weapons in predictor, which one best correlates to not dying? Can someone point me in the right direction or towards a tutorial?

I'm working in Python so a library would be helpful but I most need the model and the explanation because it's been a good few years since my university stats classes.

Sample data set:

     Setting  |  Gender  |  Weapon  |  Time_of_day  || Outcome  
     Urban    |  Male    |  Knife   | Dawn          || Dead 
     Urban    |  Male    |  Gun     | Dawn          || Dead  
     Forest   |  Male    |  Gun     | Noon          || Alive  
     Urban    |  Female  |  Knife   | Night         || Alive  
     Highway  |  Male    |  Gun     | Dawn          || Alive
     Urban    |  Female  |  Knife   | Dawn          || Dead
     Forest   |  Female  |  Rope    | Noon          || Injured
  • $\begingroup$ Some measures of association between categorical (nominal) variables are given in this answer. A python implementation is described here. $\endgroup$
    – GeoMatt22
    Commented Aug 30, 2016 at 22:30

1 Answer 1


The linked answer on the comment might lead you to use of chi-square test of independence, but I am not sure this is what you are looking for. I recommend using logistic regression. Here, multinomial logistic regression should be preferred because the response variable has multiple unordered categories. But you can also recode response variable into binary categories (say, 0 "Alive" 1 "Dead"; by recoding "Injured" also as "Alive", etc.) and use binomial logistic regression (or simply logistic regression). This might be easier to understand, because the independent variable(s) can be interpreted as increasing/decreasing the odds of dying.

Another issue is about the independent variables. They are also categorical (and nominal) variables, so you should recode them into dummy variables and then include in the analysis. The important point is having one category as your reference category (by excluding from the model). So, let's say you have three dummies derived from Weapon variable: Knife (1 "Knife", 0 "Other"), Gun (1 "Gun" 0 "Other"), and Rope (1 "Rope" 0 "Other"). Assuming that Gun is your reference category, interpretation will be something like this: "Using a gun compared to using a knife would increase the odds of dying by a factor of X".

Maybe this is not exactly what you want ("which one best correlates to not dying"), but I think it gets close considering that the variables are categorical. I am not a Python user, but here is a tutorial explaining how to do logistic regression in Python, as well as how to create dummy variables.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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