ttest.fi: Calculate a fragility index for the one sample t test

Description Usage Arguments Value Examples

View source: R/front.R

Description

This function returns a fragility index (and accomponying information) for the one sample t test, when each patients outcome is restricted to only be modified by a certain amount. We observe the sufficiently likely convention which is described in the generalized fragility index article.

Usage

1
ttest.fi(y, q = 0.5, mu0 = 0, alpha = 0.05, verbose = FALSE, cl = NULL)

Arguments

y

a numeric vector of outcomes

q

a numeric for the probability of outcome changes, by default .5. Larger values of q further constrain the permitted modifications.

mu0

the null mean, by default 0

alpha

a numberic for the significance threshold, by default 0.05

verbose

A boolean for whether to print greedy.fi steps while running, by default FALSE

cl

A parallel cluster for faster calculation in greedy.fi, by default NULL

Value

The output of greedy.fi (a list) with an additional element which has the overall data (relative) likelihood, as described in the article Generalized fragility index.

Examples

1
2
3
4
5
6
7
8
9
set.seed(123456790)
y <- rnorm(100, mean = 0)
p.grid <- seq(.1, .9, by = .1)
#ttest.fi(y, q=.9, verbose=TRUE)$FI
fi.grid <- sapply(p.grid, function(p) unlist(ttest.fi(y, q=p)[c('FI', 'sl')]))
ggplot2::qplot(p.grid, fi.grid[1,], geom = c('point', "line"), xlim = c(min(p.grid), max(p.grid)),
   xlab = "Within-patient Likelihood bound", ylab = "Fragility index", main = "t test fragility indices (n=100)")
ggplot2::qplot(log10(fi.grid[2,]), fi.grid[1,], xlab = "Full data (between-patient) Likelihood, log scale",
   ylab = "Fragility index", main = "t test fragility indices (n=100)")

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