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)
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 |
plot | Logical value specifying whether to plot the rescaled importance metrics. |
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.
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.
#> $predictors #> [1] "depth" "carat" #> #> $rsquare #> [1] 0.8506755 #> #> $result #> Variables Raw.RelWeight Rescaled.RelWeight Sign #> 1 depth 0.000729149 0.08571412 - #> 2 carat 0.849946308 99.91428588 + #> #> $n #> [1] 53940 #> #> $lambda #> [,1] [,2] #> [1,] 0.99990040 0.01411356 #> [2,] 0.01411356 0.99990040 #> #> $RXX #> depth carat #> depth 1.00000000 0.02822431 #> carat 0.02822431 1.00000000 #> #> $RXY #> depth carat #> -0.0106474 0.9215913 #>