Skip to content

Commit

Permalink
version 0.1.7
Browse files Browse the repository at this point in the history
  • Loading branch information
tunsmart authored and cran-robot committed Dec 4, 2023
1 parent 611e162 commit 18e827d
Show file tree
Hide file tree
Showing 11 changed files with 84 additions and 35 deletions.
15 changes: 7 additions & 8 deletions DESCRIPTION
@@ -1,21 +1,20 @@
Package: interactionR
Type: Package
Title: Full Reporting of Interaction Analyses
Version: 0.1.6
Version: 0.1.7
Author: Babatunde Alli
Maintainer: Babatunde Alli <babatunde.alli@mail.mcgill.ca>
Description: Produces a publication-ready table that includes all effect estimates necessary for full reporting effect modification and interaction analysis as recommended by Knol and Vanderweele (2012) [<doi:10.1093/ije/dyr218>].
It also estimates confidence interval for the trio of additive interaction measures using the delta method (see Hosmer and Lemeshow (1992), [<doi:10.1097/00001648-199209000-00012>]), variance recovery method (see Zou (2008), [<doi:10.1093/aje/kwn104>]), or percentile bootstrapping (see Assmann et al. (1996), [<doi:10.1097/00001648-199605000-00012>]).
Description: Produces a publication-ready table that includes all effect estimates necessary for full reporting effect modification and interaction analysis as recommended by Knol and Vanderweele (2012) [<doi:10.1093/ije/dyr218>]. It also estimates confidence interval for the trio of additive interaction measures using the delta method (see Hosmer and Lemeshow (1992), [<doi:10.1097/00001648-199209000-00012>]), variance recovery method (see Zou (2008), [<doi:10.1093/aje/kwn104>]), or percentile bootstrapping (see Assmann et al. (1996), [<doi:10.1097/00001648-199605000-00012>]).
License: GPL-3
Encoding: UTF-8
LazyData: true
Imports: msm, car, officer, flextable
RoxygenNote: 7.1.2
URL: https://github.com/epi-zen/interactionR
BugReports: https://github.com/epi-zen/interactionR/issues
RoxygenNote: 7.2.3
URL: https://github.com/tunsmart/interactionR
BugReports: https://github.com/tunsmart/interactionR/issues
Suggests: testthat (>= 2.1.0)
Depends: R (>= 2.10)
NeedsCompilation: no
Packaged: 2022-06-04 18:14:14 UTC; tunsm
Packaged: 2023-12-03 22:43:43 UTC; tunsm
Repository: CRAN
Date/Publication: 2022-06-04 18:30:02 UTC
Date/Publication: 2023-12-03 23:00:03 UTC
20 changes: 10 additions & 10 deletions MD5
@@ -1,20 +1,20 @@
ab67ae9e15919bebf8f6e28963924f7d *DESCRIPTION
850013e1f9eb67e9c4448d98334e500d *DESCRIPTION
edc81ef3b426a176e280f83a20b9841b *NAMESPACE
b5febf648d39e924ac7be2e6a191b09b *NEWS.md
8cfbca5f277d89e9b2278fcc7ba92abc *NEWS.md
8da546be75587747de5eeb415091373b *R/HDiscdata.R
05746067aaaebe75ddd7520c860d0e12 *R/OCdata.R
01dca54da04e82749c353c1d831ae153 *R/global.R
9380da78eb96b449035ff9367a43927e *R/helpers.R
e6f11c93a778933fafe9aab9025eb6da *R/interactionR.R
5695b49a67cb6e1ad9e56733733b8912 *R/global.R
125e51bee7806ba357ec4110e80d5530 *R/helpers.R
67b0368bd93de47ca47f5a51cd817552 *R/interactionR.R
1a50059080b0fffc141a65562d48ff4e *R/interactionR_boot.R
ff439e4c562ce80d12e0cef37ceb5741 *R/interactionR_delta.R
5349b0fc8571892d7ebefe51ebaae30d *R/interactionR_delta.R
5df8de12ac83201579bf2249613fb5fc *R/interactionR_mover.R
68cedcaf25a1443daa713de8e115f904 *R/interactionR_table.R
5297ce6113a2e27dbeaf5d58f3fef206 *README.md
720388527841511fb0ab138d7bf95dbd *build/partial.rdb
ebd98b1f9c4604edfbafdd5298af1fa0 *README.md
b943a1546a1e17be4eea235ec7b4616b *build/partial.rdb
5315b36e8817a0b7bd5c8e6924641a1e *data/HDiscdata.rda
2eebe5bdd610e465cb1ff1d06edd02fa *data/OCdata.rda
cded81821e1f74350089f0037741d609 *inst/CITATION
118c14e19a9bbe15410daf9974b3b4a0 *inst/CITATION
444a38c2d05ba69ccf0521416b769ea4 *man/HDiscdata.Rd
7db69e8b57eb9577441f8947716557e7 *man/OCdata.Rd
389c4364d9e596481045e699b63e619e *man/figures/Figure-1.png
Expand All @@ -26,5 +26,5 @@ e4f9e2247801e87e5dc9c22c9e835411 *man/interactionR_boot.Rd
d27a5c4bb701982313d7db1259afbf87 *man/interactionR_mover.Rd
14cfaa120fe33edd8a385894331ad6ad *man/interactionR_table.Rd
344b1fa06218a3f98f31a1d1d7be838e *tests/testthat.R
d8e2f5742232c1d568d5552b9131a0f5 *tests/testthat/test-interactionR.R
b244d5a80a5632d208f7299f1f649c51 *tests/testthat/test-interactionR.R
bc5bf0cd4544a8579895039e359b34ef *tests/testthat/test-interactionR_table.R
5 changes: 5 additions & 0 deletions NEWS.md
@@ -1,3 +1,8 @@
interactionR 0.1.7
==================

