rwa

Package for running Relative Weights Analysis in R

https://github.com/martinctc/rwa

Science Score: 36.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
    Links to: springer.com
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (14.1%) to scientific vocabulary

Keywords

r relative-weights rwa
Last synced: 10 months ago · JSON representation

Repository

Package for running Relative Weights Analysis in R

Basic Info
Statistics
  • Stars: 15
  • Watchers: 2
  • Forks: 8
  • Open Issues: 4
  • Releases: 1
Topics
r relative-weights rwa
Created over 7 years ago · Last pushed 12 months ago
Metadata Files
Readme Changelog

README.md

rwa

R build status CodeFactor CRAN status CRAN last month downloads

Perform a Relative Weights Analysis in R

Background

Relative Weights Analysis (RWA) is a method of calculating relative importance of predictor variables in contributing to an outcome variable. The method implemented by this function is based on Tonidandel and LeBreton (2015), but the origin of this specific approach can be traced back to Johnson (2000), A Heuristic Method for Estimating the Relative Weight of Predictor Variables in Multiple Regression. Broadly speaking, RWA belongs to a family of techiques under the broad umbrella 'Relative Importance Analysis', where other members include the 'Shapley method' and 'dominance analysis'. This is often referred to as 'Key Drivers Analysis' within market research.

This package is built around the main function rwa(), which takes in a data frame as an argument and allows you to specify the names of the input variables and the outcome variable as arguments.

The rwa() function in this package is compatible with dplyr / tidyverse style of piping operations to enable cleaner and more readable code.


Installation

You can install the stable CRAN version of rwa with:

R install.packages("rwa")

Alternatively, you can install the latest development version from GitHub with:

R install.packages("devtools") devtools::install_github("martinctc/rwa")


Method / Technical details

RWA decomposes the total variance predicted in a regression model (R2) into weights that accurately reflect the proportional contribution of the various predictor variables.

RWA is a useful technique to calculate the relative importance of predictors (independent variables) when independent variables are correlated to each other. It is an alternative to multiple regression technique and it addresses the multicollinearity problem, and also helps to calculate the importance rank of variables. It helps to answer "which variable is the most important and rank variables based on their contribution to R-Square".

See https://link.springer.com/content/pdf/10.1007%2Fs10869-014-9351-z.pdf.

Multicollinearity

When independent variables are correlated, it is difficult to determine the correct prediction power of each variable. Hence, it is difficult to rank them as we are unable to estimate coefficients correctly. Statistically, multicollinearity can increase the standard error of the coefficient estimates and make the estimates very sensitive to minor changes in the model. It means the coefficients are biased and difficult to interpret.

Signs

Key Drivers Analysis methods do not conventionally include a score sign, which can make it difficult to interpret whether a variable is positively or negatively driving the outcome. The applysigns argument in rwa::rwa(), when set to TRUE, allows the application of positive or negative signs to the driver scores to match the signs of the corresponding linear regression coefficients from the model. This feature mimics the solution used in the Q research software. The resulting column is labelled Sign.Rescaled.RelWeight to distinguish from the unsigned column.

Estimating the statistical significance of relative weights

As Tonidandel et al. (2009) noted, there is no default procedure for determining the statistical significance of individual relative weights:

The difficulty in determining the statistical significance of relative weights stems from the fact that the exact (or small sample) sampling distribution of relative weights is unknown.

The paper itself suggests a Monte Carlo method for estimating the statistical significance, but this is currently not available or provided in the package, but the plan is to implement this in the near future.

Basic example

You can pass the raw data directly into rwa(), without having to first compute a correlation matrix. The below example is with mtcars.

Code: ```R library(rwa) library(tidyverse)

mtcars %>% rwa(outcome = "mpg", predictors = c("cyl", "disp", "hp", "gear"), applysigns = TRUE) Results: R $predictors [1] "cyl" "disp" "hp" "gear"

$rsquare [1] 0.7791896

$result Variables Raw.RelWeight Rescaled.RelWeight Sign Sign.Rescaled.RelWeight 1 cyl 0.2284797 29.32274 - -29.32274 2 disp 0.2221469 28.50999 - -28.50999 3 hp 0.2321744 29.79691 - -29.79691 4 gear 0.0963886 12.37037 + 12.37037

$n [1] 32
```


Documentation

For comprehensive examples and methodology explanations, see the package vignettes:

```R

Main introduction to RWA

vignette("introduction-to-rwa", package = "rwa")

Bootstrap confidence intervals for statistical significance

vignette("bootstrap-confidence-intervals", package = "rwa") ```

The vignettes cover:

  • Introduction vignette: Detailed methodology, basic examples, and when to use RWA
  • Bootstrap vignette: Statistical significance testing, confidence intervals, and advanced features
  • Real-world applications and best practices
  • Troubleshooting and interpretation guidance

Latest Status

