Learn R Programming

scf (version 1.0.5)

scf_ols: Estimate an Ordinary Least Squares Regression on SCF Microdata

Description

Computes an OLS regression on SCF data using svyglm() across the SCF's five implicates. Returns coefficient estimates, standard errors, test statistics, and model diagnostics.

Usage

scf_ols(object, formula)

Value

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

results

A data frame of pooled coefficients, standard errors, t-values, p-values, and significance stars.

fit

A list of model diagnostics including mean AIC, standard deviation of AIC, mean R-squared, and its standard deviation.

imps

A list of implicate-level svyglm model objects.

call

The matched call used to produce the model.

Arguments

object

A scf_mi_survey object created with scf_load() and scf_design(). Must contain five implicates with replicate weights.

formula

A model formula specifying a continuous outcome and predictor variables (e.g., networth ~ income + age).

Implementation

Ordinary least squares (OLS) regression estimates the linear relationship between a continuous outcome and one or more predictor variables. Each coefficient represents the expected change in the outcome for a one-unit increase in the corresponding predictor, holding all other predictors constant.

Use this function to model associations between SCF variables while accounting for complex survey design and multiple imputation.

This function takes a scf_mi_survey object and a model formula. Internally, it fits a weighted linear regression to each implicate using survey::svyglm(), extracts coefficients and variance-covariance matrices, and pools them via scf_MIcombine().

Details

Fits a replicate-weighted linear regression model to each implicate of multiply-imputed SCF data and pools coefficients and standard errors using Rubin’s Rules.

See Also

scf_glm(), scf_logit(), scf_MIcombine()

Examples

Run this code
# Do not implement these lines in real analysis:
# Use functions `scf_download()` and `scf_load()`
td <- tempfile("ols_")
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 OLS model
model <- scf_ols(scf2022, networth ~ income + 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