Skip to contents

An application of backward stepwise selection using AIC as the criterion for stepping down (i.e., from a full model) through the candidate set of variables.

Usage

analyse_backward(
  x,
  response = NULL,
  vars = NULL,
  family = stats::gaussian(),
  k = 2
)

Arguments

x

An output of the bootstrap_data function.

response

a character argument denoting the outcome.

vars

a character vector denoting the covariates or features to be screened.

family

the error distribution and link function passed to the glm() call inside the analyse_backward function. Default is gaussian.

k

as per the stats::step definition: "the multiple of the number of degrees of freedom used for the penalty".

Value

A nested tibble.

Details

The present function is a simple wrapper for the stats::step() function. There are various commentaries that have been published on the use of stepwise selection, with a range of interpretations of its utility, spanning from more generous proponents focussing on the simplicity with which a reduced model with "insignificant" variables removed, through to those that highlight how it invalidates most of any statistical inference that can be drawn from the final fit. Irrespective of the stance taken, this method is still common practice in many clinical prediction modelling publications and is thus worth including for illustrating selection instability.

References

Harrell, F. E. (2015). Regression Modeling Strategies: With Applications to Linear Models, Logistic and Ordinal Regression, and Survival Analysis. Springer International Publishing. https://books.google.co.uk/books?id=sQ90rgEACAAJ

Examples

data(iswr_stroke)
iswr_stroke %>%
  bootstrap_data(10, seed = 1234) %>%
  analyse_backward(response = "dead12",
                   vars = c("Gender", "Age", "Diagnosis", "Coma",
                            "Diabetes", "MI", "Hypertension"),
                   family = "binomial")
#> # A tibble: 10 × 3
#>    boot_rep data               vars     
#>       <int> <list>             <list>   
#>  1        1 <tibble [814 × 8]> <chr [5]>
#>  2        2 <tibble [814 × 8]> <chr [7]>
#>  3        3 <tibble [814 × 8]> <chr [5]>
#>  4        4 <tibble [814 × 8]> <chr [6]>
#>  5        5 <tibble [814 × 8]> <chr [5]>
#>  6        6 <tibble [814 × 8]> <chr [4]>
#>  7        7 <tibble [814 × 8]> <chr [6]>
#>  8        8 <tibble [814 × 8]> <chr [4]>
#>  9        9 <tibble [814 × 8]> <chr [5]>
#> 10       10 <tibble [814 × 8]> <chr [6]>