
We describe the cv package, which implements cross-validation for standard R regression models through a uniform and simple to use generic function. Methods for the cv() function are provided for many commonly employed classes of statistical models, including mixed-effects models, and it is straightforward to extend the cv package by writing methods for additional classes of models. The cv() function can also cross-validate complex model-selection procedures, such as those that include variable transformations, predictor selection, and selection among competing models. The cv() function generally supports parallel computations, and the supplied methods for linear and generalized linear models take advantage of computational efficiencies.
Generating artificial data is a crucial step when performing Monte Carlo simulation studies. Depending on the planned study, complex data generation processes (DGPs) containing multiple, possibly time-varying, variables with various forms of dependencies and data types may be required. Simulating data from such DGPs may therefore become a difficult and time-consuming endeavor. The simDAG R package offers a standardized approach to generate data from simple and complex DGPs 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 simDAG by replicating the DGPs of multiple real Monte Carlo simulation studies.
Multimo dal univariate distributions arise in many fields such as astrophysics, bioinformatics, climatology and economics due to the heterogeneity of the underlying populations. Mixture processes are a popular tool for accurate approximation of such distributions and implied mode detection. Using Bayesian univariate mixture models and methods, Bayes-MultiMo de estimates posterior probabilities of the number of modes, their locations and uncertainty, yielding a powerful tool for mode inference. The approach follows Cross, Hoogerheide, Labonne, and Van Dijk (2024) and works in two stages. First, a flexible mixture with an unknown number of components is estimated using a Bayesian Markov chain Monte Carlo (MCMC) method due to Malsiner-Walli, Fr & uuml;hwirth-Schnatter, and Gr & uuml;n (2016). Second, suitable detection algorithms are employed to estimate modes for continuous and discrete probability distributions. Given these mode estimates, posterior probabilities for the number of modes, their locations and uncertainties are constructed. BayesMultiMo de supports a range of mixture processes, complementing and extending existing software for mixture modeling. The mode detection algorithms implemented in BayesMultiMo de also support MCMC draws for mixture estimation generated with external software. The package uses for illustrative purposes both continuous and discrete empirical distributions from the four listed fields yielding reliable multiple mode detection with substantial posterior probability where frequentist tests fail to reject the null hypothesis of unimodality.
collapse is a large C/C++-based infrastructure package facilitating complex statistical computing, data transformation, and exploration tasks in R-at outstanding levels of performance and memory efficiency. It also implements a class-agnostic approach to R programming, supporting vector, matrix and data frame-like objects and their popular extensions ('units', 'integer64', 'xts', 'tibble', 'data.table', 'sf', 'pdata.frame'), enabling its seamless integration with the bulk of the R ecosystem. This article introduces the package's key components and design principles in a structured way, supported by a rich set of examples. A small benchmark demonstrates its computational performance.
The R package polle is a unifying framework for learning and evaluating finite stage policies based on observational data. The package implements a collection of existing and novel methods for causal policy learning including doubly robust restricted Q-learning, policy tree learning, and outcome weighted learning. The package deals with (near) positivity violations by only considering realistic policies. Highly flexible machine learning methods can be used to estimate the nuisance components and valid inference for the policy value is ensured via cross-fitting. The library is built up around a simple syntax with four main functions policy_data(), policy_def(), policy_learn(), and policy_eval() used to specify the data structure, define user-specified policies, specify policy learning methods and evaluate (learned) policies. The functionality of the package is illustrated via extensive reproducible examples.
In the realm of unsupervised learning, Bayesian nonparametric mixture models, exemplified by the Dirichlet Process Mixture Model (DPMM), provide a principled approach for adapting the complexity of the model to the data. Such models are particularly useful in clustering tasks where the number of clusters is unknown. Despite their potential and mathematical elegance, however, DPMMs have yet to become a mainstream tool widely adopted by practitioners. This is arguably due to a misconception that these models scale poorly as well as the lack of high-performance (and user-friendly) software tools that can handle large datasets efficiently. In this paper we bridge this practical gap by proposing a new, easy-to-use, statistical software package for scalable DPMM inference. More concretely, we provide efficient and easily-modifiable implementations for high-performance distributed sampling-based inference in DPMMs where the user is free to choose between either a multiple-machine, multiple-core, CPU implementation (written in Julia) and a multiple-stream GPU implementation (written in CUDA/C++). Both the CPU and GPU implementations come with a common (and optional) python wrapper, providing the user with a single point of entry with the same interface. On the algorithmic side, our implementations leverage a leading DPMM sampler from (Chang and Fisher III, 2013). While Chang and Fisher III's implementation (written in MATLAB/C++) used only CPU and was designed for a single multi-core machine, the packages we proposed here distribute the computations efficiently across either multiple multi-core machines or across mutiple GPU streams. This leads to speedups, alleviates memory and storage limitations, and lets us fit DPMMs to significantly larger datasets and of higher dimensionality than was possible previously by either (Chang and Fisher III, 2013) or other DPMM methods.
The nonlinear mixed model is a popular tool for analyzing continuous longitudinal data. This paper is primarily concerned with gauging the sensitivity of nonlinear mixed models to influential observations through local influence, which assesses the impact of small perturbations of the likelihood function. Unlike when case deletion is used, in local influence the model only needs to be fitted once, making it much more computationally appealing. The methodology is illustrated with two datasets, establishing that the local influence diagnostic can easily be applied to nonlinear mixed models through the NLMIXED procedure in the SAS software as a tool to identify influential individuals.
Longitudinal data are commonly analyzed using linear mixed models, which, for mathematical convenience, usually assume that both random effect and error follow normal distributions. However, these restrictive assumptions may result in a lack of robustness against departures from the normal distribution and invalid statistical inferences. Schumacher, Lachos, and Matos (2021) developed a flexible extension of linear mixed models considering the scale mixture of skew-normal class of distributions from a frequentist point of view, accommodating skewness and heavy tails, and the robust model formulation accounts for a possible within-subject serial dependence by considering some useful the method proposed by Schumacher et al. (2021) and provides a user-friendly tool to fit robust linear mixed models to longitudinal data, including model-fit tests, residual analyzes, and plot functions to support model selection and evaluation. Two data sets and a synthetic example are analyzed to illustrate the methodology and software implementation.
Item response theory (IRT) provides a framework for modeling the responses given to a test or questionnaire, which are assumed to depend on an underlying latent variable and on some item parameters. Due to identifiability issues, when the parameters are estimated separately on different datasets, the estimates of the item parameters and the predicted values of the latent variable are not directly comparable. Equating is a statistical procedure that can be used to convert these values to a common metric and to obtain comparable test scores. The R package equateMultiple implements methods to link the parameters estimated on many different datasets. After briefly reviewing the IRT models and the equating methods, this article illustrates the use of the package.
In this paper we present and showcase the R package watson which provides a computational framework for fitting and random sampling of the Watson distribution on a p-dimensional sphere. We first introduce the random sampling scheme of the package, which offers two sampling algorithms that are based of the results of Sablica, Hornik, and Leydold (2025). What is more, the package offers a smart tool to combine these two methods, and based on the selected parameters, it approximates the relative sampling speed for both methods and picks the faster one. In addition, we describe the main fitting function for the mixtures of Watson distribution which uses the expectation-maximization (EM) algorithm. Special features are the possibility to use multiple variants of the E-step and M-step, sparse matrices for the data representation and a control parameter which will dynamically eliminate small clusters with overall contribution smaller than this parameter. Moreover, we discuss the numerical issues of the whole fitting procedure and describe how this is handled and solved in the package. Finally, we demonstrate the package on multiple examples involving misspecified simulation study, estimation of the New Zealand earthquake data and depth image clustering.
Dynamic Bayesian networks are a type of multivariate time series forecasting model capable of a level of interpretability thanks to their graphical representation. They have been reported extensively in the literature in a variety of areas, but their application usually involved an ad hoc implementation or adaptation of existing Bayesian network software to a dynamic case. In this paper, we present dbnR, an R package that encapsulates the whole process of learning the model and parameters from data and performing inference. The package provides three different structure learning algorithms, exact approximate inference and a visualization tool that allows inspection of the graphical structure of the networks. The aim of dbnR is to provide a tool that enables fast deployment of dynamic Bayesian network models and to make them readily available as general purpose forecasting models.
The R package MixtureMissing performs model-based clustering on data sets with values missing at random, aiming to identify homogeneous groups of observations. In model-based clustering, the data within each cluster follow a specific distribution. In the package, 13 distributions are available, including the contaminated normal distribution, the generalized hyperbolic distribution (GHD), and 11 special or limiting cases of GHD. Notably, eight out of these 11 cases have not been formulated at the time of writing. Given a list of candidate distributions, the package can recommend the optimal distribution to employ based on a specified information criterion. In this paper, the methodological foundations and computational aspects of the package are discussed. Furthermore, important features of model fitting, model summary, and available visualization tools are thoroughly illustrated using real data sets.
Describing the relationship between the variables in a study domain and modeling the data generating mechanism is a fundamental problem in many empirical sciences. Probabilistic graphical models are one common approach to tackle the problem. Learning the graphical structure for such models is computationally challenging and a fervent area of current research with a plethora of algorithms being developed. To facilitate the benchmarking of different methods, we present a novel Snakemake workflow, called Benchpress for producing scalable, reproducible, and platform-independent benchmarks of structure learning algorithms for probabilistic graphical models. Benchpress is interfaced via a simple JSON-file, which makes it accessible for all users, while the code is designed in a fully modular fashion to enable researchers to contribute additional methodologies. Benchpress currently provides an interface to a large number of state-of-the-art algorithms from libraries such as BDgraph, BiDAG, bnlearn, causal-learn, gCastle, GOB-NILP, pcalg, scikit-learn, TETRAD, and trilearn as well as a variety of methods for data generating models and performance evaluation. Alongside user-defined models and randomly generated datasets, the workflow also includes a number of standard datasets and graphical models from the literature, which may be included in a benchmarking study. We demonstrate the applicability of this workflow for learning Bayesian networks in five typical data scenarios. The source code and documentation is publicly available from https://benchpressdocs.readthedocs.io/.
In statistical modeling, there is a wide variety of generalized linear models for categorical response variables (nominal or ordinal responses); yet, there is no software embracing all these models together in a unique and generic framework. We propose and present GLMcat, an R package to estimate generalized linear models implemented under the unified specification (r, F, Z) where r represents the ratio of probabilities (reference, cumulative, adjacent, or sequential), F the cumulative distribution function for the linkage, and Z the design matrix. All classical models (and their variations) for categorical data can be written as an (r, F, Z) triplet, thus, they can be fitted with GLMcat. The functions in the package are intuitive and user-friendly. For each of the three components, there are multiple alternatives from which the user should thoroughly select those that best address the objectives of the analysis. The main strengths of the GLMcat package are the possibility of choosing from a large number of link functions (defined by the composition of F and r) and the simplicity for setting constraints in the linear prediction, either on the intercepts or on the slopes. This paper proposes a methodological and practical guide for the appropriate selection of a model considering the concordance between the nature of the data and the properties of the model.
Regression models that accommodate correlated observations and potential nonlinearpredictor-outcome relationships are fundamental in analyzing experimental and obser-vational data. Unlike traditional parametric approaches, transformation models makeweaker assumptions on the conditional response distribution, thus allowing for a moreuniversal applicability to at least ordered univariate outcomes. This flexibility makestransformation models an attractive choice for modeling complex relationships in a widerange of domains. TheRpackagetramMEextends the transformation model frameworkwith general random effect structures and penalized smooth terms to adapt to dependentdata and nonlinear predictor-outcome relationships. This paper presents the statisticalframework and implementation details oftramME, including its integration with otherpopularRpackages for transformation modeling (mlt), mixed-effects (lme4) and additivemodels (mgcv). The package employs the efficient Template Model Builder framework(TMB) for fully parametric likelihood-based estimation and inference. Two illustrationsdemonstrate thattramMEcan readily model complex, dependent data structures undersettings where the choice of the outcome distribution type is challenging
This article introduces the spxtivdfreg package in Stata, which implements a general instrumental variables (IV) approach for estimating dynamic spatial panel data models with unobserved common factors or interactive effects, when the number of both crosssectional and time series observations is large. The estimator has been developed in a recent paper by Cui, Sarafidis, and Yamagata (2023). The underlying idea is to project out the common factors from exogenous covariates using principal components analysis, and to run IV regression in both of two stages, using defactored covariates (and their spatial counterparts) as instruments. The resulting two-stage IV estimator is valid for models with homogeneous slope coefficients, and has several advantages relative to existing popular approaches. In addition, the spxtivdfreg package allows estimation of short-run and long-run direct and indirect effects, as well as total effects, accounting for the cumulative effects over time and across space. Standard errors for such effects are computed using the Delta method. Last, the spxtivdfreg package allows for heterogeneous slope coefficients, as in Chen, Cui, Sarafidis, and Yamagata (2025). In particular, we construct a "mean group" IV estimator, which involves averaging first-step IV estimates of individual-specific slope coefficients.
Statistical process monitoring (SPM) control charts are widely used for monitoring the stability of sequential processes. Currently, there is no open-source software which provides a general and extensible implementation of control charts. StatisticalProcess-Monitoring.jl is a novel Julia package which aims at addressing this gap, offering support for monitoring various type of data, such as univariate and multivariate observations, partially-observed data streams, and profiles. The package introduces an extensible SPM framework, allowing users to seamlessly design control charts for structured data types using the existing implementation. By introducing a flexible implementation of control charts, StatisticalProcessMonitoring.jl provides fully-automated and efficient algorithms for determining control limits and tuning control chart hyperparameters. These algorithms can accommodate various commonly-used performance metrics based on the run length distribution. The package further leverages existing packages in the Julia ecosystem to offer users a range of optimization and plotting functionalities.
dame-flame is a Python package for performing matching for observational causal inference on datasets containing discrete covariates. This package implements the dynamic almost matching exactly (DAME) and fast, large-scale almost matching exactly (FLAME) algorithms, which match treatment and control units on subsets of the covariates. The resulting matched groups are interpretable, because the matches are made directly on covariates, and high-quality, because machine learning is used to determine which covariates are important to match on instead of human inputs. The package provides several adjustable parameters to adapt the algorithms to specific applications, and can calculate treatment effects after matching. The most recent source code of the implementation is available at https://github.com/almost-matching-exactly/DAME-FLAME-Python-Package.
The BayesMortalityPlus package provides a framework for modeling and predicting mortality data. The package includes tools for the construction of life tables based on Heligman-Pollard laws, and also on dynamic linear smoothers. Flexibility is available in terms of modeling so that the response variable may be modeled as Poisson, binomial or Gaussian. If temporal data is available, the package provides a Bayesian implementation for the well-known Lee-Carter model that allows for estimation, projection of mortality over time, and assessment of uncertainty of any linear or nonlinear function of parameters such as life expectancy. Illustrations are considered to show the capability of the proposed package to model mortality data.
Special techniques must be considered during analysis of large-scale educational assessment (LSA) data. In this regard, many software packages are available to support researchers conducting secondary analyses. However, the software packages available for multilevel analyses are somewhat limited and usually contain only a few of the required techniques. In this article, we review the technical details of LSA studies and describe our comparison of software for multilevel analyses by questioning the extent to which these packages take these technical details into account. In accordance with our findings from this comparison, we developed a SAS macro for multilevel analyses of LSA data that meets all technical requirements. The macro SURVEYHLM fits multilevel models with LSA datasets. SURVEYHLM can handle up to three levels. It can fit different correlation structures for the random components and use plausible values as response variables, and the responses do not necessarily need to be normally distributed. Weights can be specified on levels 1, 2 and 3. Scaling of the level-specific weights is possible, and standard errors can be based on a sandwich estimator or calculated with either the jackknife replication technique or through user-supplied replication weights. Examples of applications are given.