Multivariate Andrews' Test for End-of-Sample Structural Change
Multivariate Andrews' Test for End-of-Sample Structural Change
This implements Andrews' test for end-of-sample change, as described by if(!exists(".Rdpack.currefs")) .Rdpack.currefs <-new.env();Rdpack::insert_citeOnly(keys="andrews03;textual",package="CPAT",cached_env=.Rdpack.currefs) . This test was derived for detecting a change in multivarate data, aso originally described. See if(!exists(".Rdpack.currefs")) .Rdpack.currefs <-new.env();Rdpack::insert_citeOnly(keys="andrews03",package="CPAT",cached_env=.Rdpack.currefs) for a description of the test.
andrews_test_reg(formula, data, M, pval =TRUE, stat =TRUE)
Arguments
formula: The regression formula, which will be passed to lm
data: data.frame containing the data
M: Numeric index of the location of the first potential change point
pval: If TRUE, return a p-value
stat: If TRUE, return a test statistic
Returns
If both pval and stat are TRUE, a list containing both; otherwise, a number for one or the other, depending on which is TRUE
Examples
x <- rnorm(1000)y <-1+2* x + rnorm(1000)df <- data.frame(x, y)CPAT:::andrews_test_reg(y ~ x, data = df, M =900)