general.fi.sscurve: Fragility index aware sample size calculator for a grid of...

Description Usage Arguments Value Examples

View source: R/front.R

Description

Loops over general.fi.samplesize to calculate the fragility index based sample size. The p value based sample size will only be calculated once.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
general.fi.sscurve(
  min.fi,
  get.p.val,
  get.replacements,
  get.sample,
  cl = NULL,
  min.power = 0.8,
  alpha = 0.05,
  verbose = FALSE,
  niters = 5,
  sample_size_init_power = 10L,
  sample_size_init_fi = NULL,
  nsim = 30,
  eps = 0.1,
  tau = 1/2,
  algorithm = "walsh",
  gamma = 0.6
)

Arguments

min.fi

a vector of the smallest acceptable quantile fragility index. Each element will be passed into

get.p.val

a function that inputs X and Y and returns a p value when algorithm is 'greedy' or that inputs a matrix when algorithm is 'walsh'.

get.replacements

a function which outputs a data frame containing all possible row replacements for Y which are to be considered. The functions inputs the row of Y under consideration, the row of X under consideration, the row name, and the full original data frames X and Y. This gets used in the greedy algorithm.

get.sample

a function which inputs a sample size and outputs a sample, with the covariates in a dataframe and the response in a dataframe

cl

a cluster from the parallel package, used in greedy.fi

min.power

the smallest acceptable power

alpha

a numeric for the significance cutoff

verbose

boolean to indicate whether to print out algorithmic information for the sample size calculation

niters

The number of times to repeat the sample size calculations. The median of the repitions is then reported.

sample_size_init_power

a sample size to initialize the algorithm (not necessary, defaults to 10) to find the sample size for power

sample_size_init_fi

a sample size to initialize the algorithm (not necessary, defaults to the sample size for power) to find the sample size for fi

nsim

the number of simulated draws to consider when estimating the power and expected fragility index

eps

a parameter to control the error. The smaller is it, the more precise the output but the longer the function will take to run.

tau

the FI quantile, by default 1/2

algorithm

A string, equal to 'walsh' to perform fragility index calculation using the original algorithm due to Walsh et al. (2014) or equal to 'greedy' to perform fragility index calculation using the greedy algorithm described in Generalized fragility index.

gamma

the power of n^-1 in the gradient descent in the Polyak-Ruppert averaging. The default is 0.60.

Value

a matrix with 3 columns and row length equal to the length of min.fi. Each row contains the min.fi value and the output of general.fi.samplesize.

Examples

1
2
out <- general.fi.sscurve(min.fi = seq(0, 10, by = 5), get.p.val = function(m) fisher.test(m)$p.value,
get.replacements = get.replacements, get.sample = function(ss) draw.binom(ss, matrix=TRUE), niters = 1)

brb225/FragilityTools documentation built on Jan. 21, 2022, 1:26 a.m.