vis_reg {RegrCoeffsExplorer}R Documentation

Visualize Regression Coefficients Within the Context of Empirical Data

Description

Typically, regression coefficients for continuous variables are interpreted on a per-unit basis and compared against coefficients for categorical variables. However, this method of interpretation is flawed as it overlooks the distribution of empirical data. This visualization tool provides a more nuanced understanding of the regression model's dynamics, illustrating not only the immediate effect of a unit change but also the broader implications of larger shifts such as interquartile changes.

Usage

vis_reg(object, ...)

Arguments

object

A fitted model object, expected to be one of the following classes:

  • lm : Linear Models.

  • ⁠glm lm⁠ : Generalized Linear Models.

  • ⁠elnet glmnet⁠ : Regularized Linear Models.

  • ⁠lognet glmnet⁠ : Regularized Logistic Models.

  • fixedLassoInf : Inference for the lassso for the linear models.

  • fixedLogitLassoInf : Inference for the lassso for the logistic models.

...

Additional parameters.Please refer to details.

Details

The following additional arguments can be passed:

Please note the following:

Value

A list with the following components:

See Also

Examples

# Set seed for reproducibility
set.seed(38)
# Set the number of observations
n = 1000
# Generate predictor variables
X1 = rnorm(n)
X2 = rnorm(n)
X3 = rnorm(n)
# Define coefficients for each predictor
beta_0 = -1
beta_1 = 0.5
beta_2 = -0.25
beta_3 = 0.75
# Generate the latent variable
latent_variable = beta_0 + beta_1 * X1+ beta_2 * X2 + beta_3 * X3
# convert it to probabilities
p = pnorm(latent_variable)
# Generate binomial outcomes based on these probabilities
y = rbinom(n, size = 1, prob = p)
# Fit a GLM with a probit link
glm_model <- glm(y ~ X1 + X2 + X3, family = binomial(link = "probit"),
                 data = data.frame(y, X1, X2, X3))
# Specify additional parameters and Plot Odds Ratio for the Realized Effect
vis_reg(glm_model, CI=TRUE,intercept=TRUE,
        palette=c("greenyellow","red4"))$RealizedEffectVis


[Package RegrCoeffsExplorer version 1.2.0 Index]