Simulating Complex Crossectional and Longitudinal Data using the \pkg simDAG \proglang R Package
Robin Denz Ruhr-University of Bochum, Nina Timmesfeld Ruhr-University of Bochum · 2025
Read Simulating Complex Crossectional and Longitudinal Data using the \pkg simDAG \proglang R Package by Robin Denz Ruhr-University of Bochum, Nina Timmesfeld Ruhr-University of Bochum (2025) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2506-01498.txt.
Introduction
Robin Denz and Nina Timmesfeld present simDAG, an R package for fabricating realistic fake data on demand. Simulation studies — the dress rehearsals of statistics — need fake datasets with exactly specified tangles of causes. Hand-building a generator with time-varying, interacting, mixed-type variables eats weeks. Their 2025 package takes a directed acyclic graph of structural equations as the single source of truth.
Any variable can be produced by a custom function or a regression model, covering binary, categorical, count, and time-to-event outcomes. A discrete-time engine extends the same graph across time, generating records with repeated or competing events. The syntax leans on familiar formula notation. Statisticians get a factory for the one dataset no ethics board must approve.
Catalog record
| CREATOR | Robin Denz Ruhr-University of Bochum, Nina Timmesfeld Ruhr-University of Bochum |
|---|---|
| YEAR | 2025 |
| COLLECTION | PAPERS |
| FORMAT | TXT |
| FILE SIZE | 87 KB |
| VERSION | 1.0 |
| LICENSE | http://creativecommons.org/licenses/by/4.0/ |
| RIGHTS | CC BY |
| SOURCE | arXiv |
Source: https://arxiv.org/abs/2506-01498
Browse the full library · About the Tower of Babel
Full text
The opening of the work, from the library's hosted text:
Simulating Complex Crossectional and Longitudinal Data using the \pkg simDAG \proglang R Package Robin Denz Ruhr-University of Bochum, Nina Timmesfeld Ruhr-University of Bochum Abstract \Plainauthor Robin Denz, Nina Timmesfeld \Plaintitle Simulating Complex Crossectional and Longitudinal Data using the simDAG R Package \Shorttitle The \pkg simDAG \proglang R Package \Abstract Generating artificial data is a crucial step when performing Monte-Carlo simulation studies. Depending on the planned study, complex data generation processes (DGP) containing multiple, possibly time-varying, variables with various forms of dependencies and data types may be required. Simulating data from such DGP may therefore become a difficult and time-consuming endeavor. The \pkg simDAG \proglang R package offers a standardized approach to generate data from simple and complex DGP based on the definition of structural equations in directed acyclic graphs using arbitrary functions or regression models. The package offers a clear syntax with an enhanced formula interface and directly supports generating binary, categorical, count and time-to-event data with arbitrary dependencies, possibly non-linear relationships and interactions. It additionally includes a framework to conduct discrete-time based simulations which allows the generation of longitudinal data on a semi-continuous time-scale. This approach may be used to generate time-to-event data with both recurrent or competing events and possibly multiple time-varying covariates, which may themselves have arbitrary data types. In this article we demonstrate the vast amount of features included in \pkg simDAG by replicating the DGP of multiple real Monte-Carlo simulation studies. \Keywords simulation, time-to-event, structural equation, directed acyclic graph, longitudinal data, discrete-time, \proglang R \Plainkeywords simulation, time-to-event, structural equation, directed acyclic graph, longitudinal data, discrete-time, R \Address Robin Denz, Nina Timmesfeld Department of Medical Informatics, Biometry and Epidemiology Ruhr-University of Bochum Universitätsstr. 105 D-44789 Bochum, Germany E-mail: URL: http://www.amib.ruhr-uni-bochum.de/index.php 1 Introduction 1.1 Motivation Applied researchers and statisticians frequently use Monte-Carlo simulation techniques in a variety of ways. They are used to estimate required sample sizes ( Arnold et al. 2011 ) , formally compare different statistical methods ( Morris et al. 2019 ; Denz et al. 2023a ) , help design and plan clinical trials ( Kimko and Duffull 2002 ; Nance et al. 2024 ) or for teaching purposes ( Sigal and Chalmers 2016 ; Fox et al. 2022 ) . The main reason for their broad usage is that the researcher has full control over the true data generation process (DGP). In general, the researcher will define a DGP appropriate to the situation and generate multiple datasets from it. Some statistical analysis technique is then applied to each dataset and the results are analyzed. A crucial step in every kind of Monte-Carlo simulation study is thus the generation of these datasets. Depending on the DGP that is required by the researcher, this step may become very difficult and time consuming. For example, some Monte-Carlo simulations require the generation of complex longitudinal data with variables of different types that are causally related in various ways ( Asparouhov and Muthén 2020 ) . Some of these possible data types are continuous variables, categorical variables, count variables or time-to-event variables. All of these require different parametrizations and simulation strategies. If interactions or non-linear relationships between these variables are required, simulating data from the DGP becomes even more challenging. Generating any artificial data requires (1) a formal description of the DGP, (2) the knowledge of an algorithm that may be used to generate the data from this DGP, and (3) the ability to create a software application to implement that algorithm. Although many statisticians may have no problem with theses steps, this might not be the case for more applied researchers. More importantly, the third step in particular may require a high level of expertise in programming, because the resulting program has to be validated extensively while it also has to be computationally efficient enough to allow potentially thousands of datasets to be generated in a reasonable amount of time. Additionally, it also has to be flexible enough to allow the user to easily make changes to the DGP to be useful in most cases ( Sofrygin et al. 2017 ) . A comprehensive software application that automates most of the required work would therefore be of great benefit to the scientific community. In this article we present the \pkg simDAG \proglang R package, which offers an easy to use and consistent framework to generate arbitrarily complex crossectional and longitudinal data. The aim of the package is to make all three steps of the data generation process easier by giving users a standardized way to define the desired DGP, which can then be used directly to generate the data without further user input. It does so by requiring the user to define a directed acyclic graph (DAG) with additional information about the associations between the supplied variables ( Pearl 2009 ) . The package was created using the \proglang R programming language ( \proglangR Core Team 2024 ) and is available on the Comprehensive \proglang R Archive Network (CRAN) at https://cran.r-project.org/package=simDAG . 1.2 Using DAGs to define data generation processes In this package, the user is required to describe the desired DGP as a causal DAG. Formally, a DAG is a mathematical graph consisting of a set of V nodes (or vertices) and a set of E edges (or links) connecting pairs of nodes. As its’ name suggests, a DAG consists only of directed edges and is acyclic , meaning that there are no cycles when following directed paths on the DAG ( Byeon and Lee 2023 ) . A causal DAG is a special sort of DAG in which the nodes represent random variables and the edges represent directed causal relationships between these variables ( Pearl 2009 ) . A very simple example containing only three nodes and no time-dependencies is given in Figure 1 . The DAG in this figure contains a directed arrow from A to C and from B to C . This translates to the assumptions that there is a direct causal effect of A on C and of B on C , but no direct causal relationship between A and B (due to the absence of an arrow between them). Figure 1: An example DAG with three nodes. Such DAGs are the cornerstone of the structural approach to causal inference developed by Pearl 2009 and Spirtes et al. 2000 . They are used extensively in social research ( Wouk et al. 2019 ) , econonomics ( Imbens 2020 ) and epidemiology ( Byeon and Lee 2023 ) to encode causal assumptions about the real underlying DGP of empirical data. For empirical research such graphs are very useful because they give a clear overview of the causal assumptions made by the researchers. By using causal graphical methods such as the backdoor criterion ( Pearl 2009 ) or the frontdoor criterion ( Pearl 1995 ) , it is also possible to use such graphs to determine which variables need to be adjusted for in order to get unbiased estimates of certain causal effects. The \pkg daggitty \proglang R package directly implements multiple tools for this kind of usage ( Textor et al. 2016 ) . These kind of DAGs can be formally described using structural equations . These equations describe how each node