Approximation of two segmented linear regression

83 Views Asked by At

Is there any function that can approximate a two segmented linear regression? Suppose you have two linear regressions See here

$y=0.1760x+2.4305\ \left\{x<77.6615\right\}$

$y=0.3011x-7.2865\ \left\{x\ge77.6615\right\}$

What single/continuous function can approximate x vs y relationship here? A function with 3 unknown parameters is preferable since I have only 4 points to fit.

Note: Interpolation or piecewise regression is not desired.

2

There are 2 best solutions below

2
On

Maybe you want to approximate this discontinuous function in the same way that one might try to approximate any singularity function? Such as a ramp function or unit step function. Anyway, in this case you would stick to Fourier analysis, and you could approximate the function as an infinite sum of sines and cosines.

2
On

If you want an infinitely differentiable function, translate the piecewise function so that the point where the two lines meet is at the origin. Then rotate the two lines clockwise around the origin so that one of them has a slope of $0$ and is on the left side of the y-axis (ie $x<0$). The other line should have a positive slope. Let the new slope of the other line be $s$. This means that one line is of the form $y = 0 \hspace{1 mm}\{x\le0\}$ and the other is $y = sx\hspace{1 mm}\{x > 0\}$. This new piecewise function can be approximated by $$y = \frac{1}{t} \ln(1+e^{tsx})$$

where $t$ is a positive number. The higher it is, the more accurate the function will be. Finally, rotate this function counterclockwise the same angle as before and translate it back.

Edit: This assumes the piecewise function is only two linear parts, is continuous, and the angle between the two linear segments is greater than $\frac{\pi}{4}$.