Day 40 of 55Stage 4 · ImproveFridayNon-linear regression and Box-Cox

When the line bends

Missed appointments don't rise in a straight line as waits grow, and waiting times aren't normal. Amara learns two tools for data that doesn't fit the usual mould.

Stage goal: Test and put in place solutions that remove the root causes.
Team
Astrid (Data Analyst)
Stakeholders
Augustin (Black Belt)
How the day goes
  1. 09:00Missed appointments by days booked ahead, with Astrid (Data Analyst)
  2. 11:00Fit a curve with Augustin (Black Belt)
  3. 15:00Box-Cox with Augustin (Black Belt)

Situation 1 of 2

09:00 · Missed appointments by days booked ahead, with Astrid (Data Analyst)
Astrid (Data Analyst)
The straight line has R² 0.90. That's good, isn't it?

What else do you look at?

A pattern in the residuals means the model has the wrong shape. Try a curve, and compare adjusted R².
Worked example 1

A curve, not a line

Astrid (Data Analyst) plots the share of appointments missed against how many days ahead they were booked, in 2-day groups.

Missed appointments against days booked ahead, with the fitted curve01020304007142128Days booked aheadMissed (%)1, 7.53, 6.45, 137, 14.89, 17.311, 19.613, 19.315, 22.717, 23.319, 28.921, 26.423, 26.525, 27.227, 27.3
Days booked aheadMissed (%)
17.5
36.4
513
714.8
917.3
1119.6
1319.3
1522.7
1723.3
1928.9
2126.4
2326.5
2527.2
2727.3
Download the data (spreadsheet file)
  1. Straight linemissed = 8.3 + 0.837 × days; R² 0.896
  2. Check the residualsnegative at both ends, positive in the middle: a curve the line misses= pattern
  3. Quadraticmissed = 4.18 + 1.717 × days − 0.0314 × days²
  4. Compare fitsadjusted R² 0.954 against 0.896 for the line= curve fits better
  5. Predict at 4 days4.18 + 1.717 × 4 − 0.0314 × 16= 10.5%
  6. Predict at 10 days= 18.2%
What it meansMissed appointments rise quickly in the first two weeks of waiting, then level off. Cutting the typical wait from 10 to 4 days should cut missed appointments from about 18% to about 10%.
What Amara decidesUse the curve, not the line, to estimate the effect of shorter waits on missed appointments. Never use it beyond 27 days, outside the data.
Try it yourself in a spreadsheet
Quadratic fit=LINEST(B2:B15,A2:A15^{1,2})
Chartscatter chart, then Add trendline, Polynomial, order 2, show equation and R²
Prediction=b0 + b1*4 + b2*4^2

Why not use the curve to predict the missed rate for appointments booked 60 days ahead?

Show the answer

The data only goes to 27 days. Outside the data a quadratic can bend in ways reality doesn't (here it would start to fall). Never extrapolate a fitted curve.

Situation 2 of 2

11:00 · Fit a curve with Augustin (Black Belt)
Augustin (Black Belt)mentor
Many tools want normal data. The Box-Cox method finds the power that makes your waits most normal. It says λ is almost zero.

What does that mean?

Box-Cox finds the power transformation that makes data most normal (λ = 0 is a log). Always check the results against the real data.
Worked example 2

Box-Cox: making skewed data usable

The 60 waits are skewed. Augustin (Black Belt) shows how a Box-Cox transformation finds the power that makes them most symmetrical.

RequestWait (days)
R0112
R0213
R0312
R0428
R0511
R0612
R0716
R087
R093
R104
R114
R1210
R134
R1417
R155
R168
R175
R185
R195
R2020
R213
R2215
R235
R249
R255
R265
R2715
R2815
R2914
R3013
R3118
R3216
R333
R345
R3510
R367
R376
R3810
R3910
R405
R415
R424
R435
R446
R457
R4611
R4711
R483
R4913
R5026
R5112
R5222
R5327
R5418
R554
R5614
R5720
R583
R596
R6019
Download the data (spreadsheet file)
  1. Box-Coxtries powers λ of the data (y to the power λ; λ = 0 means the logarithm) and picks the most normal
  2. Best λfound by the method= 0.015, so a log
  3. Transformlog of each wait
  4. Shape afterskewness 0.91 before, −0.02 after= tail gone
  5. Normality afterAnderson-Darling p about 0.01: whole-day values create ties= much closer, not perfect
  6. Use it: capabilitylog mean 2.152, log s 0.639; share over 7 = share of logs over ln 7 = 1.946= 63% predicted, 55% observed
What it meansThe log removes the skew, which makes many tools usable. But the transformed model predicts 63% of waits over 7 days, while 55% actually are. Always check a transformed model against the real data.
What Amara decidesReport the observed share for capability. Use the log scale when a test or model needs normal data, and check its predictions against reality.
Try it yourself in a spreadsheet
Log=LN(B2)
Skewness after=SKEW(C2:C61)
Share over 7 from the log model=1-NORM.DIST(LN(7),AVERAGE(C2:C61),STDEV.S(C2:C61),TRUE)

What does λ = 0.5 mean, and when would Box-Cox choose it?

Show the answer

The square root. Box-Cox picks it when the data is moderately skewed, such as counts; λ = 1 means no change is needed.

Key concepts

The ideas behind today. Concept how the work is done, in our own words · Common practice widely used ways of working.

Common practice

Curved relationships

  • When residuals show a curve, add a squared term or transform the input. Compare the fits on adjusted R² and the residuals.

Where you will meet this: Non-linear (polynomial) regression

Common practice

Transforming data

  • Box-Cox finds the power λ that makes data most normal: 1 no change, 0.5 square root, 0 logarithm, −1 reciprocal. Transform limits too, and check results against the real data.

Where you will meet this: Box-Cox transformation · data transformation

Concept

Never extrapolate

  • A model describes the range of its data. Outside it, especially for curves, predictions can be badly wrong.

Explained in our own words. This helps you understand the concepts behind the certifications; it does not reproduce or replace any official guide. Sources

Day 40 complete

2 situations today.

Your responsibility todayHandling curved and skewed data
Technique you usedNon-linear regression, Box-Cox transformation
Key points to remember
  • A pattern in the residuals means the model has the wrong shape. Try a curve, and compare adjusted R².
  • Box-Cox finds the power transformation that makes data most normal (λ = 0 is a log). Always check the results against the real data.