Why does a cubic dose term give an absurd prediction for a dose above anything in the training data?
answer
- nothing constrains the fit off-range
- the highest power wins eventually
- the in-range cancellation stops holding
- natural spline tails are straight lines
- guard the scoring input, do not model it
basics
~20 sPolynomial terms grow without bound, so once you leave the fitted range the highest power dominates and the prediction diverges. Least squares constrains the curve only where observations existed, and nothing pins down the tails.
solid answer
~50 sInside the observed dose range, a cubic can imitate a plateau by having its terms nearly cancel, and that cancellation is calibrated only over the range the fit actually saw. Push the dose 30% beyond the largest observation and the balance breaks: the cubic term grows as the cube of the input and swamps everything else, so the prediction shoots off in whichever direction that coefficient points — often to a response above 100% or below zero. A natural cubic spline behaves better at the edges because it is constrained to be linear beyond its boundary knots, so extrapolation degrades into a straight-line continuation instead of a cubic explosion. It is still extrapolation and still unverified, so in production I would guard the scoring path: flag inputs outside the training range and clamp or withhold rather than serve a number the data never supported.
go deeper
Recall that a fitted model is only supported over the range of inputs it was trained on, and that polynomial terms grow explosively once you leave that range.
Explain that the highest power dominates outside the fitted range so the in-range cancellation breaks down, and that a natural cubic spline is constrained to straight-line tails beyond its boundary knots.
Show the operational response: record and ship the training range, guard scoring inputs against it, monitor for drift past the boundary, and prefer a basis whose failure mode is bounded.
Own the contract at the boundary — whether the system refuses, clamps or flags an out-of-range input, how the model's domain of validity is published, and who is accountable when a score is served outside it.
## Least squares says nothing about where there was no data A fitted model is a function defined over the whole real line, but the fitting procedure only ever looked at the range the training inputs covered. Every coefficient was chosen to reduce squared error on those rows. Outside that range the curve is not a prediction supported by evidence; it is whatever shape the chosen basis happens to continue into. That is bearable for a straight line, whose continuation is at least gentle and inspectable. It is not bearable for a polynomial. ## Why polynomial tails explode Consider a drug dose-response fitted with dose, dose squared and dose cubed. The measured response rises with dose and then flattens into a plateau at the top of the tested range. A cubic can imitate that plateau, but only by arranging its terms to cancel: a large positive linear term is offset by a negative quadratic and a positive cubic, and the three roughly balance over the tested doses. The balance is a numerical accident of the fitting range, not a property of the biology. Step outside that range and the cancellation collapses, because the terms grow at different rates. At twice the maximum tested dose the cubic term is eight times larger than it was at the boundary while the linear term is only twice as large. The highest power always wins eventually, so the fitted response either rockets upward or plunges below zero within a short distance of the boundary. Predicting a 340% response, or a negative one, is the visible symptom of a structural fact about the basis. ## What a natural spline changes A cubic spline divides the range at knots and fits a separate cubic on each segment, joined so that value, slope and curvature match. Beyond the outermost knots it is still cubic, so it shares the polynomial's tail problem — and this is why plain cubic splines show very wide uncertainty at the edges of the data. A **natural** cubic spline adds boundary constraints: the fitted function is forced to be **linear beyond the boundary knots**. Those constraints remove degrees of freedom relative to an unconstrained cubic spline on the same knots, and they buy two things. Inside the range, the fit is stabilised near the edges where data is thinnest. Outside it, the continuation is a straight line taking off at the boundary slope, which is a bounded, inspectable guess rather than an explosion. So for the dose-response with a plateau, the two bases give visibly different tails: the cubic terms diverge, the natural spline continues at roughly the plateau's slope. Neither has any evidence behind it. ## Production practice Because no basis makes extrapolation trustworthy, the engineering answer is to control it rather than model it. **Record the domain of validity.** At training time, store the minimum and maximum of every input the model was fitted on, and ship those bounds with the model. **Guard at scoring time.** When a request arrives with a dose above the recorded maximum, the service should do something deliberate: reject it, clamp the input to the boundary and mark the response as clamped, or serve it flagged as an extrapolation. Silently returning the number is the failure. Which of the three is right depends on the cost of a wrong answer, and for anything clinical or financial that decision is a policy question, not an implementation detail. **Monitor the input distribution.** The situation almost never announces itself as one exotic request; it arrives as drift, with the scored population creeping past the range the model was fitted on over months. **Encode known shape instead of trusting the fit.** If the pharmacology says the response saturates, a basis or constraint that saturates — a monotone fit that levels off, or a spline whose tail is deliberately flat — represents the knowledge directly instead of hoping a flexible curve behaves at the boundary. ## The interview point The answer that lands is not 'the model overfitted'. It is that basis expansion buys in-range flexibility and says nothing whatever about out-of-range behaviour, that different bases fail differently out there, and that the professional response is to know your model's valid domain and defend it at the boundary rather than to chase a basis that extrapolates well.
- How would you detect this failure before your users do?Ship the training range with the model and check every scoring request against it, alerting when a feature leaves the interval. Watch the scored input distribution over time, because this usually arrives as slow drift rather than one exotic row. And before release, deliberately score synthetic inputs beyond each boundary and look at what the model returns.
- Does a natural spline make extrapolation trustworthy?No. It only changes the failure mode: the continuation is a straight line leaving the boundary at the boundary slope, rather than a cubic that diverges. That is bounded and inspectable, which is a real improvement, but it is still a guess with no observations behind it. Trustworthiness comes from data in the range, not from the basis.
- The pharmacology says the response plateaus. Can you build that in directly?Yes, and you should. Rather than hoping a flexible basis happens to flatten, impose the shape: fit under a monotonicity constraint, or use a basis whose tail is deliberately flat above the top knot. Encoding known structure costs a little flexibility and removes an entire class of implausible predictions.
- Why do plain cubic splines show such wide uncertainty at the edges of the data?Because the outermost segments are unconstrained cubics fitted from the fewest observations, so their curvature is poorly determined and small data changes move them a lot. The natural-spline boundary constraint forcing linear tails is precisely what narrows those edge bands.
A tailor fits a suit to the person in front of them. Asked what it would look like on someone twice as tall, the pattern gives an answer, but it is arithmetic rather than tailoring.
saying these in an interview costs you the question
- Assumes the fit is valid anywhere the arithmetic is defined
- Blames the training data instead of the basis's unbounded tails
- Claims a natural spline makes extrapolation reliable
- Proposes a higher-degree term to fix out-of-range behaviour
- Serves out-of-range predictions without flagging them