Skip to content

Commit

Permalink
Merge pull request #79 from svteichman/check_zero_categories
Browse files Browse the repository at this point in the history
Address points 2 and 3 in issue #78
  • Loading branch information
svteichman authored Aug 27, 2024
2 parents 0054949 + 7251d3c commit 8ab0fd7
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 3 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Depends:
methods,
dplyr,
ggplot2,
rlang,
R (>= 2.10)
Suggests:
testthat (>= 3.0.0),
Expand All @@ -30,4 +31,4 @@ Suggests:
parallel,
rmarkdown
Config/testthat/edition: 3
VignetteBuilder: knitr
VignetteBuilder: knitr
4 changes: 4 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
# Generated by roxygen2: do not edit by hand

S3method(plot,radEmu)
S3method(print,emuFit)
export(emuFit)
export(emuFit_micro)
export(score_test)
export(simulate_data)
import(MASS)
import(Matrix)
import(dplyr)
import(ggplot2)
importFrom(methods,as)
importFrom(rlang,.data)
importFrom(stats,cov)
importFrom(stats,median)
importFrom(stats,model.matrix)
Expand Down
1 change: 1 addition & 0 deletions R/emuFit.R
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,7 @@ and the corresponding gradient function to constraint_grad_fn.")
if (!is.null(zero_comparison_res)) {
coefficients <- dplyr::full_join(coefficients, zero_comparison_res,
by = c("covariate", "category"))
coefficients$zero_comparison[is.na(coefficients$zero_comparison)] <- FALSE

if (remove_zero_comparison_pvals == TRUE | is.numeric(remove_zero_comparison_pvals)) {
pval_cols <- which(grepl("pval", names(coefficients)))
Expand Down
2 changes: 1 addition & 1 deletion R/zero_comparison_check.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ zero_comparison_check <- function(X, Y) {
}

# get matrix that is (p - 1) x J that gives whether or not parameter is zero-comparison
zero_comp <- matrix(NA, nrow = n_groups - 1, J)
zero_comp <- matrix(FALSE, nrow = n_groups - 1, J)
for (i in 1:(n_groups - 1)) {
zero_comp[i, ] <- (group_counts[1, ] == 0) * (group_counts[i + 1, ] == 0) == 1
}
Expand Down
76 changes: 76 additions & 0 deletions man/plot.radEmu.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/testthat/test-zero_comparison_check.R
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ test_that("zero_comparison column is added to coef when it should be, model.matr
emuRes5 <- emuFit(Y = Y0, X = X5, run_score_tests = FALSE, compute_cis = FALSE)
expect_true("zero_comparison" %in% names(emuRes5$coef))
expect_true(emuRes5$coef$zero_comparison[1])
expect_true(is.na(emuRes5$coef$zero_comparison[13]))
expect_false(emuRes5$coef$zero_comparison[13])
expect_true(emuRes5$coef$zero_comparison[31])
expect_false(emuRes5$coef$zero_comparison[32])
})

0 comments on commit 8ab0fd7

Please sign in to comment.