Skip to content

0.1 Measurement Scales & Variable Types

Julio Toboso edited this page Oct 25, 2025 · 4 revisions

0.1 Measurement Scales & Variable Types

Purpose: choose the right summaries and charts by naming what your data is.

1) Variable families (what the thing is)

  • Categorical or Cualitative
    • Nominal (no order): color, country, user_id (identifier, not a “category” for averaging).
    • Ordinal (order, uneven steps): low/med/high, Likert 1–5.
  • Numeric
    • Interval (equal steps, no true zero): °C, dates.
    • Ratio (equal steps, true zero): length, income, counts.
    • Boolean: Logic (True/False)
  • Specials: datetime, text, geospatial, images.

2) What you may do (legitimate operations)

Scale Allowed ops (examples) Typical stats Typical visuals
Nominal =, ≠, mode, counts Mode, frequency % Bar chart, stacked bars
Ordinal order comparisons (<, >), median Median, percentiles Ordered bars, dot plot
Interval +/−, mean differences Mean, SD, z-scores Line (time), histogram
Ratio ×/÷, geometric mean, CV Mean, SD, ratios, rates Histogram, box plot, scatter

Heuristic: position > length > angle/area > color for quantitative precision.

3) Common pitfalls (and fixes)

  • IDs as categories: never average an identifier; use for joins/keys only.
  • Ordinal ≠ Interval: a 4 isn’t “twice” a 2 on a Likert scale; report medians/quantiles.
  • Unit traps: °C is interval (no true zero) → ratios like “30°C is 2× 15°C” are invalid; Kelvin is ratio.
  • Implicit missingness: “0” might mean “unknown”; encode NaN/NA explicitly.
  • Re-encoding danger: integer-coding categories does not make them numeric.

4) Mapping to pandas (practical handles)

Concept pandas dtype / tool Note
Nominal category / string Memory-friendly categories.
Ordinal CategoricalDtype(ordered=True) Define order explicitly.
Interval float64, datetime64[ns] Beware time zones.
Ratio int64 / float64 Keep units in column name.
Binary bool Encode missing as pd.BooleanDtype().
Datetime to_datetime, dt accessor Store as UTC internally.
Geo geopandas.GeoDataFrame (geometry) Track CRS; don’t mix.

5) Mini-checklist (before any analysis)

  1. Name each column’s scale (nominal/ordinal/interval/ratio).
  2. Set dtype accordingly (categories ordered where needed).
  3. Write the unit and missingness policy.
  4. Choose summaries & charts that the scale permits.

Scale → Valid Statistics & Plots: Decision Table

Scale Permitted comparisons / operations Safe descriptive stats Bad/misleading stats to avoid Recommended plots
Nominal equality / membership counts, proportions, mode mean, standard deviation, correlations bar charts (counts / proportions), mosaic
Ordinal order, ranking, percentiles median, percentiles, rank‑based mean on raw codes, linear regressions ordered bar, box / violin by group (on ranks)
Interval differences meaningful (no absolute zero) mean, standard deviation, z‑scores ratios (e.g. “twice as big”) histogram, KDE, line plot
Ratio full arithmetic ( + − × ÷ ) mean, geometric mean (if >0), CV (still avoid mixing types blindly) histogram (possibly log scale), scatter

Rule of thumb: If your data is non‑numeric or has arbitrary codes, treat as nominal/ordinal — don’t compute mean or Pearson correlations until it's truly interval/ratio.

Data

Legend:

  • 🔰 Start here
  • 🏵️ Important Insight
  • ⚙️ Technical and applications
  • 💻 Some Code
  • ⚜️ Advanced Topics

Start

01 · Ω — What could happen

02 · X, 𝒳 — What we observe

03 · p(x) — What we expected

04 · I(x), H(X) — What an observation tells us

05 · Data — What is consistent

06 · Statistics — What we can learn.

07 · Databases - How to store data

08 · μ(x) — Fuzzy - When data is flexible

  • 08.1 Fuzzy Logic (planned)
  • 08.2 Fuzzy Numbers (planned)
  • 08.3 Possibility vs Probability (planned)

09 · x(t) — Signals and systems - Where patterns live

  • 09.1 Signals (stub)
  • 09.2 Sampling and Aliasing (planned)
  • 09.3 Convolution (planned)
  • 09.4 Frequency (planned)

10 · f_θ — Modelling and linear algebra

  • 10.1 🔰 Vectors and Matrices (planned)
  • 10.2 Mathematical Modelling (planned)

11 · min L(θ) — Optimisation

  • 11.1 🔰 Derivatives (planned)
  • 11.2 Convex Optimisation (planned)

12 · Learning from data

13 · Cause, design, capstone

  • 13.1 Cause and Effect (planned)
  • 13.2 Capstone Guide (planned)

Appendix

Clone this wiki locally