Module 4 — Graphs

Question: what does the distribution actually look like? Numbers summarize; pictures reveal shape, outliers and comparisons at a glance.

Open the sample (Ctrl+Shift+O). Charts land as cards in the Output View, interleaved with tables; right-click a card to copy it as an image straight into a document.

Histogram — one scale variable's shape

Graphs → Histogram… (Ctrl+Shift+H), variable BMI, Run.

A roughly bell-shaped pile centred in the mid-20s with a right tail — real BMI data look like this too. Re-run with the bins slider at different values: more bins show more detail and more noise. The bins are display only — they change no data. (Turning BMI into actual categories is a transform — module 8.)

Boxplot — a scale variable across groups

Graphs → Boxplot… (Ctrl+Shift+B), variable SystolicBP, category SmokingStatus, Run.

Each box is a group's median and quartiles, whiskers and outlier points. The Current box should sit visibly higher — the picture version of the test you will run in module 6.

Line Chart — a trend across a scale variable

Graphs → Line Chart… (Ctrl+Shift+L), Y series SystolicBP, X axis Age, split by SmokingStatus, Run.

health_study is one row per participant, not one row per visit, so this connects each smoking group's points in age order rather than tracing a single patient over time — the mechanics are the same chart you would use for a real time series (repeated visits, a stock price, a sensor log). Turn on point markers to see the individual participants along each line.

The Chart Builder

Graphs → Chart Builder… (Ctrl+Shift+G) is the general dialog: pick the chart type, assign variables to its roles. Rebuild the boxplot above in it, then try a Scatterplot of BMI (X) against SystolicBP (Y) — the cloud should visibly climb, previewing module 7's correlation.

Exercise

  1. Histogram of FastingGlucose_mmolL. There is a small second bump well to the right of the main pile — what is it? (Codebook: a diabetic-range cluster.) Note that the declared-missing 99s are not in the plot.
  2. Boxplot of BMI by Sex. Do the medians differ much?
  3. Scatterplot Age (X) vs HeartRate (Y). Describe what "no relationship" looks like — you will want this picture in mind whenever a correlation comes out near zero.

The syntax trail

histogram variable=BMI
boxplot variable=SystolicBP, category=SmokingStatus
line_chart y=[SystolicBP], x=Age, split=SmokingStatus
scatter x=BMI, y=SystolicBP