linearfragility: Linear Fragility Function

Description Usage Arguments Value Examples

View source: R/linearfragility.R

Description

Compute the fragility of a coefficient in a linear regression, i.e. the number of removed observations it would take to make a significant-result non-significant. Uses the lm() function from the stats package.

Usage

1
2
linearfragility(formula, data, covariate = "all.factors.default",
  conf.level = 0.95, verbose = FALSE)

Arguments

formula

Model formula which will be evaluated by lm()

data

Dataframe with values for model forma, passed to lm()

covariate

Vector of covariates to find fragility index for. Default is all covariates in formula

conf.level

Significance level

verbose

Logical indicating if function will return verbose results or only fragility index

Value

If verbose is FALSE, returns a list with fragility indices for selected covariates. If verbose is TRUE, returns a list with p-values for each fragility index at each iteration of the algorithm.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# Import example data
ad <- "https://archive.ics.uci.edu/ml/machine-learning-databases/wine-quality/winequality-red.csv"
mydata <- read.csv(file = ad, header= TRUE, sep=";")
  

formula = quality ~ fixed.acidity + citric.acid + residual.sugar + free.sulfur.dioxide + 
  total.sulfur.dioxide + pH + sulphates + alcohol
linearfragility(formula, data = mydata, covariate = c("citric.acid", 
                "total.sulfur.dioxide", "free.sulfur.dioxide"))

# citric acid nonsignificant at 197 points removed and 
# residual.sugar is not significant at 0 points removed
linearfragility(quality ~ citric.acid + residual.sugar, data = mydata, verbose = TRUE)

kippjohnson/fragilityindex documentation built on May 20, 2019, 10:23 a.m.