node_rsurv | R Documentation |
Data from the parents is used to generate the node using either an accelerated failure time model, an accelerated hazard model, an extended hazard model, a proportional odds model or a Young and Prentice model, as implemented in the rsurv package (Demarqui 2024).
node_aftreg(data, parents, betas, baseline, dist=NULL,
package=NULL, u=stats::runif(nrow(data)),
cens_dist=NULL, cens_args, name, as_two_cols=TRUE,
...)
node_ahreg(data, parents, betas, baseline, dist=NULL,
package=NULL, u=stats::runif(nrow(data)),
cens_dist=NULL, cens_args, name, as_two_cols=TRUE,
...)
node_ehreg(data, parents, betas, phi, baseline, dist=NULL,
package=NULL, u=stats::runif(nrow(data)),
cens_dist=NULL, cens_args, name, as_two_cols=TRUE,
...)
node_poreg(data, parents, betas, baseline, dist=NULL,
package=NULL, u=stats::runif(nrow(data)),
cens_dist=NULL, cens_args, name, as_two_cols=TRUE,
...)
node_ypreg(data, parents, betas, phi, baseline, dist=NULL,
package=NULL, u=stats::runif(nrow(data)),
cens_dist=NULL, cens_args, name, as_two_cols=TRUE,
...)
data |
A |
parents |
A character vector specifying the names of the parents that this particular child node has. Converted into a formula and passed to the argument of the same name in |
betas |
A numeric vector with length equal to |
phi |
A numeric vector with length equal to |
baseline |
A single character string, specifying the name of the baseline survival distribution. Passed to the argument of the same name in |
dist |
An alternative way to specify the baseline survival distribution. Passed to the argument of the same name in |
package |
A single character string, specifying the name of the package where the assumed quantile function is implemented. Passed to the argument of the same name in |
u |
A numeric vector of quantiles of length |
cens_dist |
A single character naming the distribution function that should be used to generate the censoring times or a suitable function. For example, |
cens_args |
A list of named arguments which will be passed to the function specified by the |
name |
A single character string specifying the name of the node. |
as_two_cols |
Either |
... |
Further arguments passed to |
Survival times are generated according to the specified parametric survival model. The actual generation of the values is done entirely by calls to the rsurv package. All arguments are directly passed to the corresponding function in rsurv. Only the censoring is added on top of it. These convenience wrappers only exist to allow direct integration of these data generation functions with the interface provided by simDAG. Please consult the documentation and excellent paper by Demarqui (2024) for more information about the models and how to specify the arguments.
Returns a data.table
of length nrow(data)
containing two columns if as_two_cols=TRUE
and always when cens_dist
is specified. In this case, both columns start with the nodes name
and end with _event
and _time
. The first is a logical vector, the second a numeric one. If as_two_cols=FALSE
and cens_dist
is NULL
, a numeric vector is returned instead.
Robin Denz
Demarqui Fabio N. Simulation of Survival Data with the Package rsurv. (2024) arXiv:2406.01750v1.
library(simDAG)
set.seed(3454)
if (requireNamespace("rsurv")) {
library(rsurv)
# accelerated failure time model
dag <- empty_dag() +
node(c("A", "B", "C"), type="rnorm", mean=0, sd=1) +
node("Y", type="aftreg", formula= ~ -2 + A*0.2 + B*0.1 + A:B*1,
baseline="weibull", shape=1, scale=2)
data <- sim_from_dag(dag, n_sim=100)
# accelerated hazard model
dag <- empty_dag() +
node(c("A", "B", "C"), type="rnorm", mean=0, sd=1) +
node("Y", type="ahreg", formula= ~ -2 + A*0.2 + B*0.1,
baseline="weibull", shape=1, scale=2)
data <- sim_from_dag(dag, n_sim=100)
# extended hazard model
dag <- empty_dag() +
node(c("A", "B", "C"), type="rnorm", mean=0, sd=1) +
node("Y", type="ehreg", formula= ~ -2 + A*0.2 + B*0.1,
baseline="weibull", shape=1, scale=2,
phi=c(-1, 1))
data <- sim_from_dag(dag, n_sim=100)
# proportional odds model
dag <- empty_dag() +
node(c("A", "B", "C"), type="rnorm", mean=0, sd=1) +
node("Y", type="poreg", formula= ~ -2 + A*0.2 + B*0.1,
baseline="weibull", shape=1, scale=2)
data <- sim_from_dag(dag, n_sim=100)
# Young and Prentice model
dag <- empty_dag() +
node(c("A", "B", "C"), type="rnorm", mean=0, sd=1) +
node("Y", type="ypreg", formula= ~ -2 + A*0.2 + B*0.1,
baseline="weibull", shape=1, scale=2,
phi=c(-1, 1))
data <- sim_from_dag(dag, n_sim=100)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.