The main rwa() function is ready-to-use and now includes bootstrap confidence intervals for determining the statistical significance of relative weights. The package includes comprehensive documentation through vignettes and is designed to integrate seamlessly with tidyverse workflows.


Contact me

Please feel free to submit suggestions and report bugs: https://github.com/martinctc/rwa/issues

Also check out my website for my other work and packages.

References / Bibliography

Azen, R., & Budescu, D. V. (2003). The dominance analysis approach for comparing predictors in multiple regression. Psychological methods, 8(2), 129.

Budescu, D. V. (1993). Dominance analysis: a new approach to the problem of relative importance of predictors in multiple regression. Psychological bulletin, 114(3), 542.

Grömping, U. (2006). Relative importance for linear regression in R: the package relaimpo. Journal of statistical software, 17(1), 1-27.

Grömping, U. (2009). Variable importance assessment in regression: linear regression versus random forest. The American Statistician, 63(4), 308-319.

Johnson, J. W., & LeBreton, J. M. (2004). History and use of relative importance indices in organizational research. Organizational research methods, 7(3), 238-257.

Lindeman RH, Merenda PF, Gold RZ (1980). Introduction to Bivariate and Multivariate Analysis. Scott, Foresman, Glenview, IL.

Tonidandel, S., & LeBreton, J. M. (2011). Relative importance analysis: A useful supplement to regression analysis. Journal of Business and Psychology, 26(1), 1-9.

Tonidandel, S., LeBreton, J. M., & Johnson, J. W. (2009). Determining the statistical significance of relative weights. Psychological methods, 14(4), 387.

Wang, X., Duverger, P., Bansal, H. S. (2013). Bayesian Inference of Predictors Relative Importance in Linear Regression Model using Dominance Hierarchies. International Journal of Pure and Applied Mathematics, Vol. 88, No. 3, 321-339.

Also see Kovalyshyn for a similar implementation but in Javascript.

Owner

  • Name: Martin Chan
  • Login: martinctc
  • Kind: user
  • Location: London
  • Company: Microsoft

Data Science @ Microsoft Viva

GitHub Events

Total
  • Create event: 1
  • Release event: 1
  • Issues event: 1
  • Watch event: 2
  • Delete event: 2
  • Issue comment event: 3
  • Push event: 26
  • Pull request event: 1
  • Fork event: 1
Last Year
  • Create event: 1
  • Release event: 1
  • Issues event: 1
  • Watch event: 2
  • Delete event: 2
  • Issue comment event: 3
  • Push event: 26
  • Pull request event: 1
  • Fork event: 1

Committers

Last synced: over 2 years ago

All Time
  • Total Commits: 54
  • Total Committers: 2
  • Avg Commits per committer: 27.0
  • Development Distribution Score (DDS): 0.019
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Martin Chan m****3@g****m 53
Martin Chan m****n@R****l 1

Issues and Pull Requests

Last synced: 10 months ago

All Time
  • Total issues: 13
  • Total pull requests: 6
  • Average time to close issues: about 1 year
  • Average time to close pull requests: 7 days
  • Total issue authors: 13
  • Total pull request authors: 1
  • Average comments per issue: 2.08
  • Average comments per pull request: 0.5
  • Merged pull requests: 3
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 1
  • Pull requests: 1
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 1
  • Pull request authors: 1
  • Average comments per issue: 0.0
  • Average comments per pull request: 0.0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • Tepico (1)
  • mattdpalm (1)
  • maipham123 (1)
  • liuyuping233 (1)
  • benediktwetzel (1)
  • kaas66 (1)
  • marvinneumann1108 (1)
  • martinctc (1)
  • mizumot (1)
  • SietseDost (1)
  • research-max (1)
  • kalimiddleby (1)
Pull Request Authors
  • martinctc (6)
Top Labels
Issue Labels
enhancement (3) question (3) help wanted (2) documentation (1) bug (1)
Pull Request Labels
enhancement (2)

Packages

  • Total packages: 1
  • Total downloads:
    • cran 453 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 2
  • Total maintainers: 1
cran.r-project.org: rwa

Perform a Relative Weights Analysis

  • Versions: 2
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 453 Last month
Rankings
Forks count: 9.1%
Downloads: 13.6%
Stargazers count: 17.9%
Average: 21.2%
Dependent packages count: 29.8%
Dependent repos count: 35.5%
Maintainers (1)
Last synced: 11 months ago

Dependencies

DESCRIPTION cran
  • dplyr * imports
  • ggplot2 * imports
  • magrittr * imports
  • stats * imports
  • tidyr * imports
.github/workflows/R-CMD-check.yaml actions
  • actions/checkout v4 composite
  • r-lib/actions/setup-r v2 composite
.github/workflows/pkgdown.yaml actions
  • actions/cache v2 composite
  • actions/checkout v2 composite
  • r-lib/actions/setup-pandoc v1 composite
  • r-lib/actions/setup-r v1 composite