R/opt_diff.r
opt_bin_diff.Rd
This function finds the optimal number of bins in both x and y direction which should
be used to calculate the binned distance. The binned distance is calculated for each
combination of provided choices of number of bins in x and y direction and finds the
difference using calc_diff
for each combination. The combination for which the
difference is maximum should be used.
opt_bin_diff(
lineup.dat,
var,
xlow,
xhigh,
ylow,
yhigh,
pos,
plot = FALSE,
m = 20
)
lineup data to get the lineup
a list of names of the variables to be used to calculate the difference
the lowest value of number of bins on the x-direction
the highest value of number of bins on the x-direction
the lowest value of number of bins on the y-direction
the highest value of number of bins on the y-direction
position of the true plot in the lineup
LOGICAL; if true, returns a tile plot for the combinations of number of bins with the differences as weights
number of plots in the lineup, by default m = 20
a dataframe with the number of bins and differences the maximum mean distance of the null plots
if(require('dplyr')){
opt_bin_diff(lineup(null_permute('mpg'), mtcars, pos = 1), var = c('mpg', 'wt'),
2, 5, 4, 8, pos = 1, plot = TRUE, m = 8)
}
#> $dat
#> # A tibble: 20 × 3
#> # Groups: xbins [4]
#> xbins ybins Diff
#> <int> <int> <dbl>
#> 1 2 4 -0.409
#> 2 2 5 -0.409
#> 3 2 6 -0.387
#> 4 2 7 -0.409
#> 5 2 8 -0.409
#> 6 3 4 0.449
#> 7 3 5 0.449
#> 8 3 6 0.0697
#> 9 3 7 0.449
#> 10 3 8 0.449
#> 11 4 4 0.151
#> 12 4 5 0.151
#> 13 4 6 0.238
#> 14 4 7 0.151
#> 15 4 8 0.151
#> 16 5 4 0.759
#> 17 5 5 0.759
#> 18 5 6 0.207
#> 19 5 7 0.759
#> 20 5 8 0.759
#>
#> $p
#>