Skip to content

Commit c87f76c

Browse files
authored
Merge pull request #433 from tlverse/fix-impute
don't attempt to impute covariates if there is no missingness
2 parents b794bb1 + d9ab177 commit c87f76c

File tree

5 files changed

+157
-14
lines changed

5 files changed

+157
-14
lines changed

.github/workflows/R-CMD-check.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929

3030
steps:
3131
- name: Checkout repo
32-
uses: actions/checkout@v3
32+
uses: actions/checkout@v4
3333

3434
- name: Setup R
3535
uses: r-lib/actions/setup-r@v2
@@ -50,7 +50,7 @@ jobs:
5050
5151
- name: Install package dependencies
5252
run: |
53-
install.packages(c("remotes", "devtools", "rcmdcheck", "covr", "sessioninfo"))
53+
install.packages(c("remotes", "rcmdcheck", "covr", "sessioninfo"))
5454
remotes::install_deps(dependencies = TRUE)
5555
shell: Rscript {0}
5656

DESCRIPTION

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Depends: R (>= 3.6.0)
3333
Imports:
3434
data.table,
3535
assertthat,
36-
origami (>= 1.0.3),
36+
origami (>= 1.0.7),
3737
R6,
3838
uuid,
3939
BBmisc,
@@ -68,7 +68,7 @@ Suggests:
6868
glmnet,
6969
grf,
7070
gbm,
71-
hal9001 (>= 0.4.4),
71+
hal9001 (>= 0.4.6),
7272
h2o,
7373
keras,
7474
nloptr,
@@ -84,16 +84,14 @@ Suggests:
8484
xgboost,
8585
lightgbm,
8686
dbarts,
87-
gam (>= 1.15.0),
88-
haldensify (>= 0.2.3),
87+
gam,
88+
haldensify (>= 0.2.7),
8989
mgcv,
9090
hts,
9191
GA,
9292
SIS,
9393
partykit
9494
Remotes:
95-
github::tlverse/origami,
96-
github::tlverse/hal9001@devel,
9795
github::nhejazi/haldensify
9896
License: GPL-3
9997
Language: en-US

R/process_data.R

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,15 @@ process_data <- function(data, nodes, column_names, flag = TRUE,
132132
# add inidicators to column map and covariate list
133133
column_names[missing_indicator_vars] <- missing_indicator_cols
134134
nodes$covariates <- c(nodes$covariates, missing_indicator_vars)
135+
136+
# impute covariates
137+
data_missing_covars <- data[, missing_covar_cols, with = FALSE]
138+
imputed <- impute(data.frame(data_missing_covars))
139+
140+
# update data
141+
set(data, , missing_covar_cols, imputed)
142+
135143
}
136-
# impute covariates
137-
data_missing_covars <- data[, missing_covar_cols, with = FALSE]
138-
imputed <- impute(data.frame(data_missing_covars))
139-
140-
# update data
141-
set(data, , missing_covar_cols, imputed)
142144
}
143145

144146
na_Y <- (!is.null(nodes$outcome) && any(is.na(data[, outcome_columns, with = F])))

