# Changing parameter value by the level of independent variable in regression analysis

I want to construct a regression model, where the parameter values are changing by the independent variable's level.

For example, let say y is dependent variable and x is independent variable. And let say when the x has value 5 it has a different effect on y. When it is 50 it has different effect on y. Let say when it is 5, 1 unit change at x, decreases y by 10 units. And let say when x is 50, 1 unit increase in x, decreases y by 20 units.

How can I construct such a model?

I will be very glad for any help. Thanks a lot.

• You need to specify a point on $x$, say $x_0$ to indicate the change of the effect. According to current description, if $x$ = 20, what should I do? – user158565 Oct 28 '18 at 17:33
• I don't know this too. I want to model this indeed. But I am sure that x has different effect on y related to its level. – oercim Oct 28 '18 at 17:35

Step 1: Set the cut off point at $$x_0$$. Create a dummy variable $$Z = 1$$ if $$x>x_o$$, = 0 otherwise. Fit a model $$y = \beta_0 + \beta_1x+\beta_2Z+\beta_3Zx+\epsilon$$ Then $$\beta_1$$ is the slope for $$x \le x_0$$ and $$\beta_1 + \beta_3$$ is the slope for $$x > x_0$$. Record SSE (Sum of square of error) and $$x_0$$.
Step 2: Pick-up the different $$x_0$$ to repeat Step 1. After 3 times, create scatter plot with $$x_0$$ as x axis and SSE as y axis. From this graph, you will be able to find what is next $$x_0$$ so that the SSE will decrease. Repeat until you think you find $$x_0$$ such that SSE reach the lowest value. It is selected model.
Step 3: Fit a model $$y = \beta_0 + \beta_1x + \epsilon$$ Using difference of SSE to construct an F test to compare if the data following the two pieces of linear model. Here need to pay attention to DF (degree of freedom). Although 4 and 2 regression coefficients are estimated in selected model and the last model, but in fact the cut off point is also estimated, so the DF for difference of SSE should be 3, instead of 2.