|
1 | 1 |
|
2 | 2 | test_that("general test case", { |
3 | 3 |
|
4 | | - node <- node("Bla", type="aftreg", formula= ~ -2 + A*0.1 + B*3, |
| 4 | + node <- node("Bla", type="aftreg", formula= ~ A*0.1 + B*3, |
5 | 5 | baseline="weibull", shape=1, scale=2) |
6 | 6 |
|
7 | 7 | out1 <- str_eq_rsurv(node, "aftreg") |
8 | 8 | out2 <- str_eq_aftreg(node) |
9 | 9 |
|
10 | 10 | expect_equal(out1, out2) |
11 | | - expect_equal(out1, c("Bla[T] ~ aftreg(-2 + A*0.1 + B*3, dist='weibull')", |
| 11 | + expect_equal(out1, c("Bla[T] ~ aftreg(A*0.1 + B*3, dist='weibull')", |
12 | 12 | "Bla[C] ~ Inf")) |
13 | 13 | }) |
14 | 14 |
|
15 | 15 | test_that("with censoring", { |
16 | 16 |
|
17 | | - node <- node("Bla2", type="ahreg", formula= ~ -2 + A*0.1 + B*3, |
| 17 | + node <- node("Bla2", type="ahreg", formula= ~ A*0.1 + B*3, |
18 | 18 | baseline="weibull", shape=1, scale=2, |
19 | 19 | cens_dist="runif", cens_args=list(min=0, max=10)) |
20 | 20 |
|
21 | 21 | out <- str_eq_rsurv(node, "aftreg") |
22 | | - expect_equal(out, c("Bla2[T] ~ aftreg(-2 + A*0.1 + B*3, dist='weibull')", |
| 22 | + expect_equal(out, c("Bla2[T] ~ aftreg(A*0.1 + B*3, dist='weibull')", |
23 | 23 | "Bla2[C] ~ runif(min=0, max=10)")) |
24 | 24 | }) |
| 25 | + |
| 26 | +test_that("with parents / betas specified", { |
| 27 | + node <- node("Bla", type="aftreg", |
| 28 | + parents=c("A", "B"), |
| 29 | + betas=c(0.1, 3), |
| 30 | + dist="weibull", shape=1, scale=2) |
| 31 | + out <- structural_equation(node) |
| 32 | + expect_equal(out, c("Bla[T] ~ aftreg(0.1*A + 3*B, dist='weibull')", |
| 33 | + "Bla[C] ~ Inf")) |
| 34 | +}) |
| 35 | + |
| 36 | +test_that("correct output with structural_equation()", { |
| 37 | + |
| 38 | + # aftreg |
| 39 | + node <- node("Bla", type="aftreg", formula= ~ A*0.1 + B*3, |
| 40 | + baseline="weibull", shape=1, scale=2) |
| 41 | + out <- structural_equation(node) |
| 42 | + expect_equal(out, c("Bla[T] ~ aftreg(A*0.1 + B*3, dist='weibull')", |
| 43 | + "Bla[C] ~ Inf")) |
| 44 | + |
| 45 | + # ahreg |
| 46 | + node <- node("Bla", type="ahreg", formula= ~ A*0.1 + B*3, |
| 47 | + baseline="weibull", shape=1, scale=2) |
| 48 | + out <- structural_equation(node) |
| 49 | + expect_equal(out, c("Bla[T] ~ ahreg(A*0.1 + B*3, dist='weibull')", |
| 50 | + "Bla[C] ~ Inf")) |
| 51 | + |
| 52 | + # ehreg |
| 53 | + node <- node("Bla", type="ehreg", formula= ~ A*0.1 + B*3, |
| 54 | + baseline="weibull", shape=1, scale=2) |
| 55 | + out <- structural_equation(node) |
| 56 | + expect_equal(out, c("Bla[T] ~ ehreg(A*0.1 + B*3, dist='weibull')", |
| 57 | + "Bla[C] ~ Inf")) |
| 58 | + |
| 59 | + # poreg |
| 60 | + node <- node("Bla", type="poreg", formula= ~ A*0.1 + B*3, |
| 61 | + baseline="weibull", shape=1, scale=2) |
| 62 | + out <- structural_equation(node) |
| 63 | + expect_equal(out, c("Bla[T] ~ poreg(A*0.1 + B*3, dist='weibull')", |
| 64 | + "Bla[C] ~ Inf")) |
| 65 | + |
| 66 | + # ypreg |
| 67 | + node <- node("Bla", type="ypreg", formula= ~ A*0.1 + B*3, |
| 68 | + baseline="weibull", shape=1, scale=2) |
| 69 | + out <- structural_equation(node) |
| 70 | + expect_equal(out, c("Bla[T] ~ ypreg(A*0.1 + B*3, dist='weibull')", |
| 71 | + "Bla[C] ~ Inf")) |
| 72 | +}) |
0 commit comments