# polynomial regression in R: how to add hard constraints (go through specified points)? [duplicate]

I'd like to perform polynomial regression on my data (which lies in [0,10]), but I need to ensure that the endpoints of the range are fixed, i.e. that the curve goes through (0,0) and (10,10). So the interpolant

$$y = a + bx + cx^2 + \epsilon$$

becomes

$$y = bx + cx^2 + \epsilon$$ with $$b = 1 - 10c$$.

Assuming just quadratic for now, although I might go to a cubic if the data warrants it. But how do I express this constraint during fitting?

• Do you want any random components in your data? If yes, the description is needed. – user158565 Dec 10 '18 at 15:21
• Ah, it's only the interpolant that I need, thinking about this... – Paul Miller Dec 10 '18 at 15:28

It would be easiest just to plug your constraint into the model and rewrite it:

$$y = bx + cx^2 = (1 - 10c)x + cx^2 = x + c(x^2 - 10x)$$

Regress $$y-x$$ against $$x^2 - 10x$$, without an intercept, to get $$c$$. Then you can compute $$b$$ from that.