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.
reg_dist(X, PX, nbins = 1, intercept = TRUE, scale = TRUE)
a data.frame with two variables, the first column giving the explanatory variable and the second column giving the response variable
another data.frame with two variables, the first column giving the explanatory variable and the second column giving the response variable
number of bins on the x-direction, by default nbins = 1
include the distances between intercepts?
logical value: should the variables be scaled before computing regression coefficients?
distance between X and PX
with(mtcars, reg_dist(data.frame(wt, mpg), data.frame(sample(wt), mpg)))
#> [1] 1.384494