*Patch to correct pvalue estimation for SI and relax argument checkings

interactionR 0.1.6
==================

Expand Down
2 changes: 1 addition & 1 deletion R/global.R
@@ -1,5 +1,5 @@
utils::globalVariables(c(
"stats", "binomial", "coef", "confint.default", "glm",
"pnorm", "qnorm", "quantile", "update", "vcov", "askYesNo", "grep",
"str2lang", "model.frame", "is"
"str2lang", "model.frame", "is", "plnorm"
))
8 changes: 6 additions & 2 deletions R/helpers.R
Expand Up @@ -8,15 +8,19 @@ invalid <- function(model) {
}

check_arguments <- function(model, exposure_names) {
original_names <- exposure_names
modified_names <- grep(paste0("^", original_names[1], "|^", original_names[2]), names(coef(model)), value = TRUE)

if (!invalid(model)) {
stop("The 'model' argument must be a regression model object fit with glm(), coxph() or clogit()")
} else if (!is(exposure_names, "character") || length(exposure_names) != 2) {
} else if (!is(exposure_names, "character") || length(exposure_names) != 2) {
stop("Argument 'exposure_names' requires a character vector of the names of the two exposure variables")
} else if (anyNA(match(exposure_names, names(coef(model))))) {
} else if (length(modified_names) < 2) {
stop("At least one of the exposure names you have identified cannot be found in your model")
}
}


