ks: Convert KS Distance to Effect Size (Delta)

ks2deltaR Documentation

Convert KS Distance to Effect Size (Delta)

Description

Convert KS-distance to effect size using the standard inverse error function conversion: qnorm( (x + 1) / 2) * 2.

Calculate power and sample size tables for a range of known powers or sample sizes, and relate them to a sensitivity/specificity. The calculation relies on a conversion from sens/spec to KS-distance and an approximation from KS-distance to effect size: qnorm((ks + 1) / 2) * 2.

Plot power curves of call to ks_power_table(), an object of class ks_pwr_table. You can plot either power curves or required sample size curves. This differs from standard power curves in that the independent variable (usually effect size) is a varying sensitivity/specificity value.

Usage

ks2delta(x)

ks_power_table(
  power_vec = seq(0.6, 0.95, 0.05),
  n_vec = seq(20, 100, 10),
  alpha = 0.05
)

## S3 method for class 'ks_pwr_table'
plot(x, plot_power = TRUE, ...)

Arguments

x

numeric(n) in ⁠[0, 1]⁠. A sequences of KS-distance(s). Or a ks_pwr_table object, from call to ks_power_table(), which is a tibble with n and power.

power_vec

numeric(n) in ⁠(0, 1)⁠. A sequence of power levels to evaluate the required samples size.

n_vec

integer(n). A sequence of sample sizes per group to evaluate the corresponding power.

alpha

double(1). The significance threshold (\alpha), the probability of a significant result given the null hypothesis, i.e. a false positive. If desired, Bonferroni correction should be implemented here.

plot_power

logical(1). Should the power data frame be plotted? If FALSE, the sample sizes are plotted.

...

Additional arguments as requpred by the plot() generic.

Value

Effect sizes corresponding to x.

A list of:

n

A data frame of the number of samples required in each comparison group to detect an effect corresponding to a given set of sens/spec values (60/60 to 90/90) and given vector of power values (default power_vec = seq(0.6, 0.95, 0.05)). The corresponding KS-distances of the sens/spec values are also included.

power

A data frame containing the power to detect an effect corresponding to a given set of sens/spec values (60/60 to 90/90) given vector of sample sizes in each comparison group (default n_vec = seq(20, 100, 10)). The corresponding KS-distances of the sens/spec values are also included.

Author(s)

Stu Field

See Also

qnorm()

stats::power.t.test(), ks2delta()

Examples

ks2delta(0.45)

ks2delta(seq(0.1, 0.9, length.out = 5))
tables <- ks_power_table()
tables
# S3 plot method
plot(tables)

plot(tables, plot_power = FALSE)

stufield/power documentation built on June 1, 2025, 7:16 p.m.