Description Usage Arguments Details Value Examples
This is a very general function which approximately calculates a fragility index using covariates, response(s), and any p value function. It's described in detail in the article Generalized fragility index.
1 2 3 4 5 6 7 8 9 10 11 |
X |
a data frame of covariates which are not subject to modification. |
Y |
a data frame of responses which are subject to modification. |
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. |
get.p.val |
a function that inputs X and Y and returns a p value |
alpha |
a numeric for the significance cutoff |
verbose |
a logical value for whether to print status updates while running |
cl |
a cluster from the |
only.consider |
a vector of row names to only consider, by default NULL which considers all patients |
dont.consider |
a vector of row names to not consider |
This is a general function which uses a greedy algorithm to compute a fragility index.The function arguments accept data from two sources: covariates in X and responses in Y. Covariates are unchanged by the algorithm, while responses are iteratively changed. The type of each response is specified to determine which substitute outcomes to consider.
a list containing a fragility index and related information
A fragility index, positive if the initial $p$-value was < alpha and negative otherwise
An atomic vectors of the p-values at each step of the iteratative algorithm, where the first is the starting p value and the last is the p value which crossed the alpha threshold
A boolean indicating whether the original p value is larger than alpha
The number of patients whose responses were subject to change
An atomic vector with the rownames of the rows which had their responses changed
A list of dataframes of the original responses of each changed patient
A list of dataframes of the new responses of each changed patient
A data frame of the modified cbind(X,Y)
1 2 3 4 5 6 | n <- 100
X <- data.frame("tr_group" = sample(c("treated", "not treated"), n, TRUE))
Y <- data.frame("outcome" = sample(c("sick", "healthy"), n, TRUE))
get.p.val <- function(X, Y) fisher.test(table(X[[1]], Y[[1]]))$p.value
get.replacements <- function(y, x, rn, Y, X) data.frame(Y=setdiff(unique(Y[[1]]), y))
greedy.fi(X, Y, get.p.val = get.p.val, get.replacements = get.replacements)$FI
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.