Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
8dcc3fb
feat: create rwa_logit
martinctc Feb 27, 2021
b39e604
feat: create `rwa_multiregress()`
martinctc Feb 27, 2021
a4fe972
docs: improve wrapper documentation
martinctc Feb 27, 2021
029a568
Merge branch 'master' into feature/add-logistic-regression
martinctc Jan 21, 2026
e951272
feat: clean up parameters on rwa_logit() and rwa_multiregress()
martinctc Jan 21, 2026
0f97497
test: enhance coverage on new logit and regression functions
martinctc Jan 21, 2026
bfbc22c
feat: update data selection to use all_of for outcome and predictors …
martinctc Jan 21, 2026
5e35694
chore: add missing imports
martinctc Jan 21, 2026
0e0c53e
docs: remove problematic medium link failing R-CMD-checks
martinctc Jan 21, 2026
20fda7d
feat: update reference section in _pkgdown.yml to include rwa_multire…
martinctc Jan 21, 2026
09056ed
feat: enhance plot_rwa() to handle y-axis limits based on sign and up…
martinctc Jan 21, 2026
2170e8e
feat: add vignette for regression methods including multiple and logi…
martinctc Jan 21, 2026
2c9b032
chore: bump version to v0.1.2.9000
martinctc Jan 21, 2026
a69a04b
docs: update NEWS.md
martinctc Jan 21, 2026
df427dd
refactor: remove unused variable numVar from rwa_logit and rwa_multir…
martinctc Jan 21, 2026
35f0743
docs: enhance documentation for rwa_logit and rwa_multiregress functi…
martinctc Jan 21, 2026
22849b0
fix: specify tidyr::drop_na for complete cases calculation in rwa_log…
martinctc Jan 21, 2026
3a707ac
fix: handle variable name extraction for different regression types i…
martinctc Jan 21, 2026
20afed4
docs: update return values in rwa_logit documentation to clarify pseu…
martinctc Jan 21, 2026
c3485c3
test: add tests for logistic regression results in plot_rwa function
martinctc Jan 21, 2026
fbe9f60
fix: update Rescaled.RelWeight to sum to 100 for consistency with rwa…
martinctc Jan 21, 2026
7d30e5e
fix: update Rescaled.RelWeight representation in logistic regression …
martinctc Jan 21, 2026
fad0116
chore: correct indentation
martinctc Jan 21, 2026
100d522
fix: properly import NAMESPACE
martinctc Jan 21, 2026
e596154
chore: update opening brace style
martinctc Jan 21, 2026
d191712
docs: add lambda return value description in rwa_multiregress
martinctc Jan 21, 2026
30115e5
Merge branch 'feature/add-logistic-regression' of https://github.com/…
martinctc Jan 21, 2026
73d2200
docs: Update NEWS.md
martinctc Jan 21, 2026
95e3fe8
fix: standardize API and fix documentation inconsistencies
martinctc Jan 21, 2026
41c071f
fix: improve code quality and numerical stability in rwa_logit
martinctc Jan 22, 2026
043125e
docs: improve documentation accuracy and consistency
martinctc Jan 22, 2026
5ed0f57
chore: remove whitespace
martinctc Jan 22, 2026
6f8379e
refactor: align to R best practices for assignment
martinctc Jan 22, 2026
5d49b18
chore: cosmetic change on variable names
martinctc Jan 22, 2026
c71529b
fix: add missing global variable 'variable_name' to avoid false posit…
martinctc Jan 22, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: rwa
Type: Package
Title: Perform a Relative Weights Analysis
Version: 0.1.1
Version: 0.1.2.9000
Authors@R: person(given = "Martin",
family = "Chan",
role = c("aut", "cre"),
Expand Down
8 changes: 8 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ export("%>%")
export(plot_rwa)
export(remove_all_na_cols)
export(rwa)
export(rwa_logit)
export(rwa_multiregress)
import(dplyr)
import(ggplot2)
importFrom(boot,boot)
Expand All @@ -17,8 +19,14 @@ importFrom(dplyr,select)
importFrom(dplyr,tibble)
importFrom(magrittr,"%>%")
importFrom(purrr,map_dfr)
importFrom(stats,binomial)
importFrom(stats,coef)
importFrom(stats,cor)
importFrom(stats,glm)
importFrom(stats,lm)
importFrom(stats,predict)
importFrom(stats,rnorm)
importFrom(stats,sd)
importFrom(stats,var)
importFrom(tidyr,drop_na)
importFrom(utils,head)
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# rwa (development version)

- Added `rwa_logit()` and `rwa_multiregress()` to support logistic regression and multiple regression.
- Added new vignette to cover the new regression methods.
- Improved test coverage and minor bugfixes.

# rwa 0.1.1

## Improvements
Expand Down
3 changes: 2 additions & 1 deletion R/globals.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ utils::globalVariables(
"Sign",
"Rescaled.RelWeight",
"Variables",
"Sign.Rescaled.RelWeight"
"Sign.Rescaled.RelWeight",
"variable_name"
)
)
40 changes: 32 additions & 8 deletions R/plot_rwa.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,48 @@ plot_rwa <- function(rwa){
dplyr::mutate(Sign.Rescaled.RelWeight = ifelse(Sign == "-",
Rescaled.RelWeight * -1,
Rescaled.RelWeight))

# Get variable names from the Variables column
if (!"Variables" %in% names(result)) {
stop("Could not find 'Variables' column in result.")
}
result$variable_name <- result$Variables

# Calculate appropriate axis limits for both positive and negative values
max_abs_weight <- max(abs(result$Sign.Rescaled.RelWeight))
min_weight <- min(result$Sign.Rescaled.RelWeight)
max_weight <- max(result$Sign.Rescaled.RelWeight)

# Set symmetric or appropriate limits based on data
if (min_weight < 0 && max_weight > 0) {
# Mixed signs: use symmetric limits
y_limits <- c(-max_abs_weight * 1.15, max_abs_weight * 1.15)
} else if (min_weight < 0) {
# All negative: extend left for labels
y_limits <- c(min_weight * 1.15, max(0, max_weight * 1.1))
} else {
# All positive: extend right for labels
y_limits <- c(min(0, min_weight), max_weight * 1.15)
}

result %>%
ggplot(aes(x = stats::reorder(Variables, Sign.Rescaled.RelWeight),
ggplot(aes(x = stats::reorder(variable_name, Sign.Rescaled.RelWeight),
y = Sign.Rescaled.RelWeight)) +
geom_col(fill = "#0066cc") +
geom_text(aes(label = round(Sign.Rescaled.RelWeight, 1)), hjust = -0.3) +
geom_text(aes(label = round(Sign.Rescaled.RelWeight, 1),
hjust = ifelse(Sign.Rescaled.RelWeight >= 0, -0.3, 1.3))) +
coord_flip() +
ylim(c(NA, max_weight * 1.1)) + # Automatic lower limit
ylim(y_limits) +
labs(title = "Variable importance estimates",
subtitle = "Using the Relative Weights Analysis method",
x = "Predictor variables",
y = "Rescaled Relative Weights",
caption = paste0("Note: Rescaled Relative Weights sum to 100%. n = ",
y = "Rescaled Relative Weights (with sign)",
caption = paste0("Note: Absolute Rescaled Relative Weights sum to 100%. n = ",
rwa$n, ". ",
"R-squared: ",
round(rwa$rsquare, 2),
".")) +
if (!is.null(rwa$rsquare)) {
paste0("R-squared: ", round(rwa$rsquare, 2), ".")
} else {
""
})) +
theme_classic()
}
Loading