Skip to content

Commit c39275e

Browse files
author
Keith Goldfeld
committed
Commenting out long tests
1 parent ab20dec commit c39275e

File tree

2 files changed

+128
-128
lines changed

2 files changed

+128
-128
lines changed

tests/testthat/test-define_data.R

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,28 @@ test_that("defData throws errors", {
1515

1616

1717
# .evalDef ----
18-
test_that("checks combine in .evalDef correctly", {
19-
skip_on_cran()
20-
21-
# this generates 20 previously defined varnames.
22-
gen_defVars <- gen.and_then(gen.int(20), gen_varnames)
23-
24-
gen_evalDef_call <-
25-
gen.and_then(gen_defVars, function(defVars) {
26-
generate(for (i in gen_dist) {
27-
list(
28-
newvar = defVars[1],
29-
newform = get(reg[name == i]$formula)(defVars[-1]),
30-
newdist = i,
31-
variance = get(reg[name == i]$variance)(defVars[-1]),
32-
link = get(reg[name == i]$link),
33-
defVars = defVars[-1]
34-
)
35-
})
36-
})
37-
38-
forall(gen_evalDef_call, function(args) expect_silent(do.call(.evalDef, args)))
39-
})
18+
# test_that("checks combine in .evalDef correctly", {
19+
# skip_on_cran()
20+
#
21+
# # this generates 20 previously defined varnames.
22+
# gen_defVars <- gen.and_then(gen.int(20), gen_varnames)
23+
#
24+
# gen_evalDef_call <-
25+
# gen.and_then(gen_defVars, function(defVars) {
26+
# generate(for (i in gen_dist) {
27+
# list(
28+
# newvar = defVars[1],
29+
# newform = get(reg[name == i]$formula)(defVars[-1]),
30+
# newdist = i,
31+
# variance = get(reg[name == i]$variance)(defVars[-1]),
32+
# link = get(reg[name == i]$link),
33+
# defVars = defVars[-1]
34+
# )
35+
# })
36+
# })
37+
#
38+
# forall(gen_evalDef_call, function(args) expect_silent(do.call(.evalDef, args)))
39+
# })
4040

4141
test_that(".evalDef throws errors correctly.", {
4242
skip_on_cran()
@@ -51,22 +51,22 @@ test_that(".evalDef throws errors correctly.", {
5151
})
5252

5353
# .isValidArithmeticFormula ----
54-
test_that("g.a.e. formula checked correctly.", {
55-
skip_on_cran()
56-
57-
gen_gae <-
58-
gen.and_then(gen_varnames(8), function(ns) {
59-
gen.map(function(y) {
60-
list(
61-
defVars = ns, formula = y
62-
)
63-
}, gen_formula(ns))
64-
})
65-
66-
forall(gen_gae, function(x) {
67-
expect_silent(.isValidArithmeticFormula(x$formula, x$defVars))
68-
})
69-
})
54+
# test_that("g.a.e. formula checked correctly.", {
55+
# skip_on_cran()
56+
#
57+
# gen_gae <-
58+
# gen.and_then(gen_varnames(8), function(ns) {
59+
# gen.map(function(y) {
60+
# list(
61+
# defVars = ns, formula = y
62+
# )
63+
# }, gen_formula(ns))
64+
# })
65+
#
66+
# forall(gen_gae, function(x) {
67+
# expect_silent(.isValidArithmeticFormula(x$formula, x$defVars))
68+
# })
69+
# })
7070

7171
test_that(".isValidArithmeticFormula throws errors correctly.", {
7272
skip_on_cran()
@@ -119,23 +119,23 @@ test_that(".checkCategorical throws errors.", {
119119
})
120120

121121
# .checkUniform ----
122-
test_that("'uniform' formula checked correctly", {
123-
skip_on_cran()
124-
125-
forall(
126-
gen.and_then(gen_varnames(10), function(names) {
127-
generate(for (x in list(
128-
min = gen_formula(names),
129-
max = gen_formula(names)
130-
)) {
131-
paste0(x$min, ";", x$max)
132-
})
133-
}),
134-
function(r) {
135-
expect_silent(.checkUniform(r))
136-
}
137-
)
138-
})
122+
# test_that("'uniform' formula checked correctly", {
123+
# skip_on_cran()
124+
#
125+
# forall(
126+
# gen.and_then(gen_varnames(10), function(names) {
127+
# generate(for (x in list(
128+
# min = gen_formula(names),
129+
# max = gen_formula(names)
130+
# )) {
131+
# paste0(x$min, ";", x$max)
132+
# })
133+
# }),
134+
# function(r) {
135+
# expect_silent(.checkUniform(r))
136+
# }
137+
# )
138+
# })
139139

140140
test_that(".checkUniform throws errors.", {
141141
skip_on_cran()

tests/testthat/test-utility.R

Lines changed: 73 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -125,79 +125,79 @@ test_that("survParamPlot works.", {
125125

126126
# logisticCoefs
127127

128-
test_that("logisticCoefs works.", {
129-
130-
skip_on_cran()
131-
132-
d1 <- defData(varname = "x1", formula = 0, variance = 1)
133-
d1 <- defData(d1, varname = "b1", formula = 0.5, dist = "binary")
134-
135-
coefs <- log(runif(2, min = .8, max = 1.2))
136-
137-
### Prevalence
138-
139-
d1a <- defData(d1, varname = "y",
140-
formula = "t(..B) %*% c(1, x1, b1)",
141-
dist = "binary", link = "logit"
142-
)
143-
144-
tPop <- round(runif(1, .2, .5), 2)
145-
B <- logisticCoefs(defCovar = d1, coefs = coefs, popPrev = tPop)
146-
147-
dd <- genData(100000, d1a)
148-
expect_equal(dd[, mean(y)], tPop, tolerance = .025)
149-
150-
#### Comparisons
151-
152-
d1a <- defData(d1, varname = "rx", formula = "1;1", dist = "trtAssign")
153-
d1a <- defData(d1a, varname = "y",
154-
formula = "t(..B) %*% c(1, rx, x1, b1)",
155-
dist = "binary", link = "logit"
156-
)
157-
158-
### Risk ratio
159-
160-
rr <- runif(1, .1, 1/tPop)
161-
B <- logisticCoefs(d1, coefs, popPrev = tPop, rr = rr, trtName = "rx")
162-
163-
dd <- genData(100000, d1a)
164-
expect_equal(dd[rx==0, mean(y)], tPop, tolerance = .025)
165-
expect_equal(dd[rx==1, mean(y)]/dd[rx==0, mean(y)], rr, tolerance = 0.025)
166-
167-
### risk difference
168-
169-
rd <- runif(1, -tPop, 1 - tPop)
170-
B <- logisticCoefs(d1, coefs, popPrev = tPop, rd = rd, trtName = "rx")
171-
172-
dd <- genData(100000, d1a)
173-
expect_equal(dd[rx==0, mean(y)], tPop, tolerance = .025)
174-
expect_equal(dd[rx==1, mean(y)] - dd[rx==0, mean(y)], rd, tolerance = 0.025)
175-
176-
### AUC
177-
178-
d1a <- defData(d1, varname = "y",
179-
formula = "t(..B) %*% c(1, x1, b1)",
180-
dist = "binary", link = "logit"
181-
)
182-
183-
auc <- runif(1, 0.6, 0.95)
184-
B <- logisticCoefs(d1, coefs, popPrev = tPop, auc = auc)
185-
186-
dx <- genData(500000, d1a)
187-
expect_equal(dx[, mean(y)], tPop, tolerance = .025)
188-
189-
form <- paste("y ~", paste(d1[, varname], collapse = " + "))
190-
191-
fit <- stats::glm(stats::as.formula(form), data = dx)
192-
dx[, py := stats::predict(fit)]
193-
194-
Y1 <- dx[y == 1, sample(py, 1000000, replace = TRUE)]
195-
Y0 <- dx[y == 0, sample(py, 1000000, replace = TRUE)]
196-
aStat <- mean(Y1 > Y0)
197-
198-
expect_equal(aStat, auc, tolerance = 0.025)
199-
200-
})
128+
# test_that("logisticCoefs works.", {
129+
#
130+
# skip_on_cran()
131+
#
132+
# d1 <- defData(varname = "x1", formula = 0, variance = 1)
133+
# d1 <- defData(d1, varname = "b1", formula = 0.5, dist = "binary")
134+
#
135+
# coefs <- log(runif(2, min = .8, max = 1.2))
136+
#
137+
# ### Prevalence
138+
#
139+
# d1a <- defData(d1, varname = "y",
140+
# formula = "t(..B) %*% c(1, x1, b1)",
141+
# dist = "binary", link = "logit"
142+
# )
143+
#
144+
# tPop <- round(runif(1, .2, .5), 2)
145+
# B <- logisticCoefs(defCovar = d1, coefs = coefs, popPrev = tPop)
146+
#
147+
# dd <- genData(100000, d1a)
148+
# expect_equal(dd[, mean(y)], tPop, tolerance = .025)
149+
#
150+
# #### Comparisons
151+
#
152+
# d1a <- defData(d1, varname = "rx", formula = "1;1", dist = "trtAssign")
153+
# d1a <- defData(d1a, varname = "y",
154+
# formula = "t(..B) %*% c(1, rx, x1, b1)",
155+
# dist = "binary", link = "logit"
156+
# )
157+
#
158+
# ### Risk ratio
159+
#
160+
# rr <- runif(1, .1, 1/tPop)
161+
# B <- logisticCoefs(d1, coefs, popPrev = tPop, rr = rr, trtName = "rx")
162+
#
163+
# dd <- genData(100000, d1a)
164+
# expect_equal(dd[rx==0, mean(y)], tPop, tolerance = .025)
165+
# expect_equal(dd[rx==1, mean(y)]/dd[rx==0, mean(y)], rr, tolerance = 0.025)
166+
#
167+
# ### risk difference
168+
#
169+
# rd <- runif(1, -tPop, 1 - tPop)
170+
# B <- logisticCoefs(d1, coefs, popPrev = tPop, rd = rd, trtName = "rx")
171+
#
172+
# dd <- genData(100000, d1a)
173+
# expect_equal(dd[rx==0, mean(y)], tPop, tolerance = .025)
174+
# expect_equal(dd[rx==1, mean(y)] - dd[rx==0, mean(y)], rd, tolerance = 0.025)
175+
#
176+
# ### AUC
177+
#
178+
# d1a <- defData(d1, varname = "y",
179+
# formula = "t(..B) %*% c(1, x1, b1)",
180+
# dist = "binary", link = "logit"
181+
# )
182+
#
183+
# auc <- runif(1, 0.6, 0.95)
184+
# B <- logisticCoefs(d1, coefs, popPrev = tPop, auc = auc)
185+
#
186+
# dx <- genData(500000, d1a)
187+
# expect_equal(dx[, mean(y)], tPop, tolerance = .025)
188+
#
189+
# form <- paste("y ~", paste(d1[, varname], collapse = " + "))
190+
#
191+
# fit <- stats::glm(stats::as.formula(form), data = dx)
192+
# dx[, py := stats::predict(fit)]
193+
#
194+
# Y1 <- dx[y == 1, sample(py, 1000000, replace = TRUE)]
195+
# Y0 <- dx[y == 0, sample(py, 1000000, replace = TRUE)]
196+
# aStat <- mean(Y1 > Y0)
197+
#
198+
# expect_equal(aStat, auc, tolerance = 0.025)
199+
#
200+
# })
201201

202202
test_that("logisticCoefs throws errors.", {
203203

0 commit comments

Comments
 (0)