Learn R Programming

changedetection (version 0.2.0)

energyDistance: Energy distance between two datasets

Description

Estimate energy distance which is a metric that measures the distance between the distributions of random vectors rizzo-szekely10changedetection. The energy distance is zero if an only if the distributions are identical, otherwise it will diverge.

Usage

energyDistance(x1, y1, x2, y2, l = NULL, 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)

alpha

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

Value

energy distance value

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)

ed <- energyDistance(x1=as.data.frame(x[1:30]),
                     y1=as.data.frame(y[1:30]),
                     x2=as.data.frame(x[31:T]),
                     y2=as.data.frame(y[31:T]))

# }

Run the code above in your browser using DataLab