This function creates a Relative Weights Analysis (RWA) and returns a list of outputs.
RWA provides a heuristic method for estimating the relative weight of predictor variables in multiple regression, which involves
creating a multiple regression with on a set of transformed predictors which are orthogonal to each other but
maximally related to the original set of predictors.
rwa() is optimised for dplyr pipes and shows positive / negative signs for weights.
rwa(df, outcome, predictors, applysigns = FALSE, plot = TRUE)rwa() returns a list of outputs, as follows:
predictors: character vector of names of the predictor variables used.
rsquare: the rsquare value of the 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 correlated with the outcome.
n: indicates the number of observations used in the analysis.
lambda:
RXX: Correlation matrix of all the predictor variables against each other.
RXY: Correlation values of the predictor variables against the outcome variable.
Data frame or tibble to be passed through.
Outcome variable, to be specified as a string or bare input. Must be a numeric variable.
Predictor variable(s), to be specified as a vector of string(s) or bare input(s). All variables must be numeric.
Logical value specifying whether to show an estimate that applies the sign. Defaults to FALSE.
Logical value specifying whether to plot the rescaled importance metrics.
rwa() produces raw relative weight values (epsilons) as well as rescaled weights (scaled as a percentage of predictable variance)
for every predictor in the model.
Signs are added to the weights when the applysigns argument is set to TRUE.
See https://relativeimportance.davidson.edu/multipleregression.html for the original implementation that inspired this package.
library(ggplot2)
rwa(diamonds,"price",c("depth","carat"))
Run the code above in your browser using DataLab