MyNixOS website logo
Description

Stepwise Regression Analysis.

Stepwise regression is a statistical technique used for model selection. This package streamlines stepwise regression analysis by supporting multiple regression types(linear, Cox, logistic, Poisson, Gamma, and negative binomial), incorporating popular selection strategies(forward, backward, bidirectional, and subset), and offering essential metrics. It enables users to apply multiple selection strategies and metrics in a single function call, visualize variable selection processes, and export results in various formats. StepReg offers a data-splitting option to address potential issues with invalid statistical inference and a randomized forward selection option to avoid overfitting. We validated StepReg's accuracy using public datasets within the SAS software environment. For an interactive web interface, users can install the companion 'StepRegShiny' package.

StepReg


  • An R package for stepwise regression analysis


StepReg is an R package that streamlines stepwise regression analysis by supporting multiple regression types, incorporating popular selection strategies, and offering essential metrics.

Key Features

  • Multiple Regression Types: Linear, logistic, Cox, Poisson, Gamma, and negative binomial regression
  • Selection Strategies: Forward selection, backward elimination, bidirectional elimination, and best subsets
  • Selection Metrics: AIC, AICc, BIC, CP, HQ, adjRsq, SL, SBC, IC(3/2), IC(1)
  • Advanced Features:
    • Strata variables for Cox regression
    • Continuous-nested-within-class effects
    • multivariable multiple linear stepwise regression
  • Multicollinearity Detection: Automatic detection and handling of multicollinearity
  • Visualization: Plot functions for variable selection processes
  • Reporting: Export results in various formats (HTML, DOCX, XLSX, PPTX)
  • Shiny App: Interactive web interface for non-programmers

Installation

Install from CRAN

pak::pkg_install("StepReg")

or

install.packages("StepReg")

Or install from GitHub

devtools::install_github("JunhuiLi1017/StepReg")

Quick Start

library(StepReg)

# Basic linear regression
data(mtcars)
formula <- mpg ~ .
res <- stepwise(
  formula = formula,
  data = mtcars,
  type = "linear",
  strategy = "bidirection",
  metric = "AIC"
)

# View results
res
summary(res$bidirection$AIC)

Advanced Features

Strata Variables in Cox Regression

library(survival)
data(lung)
lung$sex <- factor(lung$sex)

# Cox regression with strata
formula <- Surv(time, status) ~ age + sex + ph.ecog + strata(inst)
res <- stepwise(
  formula = formula,
  data = lung,
  type = "cox",
  strategy = "forward",
  metric = "AIC"
)

Continuous-Nested-Within-Class Effects

data(mtcars)
mtcars$am <- factor(mtcars$am)

# Nested effects
formula <- mpg ~ am + wt:am + disp:am + hp:am
res <- stepwise(
  formula = formula,
  data = mtcars,
  type = "linear",
  strategy = "bidirection",
  metric = "AIC"
)

Documentation

Shiny Application

Important Note

StepReg should NOT be used for statistical inference unless the variable selection process is explicitly accounted for, as it can compromise the validity of the results. This limitation does not apply when StepReg is used for prediction purposes.

Citation

If you use StepReg in your research, please cite:

citation("StepReg")

Questions?

Please raise an issue here.

Metadata

Version

1.6.2

License

Unknown

Platforms (78)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    uefi
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-uefi
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-linux
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-uefi
  • x86_64-windows