testresults.txt

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
[2024-04-29 20:20:53] ══ Documenting ═════════════════════════════════════════════════════════════════
2+
[2024-04-29 20:20:53] ℹ Updating sl3 documentation
3+
[2024-04-29 20:20:54] ℹ Loading sl3
4+
[2024-04-29 20:20:57]
5+
[2024-04-29 20:20:57] ══ Building ════════════════════════════════════════════════════════════════════
6+
[2024-04-29 20:20:57] Setting env vars:
7+
[2024-04-29 20:20:57] • CFLAGS : -Wall -pedantic
8+
[2024-04-29 20:20:57] • CXXFLAGS : -Wall -pedantic
9+
[2024-04-29 20:20:57] • CXX11FLAGS: -Wall -pedantic
10+
[2024-04-29 20:20:57] • CXX14FLAGS: -Wall -pedantic
11+
[2024-04-29 20:20:57] • CXX17FLAGS: -Wall -pedantic
12+
[2024-04-29 20:20:57] • CXX20FLAGS: -Wall -pedantic
13+
[2024-04-29 20:20:57] ── R CMD build ─────────────────────────────────────────────────────────────────
14+
[2024-04-29 20:20:57] * checking for file ‘/home/jrcoyle/Dropbox/tlverse/sl3/DESCRIPTION’ ... OK
15+
[2024-04-29 20:20:57] * preparing ‘sl3’:
16+
[2024-04-29 20:20:57] * checking DESCRIPTION meta-information ... OK
17+
[2024-04-29 20:20:57] * installing the package to process help pages
18+
[2024-04-29 20:21:14] Loading required namespace: sl3
19+
[2024-04-29 20:21:15] * saving partial Rd database
20+
[2024-04-29 20:21:19] * creating vignettes ... OK
21+
[2024-04-29 20:21:19] * checking for LF line-endings in source and make files and shell scripts
22+
[2024-04-29 20:21:19] * checking for empty or unneeded directories
23+
[2024-04-29 20:21:19] Removed empty directory ‘sl3/tests/testthat/_snaps’
24+
[2024-04-29 20:21:19] * building ‘sl3_1.4.5.tar.gz’
25+
[2024-04-29 20:21:19]
26+
[2024-04-29 20:21:19] ══ Checking ════════════════════════════════════════════════════════════════════
27+
[2024-04-29 20:21:19] Setting env vars:
28+
[2024-04-29 20:21:19] • _R_CHECK_CRAN_INCOMING_USE_ASPELL_ : TRUE
29+
[2024-04-29 20:21:19] • _R_CHECK_CRAN_INCOMING_REMOTE_ : FALSE
30+
[2024-04-29 20:21:19] • _R_CHECK_CRAN_INCOMING_ : FALSE
31+
[2024-04-29 20:21:19] • _R_CHECK_FORCE_SUGGESTS_ : FALSE
32+
[2024-04-29 20:21:19] • _R_CHECK_PACKAGES_USED_IGNORE_UNUSED_IMPORTS_: FALSE
33+
[2024-04-29 20:21:19] • NOT_CRAN : false
34+
[2024-04-29 20:21:19] ── R CMD check ─────────────────────────────────────────────────────────────────
35+
[2024-04-29 20:21:19] * using log directory ‘/tmp/RtmpZW35EK/file1237e20c4dd84/sl3.Rcheck’
36+
[2024-04-29 20:21:19] * using R version 4.3.3 (2024-02-29)
37+
[2024-04-29 20:21:19] * using platform: x86_64-pc-linux-gnu (64-bit)
38+
[2024-04-29 20:21:19] * R was compiled by
39+
[2024-04-29 20:21:19] gcc (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0
40+
[2024-04-29 20:21:19] GNU Fortran (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0
41+
[2024-04-29 20:21:19] * running under: Pop!_OS 20.04 LTS
42+
[2024-04-29 20:21:19] * using session charset: UTF-8
43+
[2024-04-29 20:21:20] * using options ‘--no-manual --as-cran’
44+
[2024-04-29 20:21:20] * checking for file ‘sl3/DESCRIPTION’ ... OK
45+
[2024-04-29 20:21:20] * this is package ‘sl3’ version ‘1.4.5’
46+
[2024-04-29 20:21:20] * package encoding: UTF-8
47+
[2024-04-29 20:21:20] * checking package namespace information ... OK
48+
[2024-04-29 20:21:20] * checking package dependencies ... OK
49+
[2024-04-29 20:21:20] * checking if this is a source package ... OK
50+
[2024-04-29 20:21:20] * checking if there is a namespace ... OK
51+
[2024-04-29 20:21:21] * checking for executable files ... OK
52+
[2024-04-29 20:21:21] * checking for hidden files and directories ... OK
53+
[2024-04-29 20:21:21] * checking for portable file names ... OK
54+
[2024-04-29 20:21:21] * checking for sufficient/correct file permissions ... OK
55+
[2024-04-29 20:21:37] * checking whether package ‘sl3’ can be installed ... [16s/16s] OK
56+
[2024-04-29 20:21:37] * checking installed package size ... OK
57+
[2024-04-29 20:21:37] * checking package directory ... OK
58+
[2024-04-29 20:21:37] * checking for future file timestamps ... OK
59+
[2024-04-29 20:21:37] * checking ‘build’ directory ... OK
60+
[2024-04-29 20:21:37] * checking DESCRIPTION meta-information ... OK
61+
[2024-04-29 20:21:37] * checking top-level files ... OK
62+
[2024-04-29 20:21:37] * checking for left-over files ... OK
63+
[2024-04-29 20:21:37] * checking index information ... OK
64+
[2024-04-29 20:21:38] * checking package subdirectories ... OK
65+
[2024-04-29 20:21:38] * checking R files for non-ASCII characters ... OK
66+
[2024-04-29 20:21:38] * checking R files for syntax errors ... OK
67+
[2024-04-29 20:21:39] * checking whether the package can be loaded ... OK
68+
[2024-04-29 20:21:40] * checking whether the package can be loaded with stated dependencies ... OK
69+
[2024-04-29 20:21:41] * checking whether the package can be unloaded cleanly ... OK
70+
[2024-04-29 20:21:42] * checking whether the namespace can be loaded with stated dependencies ... OK
71+
[2024-04-29 20:21:44] * checking whether the namespace can be unloaded cleanly ... OK
72+
[2024-04-29 20:21:45] * checking loading without being on the library search path ... OK
73+
[2024-04-29 20:21:48] * checking startup messages can be suppressed ... OK
74+
[2024-04-29 20:21:49] * checking dependencies in R code ... OK
75+
[2024-04-29 20:21:50] * checking S3 generic/method consistency ... OK
76+
[2024-04-29 20:21:52] * checking replacement functions ... OK
77+
[2024-04-29 20:21:53] * checking foreign function calls ... OK
78+
[2024-04-29 20:22:00] * checking R code for possible problems ... OK
79+
[2024-04-29 20:22:02] * checking Rd files ... OK
80+
[2024-04-29 20:22:02] * checking Rd metadata ... OK
81+
[2024-04-29 20:22:02] * checking Rd line widths ... OK
82+
[2024-04-29 20:22:03] * checking Rd cross-references ... OK
83+
[2024-04-29 20:22:04] * checking for missing documentation entries ... OK
84+
[2024-04-29 20:22:08] * checking for code/documentation mismatches ... OK
85+
[2024-04-29 20:22:09] * checking Rd \usage sections ... OK
86+
[2024-04-29 20:22:09] * checking Rd contents ... OK
87+
[2024-04-29 20:22:10] * checking for unstated dependencies in examples ... OK
88+
[2024-04-29 20:22:10] * checking contents of ‘data’ directory ... OK
89+
[2024-04-29 20:22:10] * checking data for non-ASCII characters ... OK
90+
[2024-04-29 20:22:10] * checking LazyData ... OK
91+
[2024-04-29 20:22:10] * checking data for ASCII and uncompressed saves ... OK
92+
[2024-04-29 20:22:10] * checking installed files from ‘inst/doc’ ... OK
93+
[2024-04-29 20:22:10] * checking files in ‘vignettes’ ... OK
94+
[2024-04-29 20:22:41] * checking examples ... [30s/31s] OK
95+
[2024-04-29 20:22:44] * checking for unstated dependencies in ‘tests’ ... OK
96+
[2024-04-29 20:22:44] * checking tests ...
97+
[2024-04-29 20:28:05] Running ‘testthat.R’ [401s/321s]
98+
[2024-04-29 20:28:05] [401s/321s] OK
99+
[2024-04-29 20:28:05] * checking for unstated dependencies in vignettes ... OK
100+
[2024-04-29 20:28:05] * checking package vignettes in ‘inst/doc’ ... OK
101+
[2024-04-29 20:28:10] * checking re-building of vignette outputs ... OK
102+
[2024-04-29 20:28:10] * checking for non-standard things in the check directory ... OK
103+
[2024-04-29 20:28:10] * checking for detritus in the temp directory ... OK
104+
[2024-04-29 20:28:10] * DONE
105+
[2024-04-29 20:28:10]
106+
[2024-04-29 20:28:10] Status: OK
107+
[2024-04-29 20:28:10]
108+
[2024-04-29 20:28:11] ── R CMD check results ────────────────────────────────────────── sl3 1.4.5 ────
109+
[2024-04-29 20:28:11] Duration: 6m 51.5s
110+
[2024-04-29 20:28:11]
111+
[2024-04-29 20:28:11] 0 errors ✔ | 0 warnings ✔ | 0 notes ✔
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
context("Incorporating corrections for missingness in covariates")
2+
3+
library(data.table)
4+
library(assertthat)
5+
library(uuid)
6+
library(sl3)
7+
library(tmle3)
8+
set.seed(34831)
9+
10+
# setup data for test
11+
data(cpp)
12+
data <- as.data.table(cpp)
13+
data[, parity01 := as.numeric(data$parity > 0)]
14+
data[, parity01_fac := factor(data$parity01)]
15+
data[, haz01 := as.numeric(data$haz > 0)]
16+
17+
node_list <- list(
18+
W = c(
19+
"apgar1", "apgar5", "gagebrth", "mage",
20+
"meducyrs", "sexn"
21+
),
22+
A = "waz",
23+
Y = "haz01"
24+
)
25+
26+
# drop missing A for now, might add back to test later
27+
missing_W <- apply(is.na(data[, c(node_list$W, node_list$A),
28+
with = FALSE
29+
]), 1, any)
30+
data <- data[!missing_W]
31+
32+
task <- sl3_Task$new(data, outcome=node_list$Y, covariates = node_list$W)

0 commit comments

Comments
 (0)