Skip to content

Commit 64e9d2c

Browse files
committed
Fix R check issues
1 parent b401f42 commit 64e9d2c

File tree

5 files changed

+19
-16
lines changed

5 files changed

+19
-16
lines changed

DESCRIPTION

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Package: CohortMethod
22
Type: Package
33
Title: New-User Cohort Method with Large Scale Propensity and Outcome Models
44
Version: 6.0.0
5-
Date: 2025-11-25
5+
Date: 2026-02-13
66
Authors@R: c(
77
person("Martijn", "Schuemie", , "schuemie@ohdsi.org", role = c("aut", "cre")),
88
person("Marc", "Suchard", role = c("aut")),
@@ -61,7 +61,8 @@ Suggests:
6161
R.utils,
6262
RSQLite,
6363
ResultModelManager,
64-
markdown
64+
markdown,
65+
PSweight
6566
SystemRequirements: Java
6667
LinkingTo: Rcpp
6768
NeedsCompilation: yes

R/PsFunctions.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -750,16 +750,16 @@ trimByPs <- function(population, trimByPsArgs = createTrimByPsArgs(trimFraction
750750
if (trimByPsArgs$trimMethod %in% c("asymmetric", "reverse asymmetric")){
751751
# Remove overlapping patients
752752
bounds <- population |>
753-
group_by(treatment) |>
754-
summarise(minPs = min(propensityScore),
755-
maxPs = max(propensityScore),
753+
group_by(.data$treatment) |>
754+
summarise(minPs = min(.data$propensityScore),
755+
maxPs = max(.data$propensityScore),
756756
.groups = "drop"
757757
)
758758
lower <- max(bounds$minPs)
759759
upper <- min(bounds$maxPs)
760760
population <- population |>
761-
filter(propensityScore >= lower,
762-
propensityScore <= upper)
761+
filter(.data$propensityScore >= lower,
762+
.data$propensityScore <= upper)
763763

764764
deltaTarget <- beforeCountTarget - sum(population$treatment == 1)
765765
deltaComparator <- beforeCountComparator - sum(population$treatment == 0)

R/SettingsObjects.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -429,10 +429,10 @@ CreatePsArgs <- R6Class(
429429
#' @param trimMethod The trimming method to be performed. Three methods are supported:
430430
#'
431431
#' - symmetric: trims all units with estimated PS outside the interval
432-
#' (`trimFraction`,1`trimFraction`), following Crump et al. (2009).
432+
#' (`trimFraction`,1-`trimFraction`), following Crump et al. (2009).
433433
#' - asymmetric: removes all units not in the overlap PS range and trims the
434434
#' `trimFraction` target persons with the lowest propensity scores and comparator
435-
#' persons with the highest propensity scores, following Stürmer et al. (2010).
435+
#' persons with the highest propensity scores, following Sturmer et al. (2010).
436436
#' - reverse asymmetric: removes all units not in the overlap PS range and trims the
437437
#' `trimFraction` target persons with the highest propensity scores and comparator
438438
#' persons with the lowest propensity scores (not suggested).
@@ -445,7 +445,7 @@ CreatePsArgs <- R6Class(
445445
#' Crump, Richard K., V. Joseph Hotz, Guido W. Imbens, and Oscar A. Mitnik. 2009. Dealing
446446
#' with limited overlap in estimation of average treatment effects. Biometrika 96(1): 187-199.
447447
#'
448-
#' Stürmer T, Rothman KJ, Avorn J, Glynn RJ. Treatment effects in the presence of unmeasured
448+
#' Sturmer T, Rothman KJ, Avorn J, Glynn RJ. Treatment effects in the presence of unmeasured
449449
#' confounding: dealing with observations in the tails of the propensity score distribution--a simulation study.
450450
#' Am J Epidemiol. 2010 Oct 1;172(7):843-54.
451451
#'

man/createTrimByPsArgs.Rd

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-psFunctions.R

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
library(CohortMethod)
22
library(testthat)
33
library(pROC)
4-
library(PSweight)
4+
# library(PSweight)
55

66
test_that("Simple 1-on-1 matching", {
77
rowId <- 1:5
@@ -267,6 +267,7 @@ test_that("IPTW ATO", {
267267
})
268268

269269
test_that("Trimming symmetric", {
270+
skip_if_not_installed("PSweight")
270271
rowId <- 1:10000
271272
treatment <- rep(c(1, 1, 1, 0), 2500)
272273
propensityScore <- (1:10000) / 10000
@@ -275,7 +276,7 @@ test_that("Trimming symmetric", {
275276
trimMethod = "symmetric")
276277
result <- trimByPs(data,
277278
trimByPsArgs = trimByPsArgs)
278-
gold <- PStrim(data = data,
279+
gold <- PSweight::PStrim(data = data,
279280
zname = "treatment",
280281
ps.estimate = data$propensityScore,
281282
delta = 0.1)
@@ -305,6 +306,7 @@ test_that("Trimming removing an entire treatment group", {
305306
})
306307

307308
test_that("Trimming symmetric", {
309+
skip_if_not_installed("PSweight")
308310
rowId <- 1:10000
309311
treatment <- rep(c(1, 1, 1, 0), 2500)
310312
propensityScore <- (1:10000) / 10000
@@ -313,7 +315,7 @@ test_that("Trimming symmetric", {
313315
trimMethod = "symmetric")
314316
result <- trimByPs(data,
315317
trimByPsArgs = trimByPsArgs)
316-
gold <- PStrim(data = data,
318+
gold <- PSweight::PStrim(data = data,
317319
zname = "treatment",
318320
ps.estimate = data$propensityScore,
319321
delta = 0.1)

0 commit comments

Comments
 (0)