# How to do Chow Test in R

**Methods – finnstats**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

The Chow test is used to compare the coefficients of two distinct regression models on two separate datasets.

This test is commonly used in econometrics using time series data to evaluate if the data has a structural break at some point.

Correlation Analysis in R? » Karl Pearson correlation coefficient »

The basic steps are as follows:

Run all of your data through a “limited” regression (pooled).

Using your breakpoint as a guide, divide your sample into two groups (e.g. a point in time, or a variable value).

On each of your subsamples, run an “unrestricted” regression. With a single breakpoint, you’ll run two “unrestricted” regressions.

Then calculate Chow F-statistic.

## Chow Test in R

This tutorial shows you how to execute a Chow test in R step by step.

Let’s create the Data Frame, we can make use of the EuStockMarkets dataset here for illustration purposes.

What are the differences between Association and Correlation? »

library(dplyr) data<-data.frame(EuStockMarkets) data <- dplyr::select(data, DAX, SMI)

View first six rows of data

head(data) DAX SMI 1 1628.75 1678.1 2 1613.63 1688.5 3 1606.51 1678.6 4 1621.04 1684.1 5 1618.16 1686.6 6 1610.61 1671.6

### Visualize the Information

Then, to visualize the data, we’ll make a basic scatterplot. Let’s load ggplot2 package in the R console.

Discriminant Analysis in r » Discriminant Analysis in R »

library(ggplot2)

In R, we can now make a scatterplot Chow test.

ggplot(data, aes(x = disp, y = mpg)) + geom_point(col='steelblue', size=3)

We can see from the scatterplot that the data pattern appears to alter at DAX = 4000. But not sure, as a result, we may use the Chow test to see if the data has a structural breakpoint.

What is mean by the correlation coefficient? »

Take the Chow Test. To execute a Chow test, we may use the strucchange package’s sctest function:

Let’s load strucchange package

**Syntax**:

sctest(formula, type = , h = 0.15, alt.boundary = FALSE, functional = c("max", "range", "maxL2", "meanL2"), from = 0.15, to = NULL, point = 0.5, asymptotic = FALSE, data, ...)

The above function returns the following

**statistic** the test statistic

**p.value** the corresponding p-value

**method** a character string with the method used

**data.name **a character string with the data name

One Sample Analysis in R » Quick Guide »

library(strucchange)

Now we can perform the Chow test in R

sctest(data$SMI ~ data$DAX, type = "Chow", point = 10) Chow test data: data$SMI ~ data$DAX F = 212.01, p-value < 2.2e-16

We can reject the null hypothesis of the test because the p-value is less than 0.05. This means we have enough evidence to conclude that the data contains a structural breakpoint.

To put it another way, two regression lines can match the data pattern better than a single regression line.

Null Hypothesis » Why we need a null hypothesis test?. »

The post How to do Chow Test in R appeared first on finnstats.

**leave a comment**for the author, please follow the link and comment on their blog:

**Methods – finnstats**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.