extract_pvals <- function(model) {
if ("glm" %in% class(model)) {
return(summary(model)$coefficients[,4])
Expand Down
4 changes: 3 additions & 1 deletion R/interactionR.R
Expand Up @@ -389,7 +389,7 @@ interactionR <- function(model, exposure_names = c(), ci.type = "delta", ci.leve

SIL <- exp(lnSI - z * se_SI)
SIU <- exp(lnSI + z * se_SI)
p.SI <- 1 - pnorm(exp(lnSI/se_SI))
p.SI <- 1 - plnorm(exp(lnSI/se_SI))

} else {
stop("Argument 'ci.type' must be 'delta' or 'mover' ")
Expand Down Expand Up @@ -457,6 +457,8 @@ interactionR <- function(model, exposure_names = c(), ci.type = "delta", ci.leve
raw_data <- dat.ir
}

d$p = round(d$p, 5)

ir <- list(dframe = d, exp_names = c(beta1, beta2), analysis = em, call = model$call, dat = raw_data)
attr(ir, "class") <- "interactionR"

Expand Down
6 changes: 3 additions & 3 deletions R/interactionR_delta.R
Expand Up @@ -197,7 +197,7 @@ interactionR_delta <- function(model, exposure_names = c(), ci.level = 0.95, em

CI.ll_SI <- exp(lnSI - z * se_SI)
CI.ul_SI <- exp(lnSI + z * se_SI)
p.SI <- NA
p.SI <- 1 - plnorm(exp(lnSI/se_SI))

d <- data.frame(Measures = c(
"OR00", "OR01", "OR10", "OR11", paste("OR(",
Expand Down Expand Up @@ -266,8 +266,8 @@ interactionR_delta <- function(model, exposure_names = c(), ci.level = 0.95, em
if (exists("dat.ir")) {
raw_data <- dat.ir
}
#d$p = ifelse(d$p < 0.001, "<0.001", round(d$p, 8))
d$p = round(d$p, 6)

d$p = round(d$p, 5)

ir <- list(dframe = d, exp_names = c(beta1, beta2), analysis = em, call = model$call, dat = raw_data)
attr(ir, "class") <- "interactionR"
Expand Down
8 changes: 4 additions & 4 deletions README.md
@@ -1,6 +1,6 @@
# About interactionR

[![R-CMD-check](https://github.com/epi-zen/interactionR/actions/workflows/check-standard.yaml/badge.svg)](https://github.com/epi-zen/interactionR/actions/workflows/check-standard.yaml)
[![R-CMD-check](https://github.com/tunsmart/interactionR/actions/workflows/check-standard.yaml/badge.svg)](https://github.com/tunsmart/interactionR/actions/workflows/check-standard.yaml)
[![](https://www.r-pkg.org/badges/version/interactionR)](https://cran.r-project.org/package=interactionR)
![Downloads](https://cranlogs.r-pkg.org/badges/interactionR)
[![](http://cranlogs.r-pkg.org/badges/grand-total/interactionR)](https://cran.r-project.org/package=interactionR)
Expand All @@ -23,11 +23,11 @@ interactionR is on
`install.packages("interactionR")`.

You can also install the development version from
[GitHub](https://github.com/epi-zen/interactionR) with:
[GitHub](https://github.com/tunsmart/interactionR) with:

``` r
# install.packages("devtools")
devtools::install_github("epi-zen/interactionR")
devtools::install_github("tunsmart/interactionR")
```

# Implementation
Expand Down Expand Up @@ -197,7 +197,7 @@ both development and releases.
### To report problems, bugs or issues

Please use [interactionR
issues](https://github.com/epi-zen/interactionR/issues) here on Github.
issues](https://github.com/tunsmart/interactionR/issues) here on Github.

### To get support

Expand Down
Binary file modified build/partial.rdb
Binary file not shown.
11 changes: 5 additions & 6 deletions inst/CITATION
@@ -1,16 +1,15 @@
citHeader("To cite interactionR in publications use:")

citEntry(
entry = "Article",
title = "InteractionR: An R package for full reporting of
effect modification and interaction",
author = as.person("Babatunde Yusuf Alli"),
bibentry(
"Article",
title = "InteractionR: An R package for full reporting of effect modification and interaction",
author = "Babatunde Yusuf Alli",
journal = "Software Impacts",
year = "2021",
volume = "10",
number = "00147",
pages = "0-0",
url = "https://doi.org/10.1016/j.simpa.2021.100147",
doi = "10.1016/j.simpa.2021.100147",
textVersion = paste("Babatunde Y. Alli (2021).",
"InteractionR: An R package for full reporting of effect modification and interaction.", "Software Impacts, 10, 100147.", "doi:10.1016/j.simpa.2021.100147")
)
40 changes: 40 additions & 0 deletions tests/testthat/test-interactionR.R
Expand Up @@ -74,6 +74,46 @@ test_that("generates error when exposure name cannot be found in model", {
)
})


test_that("works correctly with numeric exposure variables", {
model <- glm(exp3 ~ exp1 * exp2, data=d)
expect_no_error(
interactionR(model,
exposure_names = c("exp1", "exp2"),
ci.type = "delta", ci.level = 0.95,
em = FALSE, recode = FALSE
)
)
})

test_that("works correctly with character/factor exposure variables", {
d$exp1 <- as.factor(exp1)
d$exp2 <- as.factor(exp2)
model <- glm(outcome ~ exp1 * exp2, data=d, family = binomial(link = "logit"))
expect_no_error(
interactionR(model,
exposure_names = c("exp1", "exp2"),
ci.type = "delta", ci.level = 0.95,
em = FALSE, recode = FALSE
)
)
})

test_that("works correctly with unknown postfix in exposure variables (using factor levels)", {
d$exp1 <- factor(exp1, levels = c(0, 1), labels = c("No", "Yes"))
d$exp2 <- factor(exp2, levels = c(0, 1), labels = c("No", "Yes"))

model <- glm(outcome ~ exp1 * exp2, data=d, family = binomial(link = "logit"))
expect_no_error(
interactionR(model,
exposure_names = c("exp1", "exp2"),
ci.type = "delta", ci.level = 0.95,
em = FALSE, recode = FALSE
)
)
})


test_that("generates error when exposures interaction cannot be found in the model", {
model <- glm(outcome ~ exp2*exp3 + exp1, data=d)
expect_error(
Expand Down

0 comments on commit 18e827d

Please sign in to comment.