andrews_test_reg {CPAT}  R Documentation 
This implements Andrews' test for endofsample change, as described by Andrews (2003). This test was derived for detecting a change in multivarate data, aso originally described. See (Andrews 2003) for a description of the test.
andrews_test_reg(formula, data, M, pval = TRUE, stat = TRUE)
formula 
The regression formula, which will be passed to

data 

M 
Numeric index of the location of the first potential change point 
pval 
If 
stat 
If 
If both pval
and stat
are TRUE
, a list
containing both; otherwise, a number for one or the other, depending
on which is TRUE
Andrews DWK (2003). “EndofSample Instability Tests.” Econometrica, 71(6), 1661–1694. ISSN 00129682, 14680262, https://www.jstor.org/stable/1555535.
x < rnorm(1000) y < 1 + 2 * x + rnorm(1000) df < data.frame(x, y) CPAT:::andrews_test_reg(y ~ x, data = df, M = 900)