Learn R Programming

scf (version 1.0.5)

scf_logit: Estimate Logistic Regression Model using SCF Microdata

Description

Fits a replicate-weighted logistic regression model to multiply-imputed SCF data, returning pooled coefficients or odds ratios with model diagnostics. Use this function to model a binary variable as a function of predictors.

Usage

scf_logit(object, formula, odds = TRUE, ...)

Value

An object of class "scf_logit" and "scf_model_result" with:

results

A data frame of pooled estimates (log-odds or odds ratios), standard errors, and test statistics.

fit

Model diagnostics including AIC and pseudo-R-Squared (for binomial family).

models

List of implicate-level svyglm model objects.

call

The matched function call.

Arguments

object

A scf_mi_survey object created with scf_load() and scf_design().

formula

A model formula specifying a binary outcome and predictors, e.g., rich ~ age + factor(edcl).

odds

Logical. If TRUE (default), exponentiates coefficient estimates to produce odds ratios for interpretability.

...

Additional arguments passed to scf_glm().

Warning

When modeling binary outcomes using survey-weighted logistic regression, users may encounter the warning:

"non-integer #successes in a binomial glm!"

This message is benign. It results from replicate-weighted survey designs where the implied number of "successes" is non-integer. The model is estimated correctly. Coefficients are valid and consistent with maximum likelihood.

For background, see: https://stackoverflow.com/questions/12953045/warning-non-integer-successes-in-a-binomial-glm-survey-packages

Details

This function internally calls scf_glm() with family = binomial() and optionally exponentiates pooled log-odds to odds ratios.

Logistic regression models the probability of a binary outcome using the logit link.

Coefficients reflect the change in log-odds associated with a one-unit change in the predictor.

When odds = TRUE, the coefficient estimates and standard errors are transformed from log-odds to odds ratios and approximate SEs.

See Also

scf_glm(), scf_ols(), scf_MIcombine()

Examples

Run this code
# \donttest{
# Do not implement these lines in real analysis:
# Use functions `scf_download()` and `scf_load()`
td <- tempfile("logit_")
dir.create(td)

src <- system.file("extdata", "scf2022_mock_raw.rds", package = "scf")
file.copy(src, file.path(td, "scf2022.rds"), overwrite = TRUE)
scf2022 <- scf_load(2022, data_directory = td)

# Example for real analysis: Run logistic regression
model <- scf_logit(scf2022, own ~ age)
summary(model)

# Do not implement these lines in real analysis: Cleanup for package check
unlink(td, recursive = TRUE, force = TRUE)
# }

Run the code above in your browser using DataLab