nullabor (version 0.3.1)

reg_dist: Distance based on the regression parameters

Description

Dataset X is binned into 5 bins in x-direction. A regression line is fitted to the data in each bin and the regression coefficients are noted. Same is done for dataset PX. An euclidean distance is calculated between the two sets of regression parameters. If the relationship between X and PX looks linear, number of bins should be equal to 1.

Usage

reg_dist(X, PX, nbins = 1)

Arguments

X

a data.frame with two variables, the first column giving the explanatory variable and the second column giving the response variable

PX

another data.frame with two variables, the first column giving the explanatory variable and the second column giving the response variable

nbins

number of bins on the x-direction, by default nbins = 1

Value

distance between X and PX

Examples

Run this code
# NOT RUN {
with(mtcars, reg_dist(data.frame(wt, mpg), data.frame(sample(wt), mpg)))
# }

Run the code above in your browser using DataCamp Workspace