Skip to content

Commit 6f31b2e

Browse files
committed
feat: prepare for CRAN release
1 parent ae3d945 commit 6f31b2e

File tree

9 files changed

+119
-12
lines changed

9 files changed

+119
-12
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: simDAG
22
Title: Simulate Data from a DAG and Associated Node Information
3-
Version: 0.2.2.9000
3+
Version: 0.3.0
44
Authors@R: c(
55
person("Robin", "Denz", , "robin.denz@rub.de", role = c("aut", "cre")),
66
person("Katharina", "Meiszl", , "meiszl@amib.rub-uni-bochum.de", role = c("aut"))

NEWS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ Enhancements
114114
* Added the `reference` argument to `rbernoulli()` and `rcategorical()` to make it easier to specify the reference category when coding the output as a factor variable.
115115
* `+.DAG` now checks whether the `DAG` would become cyclic when adding a `node()` and returns an error if it does.
116116
* Added the `include_td_nodes` and `include_root_nodes` arguments to `as.igraph.DAG()`.
117-
* Changed the default of `n_cores` in the `sim_n_datasets()` function to 1 from `parallel::detectCores()-1`
117+
* Changed the default of `n_cores` in the `sim_n_datasets()` function to 1 from `parallel::detectCores()`
118118
* Function input to the `cens_dist` argument in the `node_cox()` function is now allowed.
119119
* The argument `as_two_cols` was added to the `node_cox()` function to allow users to return only the time-to-event as a single column if no censoring is applied.
120120

codemeta.json

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"codeRepository": "https://github.com/RobinDenz1/simDAG",
99
"issueTracker": "https://github.com/RobinDenz1/siMDAG/issues",
1010
"license": "https://spdx.org/licenses/GPL-3.0",
11-
"version": "0.2.2",
11+
"version": "0.2.2.9000",
1212
"programmingLanguage": {
1313
"@type": "ComputerLanguage",
1414
"name": "R",
@@ -175,6 +175,35 @@
175175
"@type": "SoftwareApplication",
176176
"identifier": "parallel",
177177
"name": "parallel"
178+
},
179+
{
180+
"@type": "SoftwareApplication",
181+
"identifier": "utils",
182+
"name": "utils"
183+
},
184+
{
185+
"@type": "SoftwareApplication",
186+
"identifier": "simr",
187+
"name": "simr",
188+
"provider": {
189+
"@id": "https://cran.r-project.org",
190+
"@type": "Organization",
191+
"name": "Comprehensive R Archive Network (CRAN)",
192+
"url": "https://cran.r-project.org"
193+
},
194+
"sameAs": "https://CRAN.R-project.org/package=simr"
195+
},
196+
{
197+
"@type": "SoftwareApplication",
198+
"identifier": "rsurv",
199+
"name": "rsurv",
200+
"provider": {
201+
"@id": "https://cran.r-project.org",
202+
"@type": "Organization",
203+
"name": "Comprehensive R Archive Network (CRAN)",
204+
"url": "https://cran.r-project.org"
205+
},
206+
"sameAs": "https://CRAN.R-project.org/package=rsurv"
178207
}
179208
],
180209
"softwareRequirements": {
@@ -229,7 +258,7 @@
229258
},
230259
"SystemRequirements": null
231260
},
232-
"fileSize": "1261.119KB",
261+
"fileSize": "1401.968KB",
233262
"citation": [
234263
{
235264
"@type": "CreativeWork",
@@ -252,7 +281,7 @@
252281
],
253282
"releaseNotes": "https://github.com/RobinDenz1/simDAG/blob/master/NEWS.md",
254283
"readme": "https://github.com/RobinDenz1/simDAG/blob/main/README.md",
255-
"contIntegration": ["https://github.com/RobinDenz1/simDAG/actions/workflows/R-CMD-check.yaml", "https://app.codecov.io/gh/RobinDenz1/simDAG?branch=main"],
284+
"contIntegration": ["https://github.com/RobinDenz1/simDAG/actions/workflows/R-CMD-check.yaml", "https://app.codecov.io/gh/RobinDenz1/simDAG"],
256285
"developmentStatus": "https://www.repostatus.org/#active",
257286
"keywords": ["causal-inference", "directed-acyclic-graph", "simulation"]
258287
}

