reg_dist {nullabor} | R Documentation |
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, intercept = TRUE, scale = TRUE)
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 |
intercept |
include the distances between intercepts? |
scale |
logical value: should the variables be scaled before computing regression coefficients? |
Value
distance between X and PX
Examples
with(mtcars, reg_dist(data.frame(wt, mpg), data.frame(sample(wt), mpg)))