Learn R Programming

changedetection (version 0.2.0)

changeTest: A test showing whether two datasets have similar linear structure

Description

The function performs a nonparametric test showing whether two datasets have similar linear structure or not. The test is based on applying energy distance rizzo-szekely10changedetection to residuals estimated for each dataset separately but only by one model (either first or second). It is implemented as a permutation test with R rounds and corresponding pzero gorskikh17changedetection.

Usage

changeTest(x1, y1, x2, y2, l = NULL, R = 1000, pzero = 0.05,
  alpha = 1)

Arguments

x1

matrix of first period regressors with variables in columns and observations in rows

y1

matrix of first period responses with variables in columns and observations in rows

x2

matrix of second period regressors with variables in columns and observations in rows

y2

matrix of second period responses with variables in columns and observations in rows

l

approximate number of contributing variables (default: overall number of regressors)

R

number of bootstrap rounds (default: `1000`)

pzero

trust level for bootstrap (default: `0.05`)

alpha

parameter for energy distance formula (default: `1`)

Value

TRUE or FALSE

References

Examples

Run this code
# NOT RUN {
T<-60
change<-35
x<-rnorm(n=T, m=0, sd=1)
e<-scale(rt(n=T,3), scale=FALSE)
y1<-5*x[1:(change-1)]+e[1:(change-1)]
y2<--2*x[change:T]+e[change:T]
y<-c(y1,y2)

testResult <- changeTest(x1=as.data.frame(x[1:T]),
                         y1=as.data.frame(y[1:T]),
                         x2=as.data.frame(x[31:T]),
                         y2=as.data.frame(y[31:T]),
                         R=200)

# }

Run the code above in your browser using DataLab