man/node_cox.Rd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Bender R, Augustin T, Blettner M. Generating survival times to simulate Cox prop
6060
Robin Denz
6161
}
6262
\value{
63-
Returns a \code{data.table} of length \code{nrow(data)} containing two columns if \code{as_two_cols=TRUE} and always when \code{cens_dist} is specified. In this case, both colums start with the nodes \code{name} and end with \code{_event} and \code{_time}. The first is a logical vector, the second a numeric one. If \code{as_two_cols=FALSE} and \code{cens_dist} is \code{NULL}, a numeric vector is returned instead.
63+
Returns a \code{data.table} of length \code{nrow(data)} containing two columns if \code{as_two_cols=TRUE} and always when \code{cens_dist} is specified. In this case, both columns start with the nodes \code{name} and end with \code{_event} and \code{_time}. The first is a logical vector, the second a numeric one. If \code{as_two_cols=FALSE} and \code{cens_dist} is \code{NULL}, a numeric vector is returned instead.
6464
}
6565
\examples{
6666
library(simDAG)

man/node_mixture.Rd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Robin Denz
3333
\details{
3434
Internally, the data is generated by extracting only the relevant part of the already generated \code{data} as defined by the condition and using \code{\link{node}} function to generate the new response-part. This generation is done in the order in which the \code{distr} was specified, meaning that data for the first condition is checked first and so on. There are no safeguards to guarantee that the conditions do not overlap. For example, users are free to set the first condition to something like \code{A > 10} and the next one to \code{A > 11}, in which case the value for every individual with \code{A > 11} is generated twice (first with the first specification, secondly with the next specification). In this case, only the last generated value is retained.
3535

36-
Note that it is also possible to use the mixture node itself inside the conditions or \code{\link{node}} calls in \code{distr}, because it is directly added to the \code{data} before the first condition is applied (by setting everyong to the \code{default} value). See examples.
36+
Note that it is also possible to use the mixture node itself inside the conditions or \code{\link{node}} calls in \code{distr}, because it is directly added to the \code{data} before the first condition is applied (by setting everyone to the \code{default} value). See examples.
3737

3838
Additionally, because the output of each of the parts of the mixture distributions is forced into one vector, they might be coerced from one class to another, depending on the input to \code{distr} and the order used. This also needs to be taken care of by the user.
3939
}

man/node_rsurv.Rd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ Demarqui Fabio N. Simulation of Survival Data with the Package rsurv. (2024) arX
8989
Robin Denz
9090
}
9191
\value{
92-
Returns a \code{data.table} of length \code{nrow(data)} containing two columns if \code{as_two_cols=TRUE} and always when \code{cens_dist} is specified. In this case, both colums start with the nodes \code{name} and end with \code{_event} and \code{_time}. The first is a logical vector, the second a numeric one. If \code{as_two_cols=FALSE} and \code{cens_dist} is \code{NULL}, a numeric vector is returned instead.
92+
Returns a \code{data.table} of length \code{nrow(data)} containing two columns if \code{as_two_cols=TRUE} and always when \code{cens_dist} is specified. In this case, both columns start with the nodes \code{name} and end with \code{_event} and \code{_time}. The first is a logical vector, the second a numeric one. If \code{as_two_cols=FALSE} and \code{cens_dist} is \code{NULL}, a numeric vector is returned instead.
9393
}
9494
\examples{
9595
library(simDAG)

tests/testthat/test_node_custom.r

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,15 @@ test_that("multiple columns in custom root", {
1616
expect_true(nrow(data)==100)
1717
expect_equal(colnames(data), c("A", "B", "C"))
1818
})
19+
20+
test_that("node needs intercept", {
21+
22+
test_fun <- function(data, intercept) {
23+
return(data)
24+
}
25+
26+
assign("test_fun", test_fun, envir=.GlobalEnv)
27+
28+
expect_true(node_needs_intercept(test_fun))
29+
expect_true(node_needs_intercept("test_fun"))
30+
})

tests/testthat/test_node_mixture.r

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,24 @@ test_that("conditions not covering all scenarios, using default", {
105105
expect_equal(round(mean(data$Y[data$A==0]), 3), -2.711)
106106
})
107107

108+
test_that("calling the function directly", {
109+
110+
set.seed(1535434)
111+
112+
dag <- empty_dag() +
113+
node("A", type="rbernoulli") +
114+
node("B", type="rnorm")
115+
data <- as.data.frame(sim_from_dag(dag, n_sim=100))
116+
117+
out <- node_mixture("Y", data=data, parents="A",
118+
distr=list(
119+
"A==0", node(".", type="gaussian", formula= ~ -2 + B*2, error=1)
120+
), default=10)
121+
122+
expect_true(all(out[data$A==1]==10))
123+
expect_equal(round(mean(out[data$A==0]), 3), -2.711)
124+
})
125+
108126
test_that("nothing in distr defined", {
109127
expect_error({
110128
dag <- empty_dag() +

tests/testthat/test_str_eq_rsurv.r

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,72 @@
11

22
test_that("general test case", {
33

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,
55
baseline="weibull", shape=1, scale=2)
66

77
out1 <- str_eq_rsurv(node, "aftreg")
88
out2 <- str_eq_aftreg(node)
99

1010
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')",
1212
"Bla[C] ~ Inf"))
1313
})
1414

1515
test_that("with censoring", {
1616

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,
1818
baseline="weibull", shape=1, scale=2,
1919
cens_dist="runif", cens_args=list(min=0, max=10))
2020

2121
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')",
2323
"Bla2[C] ~ runif(min=0, max=10)"))
2424
})
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

Comments
 (0)