Learn R Programming

CLRtools (version 0.1.0)

check_coef_significant: Check Significance of Excluded Variables

Description

Obtain summary statistics, including Wald test z-values and p-values, for coefficients of variables added one at a time to an existing logistic regression model. Supports both standard and conditional logistic regression.

Usage

check_coef_significant(data, yval, xpre, xcheck, strata = NULL)

Value

A matrix containing the coefficient estimates, standard errors, z-values, and p-values for each variable in xcheck when added to the preliminary model.

Arguments

data

A data frame containing the outcome, predictors, and optionally a stratification variable.

yval

A string naming the binary outcome variable.

xpre

A character vector of variables included in the preliminary model.

xcheck

A character vector of variables to be tested for significance when added individually to the preliminary model.

strata

(Optional) A string naming the stratification variable. If provided, conditional logistic regression is used via clogit().

Details

For each variable in xcheck, this function fits a model that includes the variable alongside xpre. It extracts and returns the coefficient summary for each added variable to assess statistical significance. When strata is provided, a conditional logistic regression model is used instead of standard logistic regression.

Examples

Run this code
# Example from Hosmer et al., 2013
# Applied Logistic Regression (3rd ed.), Chapter 4

# Variables selected for the full model
preliminar <- c('age', 'height', 'priorfrac', 'momfrac', 'armassist', 'raterisk')

# Variables to test
excluded <- c('weight', 'bmi', 'premeno', 'smoke')

# Assess whether any excluded variables become significant when added to the preliminary model
check_coef_significant(data = glow500, yval = 'fracture', xpre = preliminar, xcheck = excluded)

Run the code above in your browser using DataLab