loop_break: Find smallest subset to exclude from sample for...

Description Usage Arguments Value Examples

View source: R/loop_break.R

Description

The function iteratively learns which observations should at least be excluded from the data to reach a conservative 'goal value' for the statistic of interest. It does so by relying on a genetic algorithm, which efficiently explores the (usually vast) space of possible subsets. The result can uncover impactful subsamples and fuel discussions of robustness. Necessary arguments include the dataframe, a function to compute the statistic of interest ('statistic_computation' see examples), and the goal value of interest.

Usage

1
2
3
4
5
6
7
loop_break(
  data = NA,
  goal_value = NA,
  statistic_computation = NA,
  max_exclusions = 3,
  random_seed = 42
)

Arguments

data

A data.frame containing the observations as rows.

goal_value

This conservative value (e.g., small effect size) is targeted.

statistic_computation

A formula which has 'data' as input and returns the statistic of interest.

max_exclusions

maximum number of cases to be excluded

random_seed

Seed for replicability.

Value

Vector of row indeces to be excluded

Examples

1
2
3
4
5
6
coefficient_computation <- function(data){
statistic <- cor(data$Sepal.Length, data$Petal.Width)
return(statistic)}

filter <- loop_break(data = iris, statistic_computation = coefficient_computation, goal_value = 0.2, max_exclusions = 2)
print(filter)

hannesrosenbusch/StatBreak documentation built on Feb. 12, 2020, 10:35 a.m.