liveBook · Manning

Categorical data

As explained in Effective Data Analysis

A categorical variable is a variable whose values represent membership in distinct categories rather than measured numerical amounts.

Categorical data records membership in distinct groups rather than measured numerical amounts. Analysts must represent those groups appropriately before including them in models or comparisons. section 9.2.1

Common analytical treatments include:

  • Use dummy coding to represent each category as a separate binary variable indicating presence or absence. section 9.2.1
  • Omit one category when appropriate; its absence is then represented when all remaining category variables equal zero. section 9.2.1
  • Collapse categories into a meaningful binary variable when the grouped distinction better represents the analytical question. section 9.2.1
  • Use the chi-square test to compare one or two categorical variables through observed and expected frequencies in a contingency table. section 5.4

Choice of representation should connect to the decision being supported. A day-of-week variable can preserve behavioral information, support predictions for future days, and avoid unnecessary complexity when categories have similar outcomes. Analysts should weigh the effort and advantages of deriving additional variables rather than applying a fixed rule. section 9.2.1

Rat sightings by day of week

A daily New York City rat-sightings dataset derives a day-of-week column, examines distributions with boxplots, and dummy-codes the seven days. Because weekday categories show little difference, the analysis creates a single weekday indicator and checks its correlations with temperature, wind speed, and sightings. section 9.2.1

How Effective Data Analysis covers it

How deep it goes
Explains dummy coding, omitted reference categories, binary regrouping, visual checks, and chi-square testing, but not model internals.
Examples
Uses day-of-week categories, rat-sighting boxplots, dummy-coded predictors, and a weekday indicator in a weather dataset.
What you can do after
Apply it via dummy coding, binary regrouping, visualization, correlation checks, and chi-square comparisons.
How it connects
Connects categorical data with dummy coding, binary variables, linear models, correlation, chi-square tests, and contingency tables.

Also explained in

Compare how 16 books explain categorical data →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Effective Data Analysis. The section links point to the parts of the book it draws on.