| rwa_logit | R Documentation |
This function performs Relative Weights Analysis (RWA) for binary outcome variables using logistic regression. RWA provides a method for estimating the relative importance of predictor variables by transforming them into orthogonal variables while preserving their relationship to the outcome. This implementation follows Johnson (2000) for logistic regression.
rwa_logit(df, outcome, predictors, applysigns = FALSE)
df |
Data frame or tibble to be passed through. |
outcome |
Outcome variable, to be specified as a string or bare input. Must be a numeric variable. |
predictors |
Predictor variable(s), to be specified as a vector of string(s) or bare input(s). All variables must be numeric. |
applysigns |
Logical value specifying whether to show an estimate that
applies the sign. Defaults to |
rwa_logit() returns a list of outputs, as follows:
predictors: character vector of names of the predictor variables used.
rsquare: the pseudo R-squared value (sum of epsilon weights) for the logistic regression model.
result: the final output of the importance metrics.
The Rescaled.RelWeight column sums up to 100.
The Sign column indicates whether a predictor is positively or negatively associated with the outcome.
n: indicates the number of observations used in the analysis.
lambda: the Lambda transformation matrix from the analysis.
# Create a binary outcome variable
mtcars_binary <- mtcars
mtcars_binary$high_mpg <- ifelse(mtcars$mpg > median(mtcars$mpg), 1, 0)
# Basic logistic RWA
result <- rwa_logit(
df = mtcars_binary,
outcome = "high_mpg",
predictors = c("cyl", "disp", "hp", "wt")
)
# View the relative importance results
result$result
# With sign information
result_signed <- rwa_logit(
df = mtcars_binary,
outcome = "high_mpg",
predictors = c("cyl", "disp", "hp", "wt"),
applysigns = TRUE
)
result_signed$result
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.