Description Usage Arguments Value Examples
View source: R/linearfragility.R
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.
1 2 | linearfragility(formula, data, covariate = "all.factors.default",
conf.level = 0.95, verbose = FALSE)
|
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 |
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.
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.