Let's first create a fake data with a break-point at 3.
> x=seq(1,5,length=100)
> y=numeric(100)
> y[1:50]=2*x[1:50]
> y[51:100]=rep(2*x[51],50)
> z=rnorm(100,0,.15)
> y=y+z
> plot(x,y)
Now I am gonna perform a Chow test using package strucchange
in R to test if 3 is a break-point or not.
> require(strucchange)
> sctest(y ~ x, type = "Chow", point = 3)
Chow test
data: y ~ x
F = 3.4086, p-value = 0.03714
So based on this test, the point x=3 is a break-point. Now I will create a dummy variable dum.x
and define it as 0 when $x>=3$ and 1 otherwise.
> dum.x=rep(1,100)
> dum.x[x>=3]=0
Next I fit a linear regression using the dummy variable I created with an interaction term and take the summary. So the model I am fitting here is $Y=\beta_0+\beta_1x+\beta_2dum.x+\beta_3x \times dum.x$.
> M=lm(y~x*dum.x)
> summary(M)
Call:
lm(formula = y ~ x * dum.x)
Residuals:
Min 1Q Median 3Q Max
-0.35089 -0.09929 -0.01161 0.08907 0.40424
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 6.32411 0.14728 42.94 <2e-16 ***
x -0.07234 0.03634 -1.99 0.0494 *
dum.x -6.32203 0.16544 -38.21 <2e-16 ***
x:dum.x 2.06979 0.05140 40.27 <2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.1498 on 96 degrees of freedom
Multiple R-squared: 0.9877, Adjusted R-squared: 0.9874
F-statistic: 2579 on 3 and 96 DF, p-value: < 2.2e-16
Note that when $x\geq 3$, then dum.x=0
so $$Y=\beta_0+\beta_1x,$$ and when $x<3$ then dum.x=1
so $$Y=\beta_0+\beta_1x+\beta_2+\beta_3x=(\beta_0+\beta_2)+(\beta_1+\beta_3)x.$$ This means that I am actually changing both the intercept and slope by dividing my dataset and fitting above linear regression. According to the summary output the p-values for dum.x and x:dum.x are less than 0.05. So we reject $H_0:\beta_3=0$ vs. $H_1:\beta_3\ne 0$ at 5% sig. level. This means that the slope is changing at $x=3$ that confirms the Chow test we had before.
Finally lets try to change our $x$ in a way that we don't have any break-point at 3.
> y=2*x+rnorm(100)
> plot(x,y)
Using the Chow test again, we have:
> sctest(y ~ x, type = "Chow", point = 3)
Chow test
data: y ~ x
F = 2.1406, p-value = 0.1232
Therefore, x=3 is not a break-point as expected. Lets fit a linear model using our dummy variable:
> M2=lm(y~x*dum.x)
> summary(M2)
Call:
lm(formula = y ~ x * dum.x)
Residuals:
Min 1Q Median 3Q Max
-2.50938 -0.64484 -0.03025 0.67947 2.21949
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1.1014 0.9875 1.115 0.267
x 1.7388 0.2437 7.135 1.83e-10 ***
dum.x -1.5082 1.1093 -1.360 0.177
x:dum.x 0.3508 0.3446 1.018 0.311
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 1.005 on 96 degrees of freedom
Multiple R-squared: 0.8595, Adjusted R-squared: 0.8551
F-statistic: 195.8 on 3 and 96 DF, p-value: < 2.2e-16
As you can see from summary output, neither the slope nor the intercept is changing at 3 and again confirms the Chow test.