Journal of Statistical Software: Volume 116の記事一覧

Journal of Statistical Software Volume 116に記載されている内容を一覧にまとめ、機械翻訳を交えて日本語化し掲載します。

記事

collapse: Advanced and Fast Statistical Computing and Data Transformation in R

collapse: Advanced and Fast Statistical Computing and Data Transformation in R / collapse: Rにおける高度で高速な統計計算およびデータ変換

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.

collapseは、Rにおける複雑な統計計算、データ変換、および探索タスクを、卓越したパフォーマンスとメモリ効率で容易にする、大規模なC/C++ベースのインフラストラクチャパッケージです。また、Rプログラミングにおいてクラスに依存しないアプローチを採用しており、ベクトル、行列、データフレームのようなオブジェクトとその一般的な拡張機能(「units」、「integer64」、「xts」、「tibble」、「data.table」、「sf」、「pdata.frame」)をサポートすることで、Rエコシステムの大部分とのシームレスな統合を実現しています。この記事では、豊富な例を用いて、パッケージの主要コンポーネントと設計原則を体系的に解説します。また、簡単なベンチマークによって計算性能を示します。

Simulating Complex Cross-Sectional and Longitudinal Data Using the simDAG R Package

Simulating Complex Cross-Sectional and Longitudinal Data Using the simDAG R Package / simDAG Rパッケージを用いた複雑な横断的および縦断的データのシミュレーション

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.

モンテカルロシミュレーション研究を行う上で、人工データの生成は重要なステップです。計画されている研究によっては、複数の変数(場合によっては時間とともに変化する変数)と、様々な依存関係やデータ型を含む複雑なデータ生成プロセス(DGP)が必要となる場合があります。そのため、このようなDGPからデータをシミュレーションすることは、困難で時間のかかる作業となる可能性があります。simDAG Rパッケージは、任意の関数または回帰モデルを使用して有向非巡回グラフにおける構造方程式の定義に基づき、単純および複雑なDGPからデータを生成するための標準化されたアプローチを提供します。このパッケージは、強化された数式インターフェースを備えた明確な構文を提供し、任意の依存関係、場合によっては非線形関係および相互作用を持つバイナリ、カテゴリ、カウント、およびイベント発生までの時間データを直接生成することをサポートします。さらに、離散時間ベースのシミュレーションを実行するためのフレームワークも含まれており、半連続的な時間スケールで縦断的データを生成できます。このアプローチは、反復イベントまたは競合イベント、および場合によっては複数の時間変動共変量(それ自体が任意のデータ型を持つ可能性がある)の両方を含むイベント発生までの時間データを生成するために使用できます。この記事では、複数の実際のモンテカルロシミュレーション研究のDGPを再現することで、simDAGに含まれる膨大な機能を示します。

BayesMultiMode: Bayesian Mode Inference in R

BayesMultiMode: Bayesian Mode Inference in R / BayesMultiMode: Rにおけるベイズ的モード推定

Multimodal 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, BayesMultiMode 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ühwirth-Schnatter, and Grü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. BayesMultiMode supports a range of mixture processes, complementing and extending existing software for mixture modeling. The mode detection algorithms implemented in BayesMultiMode 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.

天体物理学、バイオインフォマティクス、気候学、経済学など多くの分野において、対象となる母集団の不均一性に起因して、多峰性(複数の山を持つこと)を示す一変量分布が現れます。混合モデル(混合プロセス)は、こうした分布を正確に近似し、潜在的なモード(山の頂点)を検出するための有力な手法です。BayesMultiModeは、ベイズ一変量混合モデルおよび関連手法を用い、モードの数、その位置、および不確実性に関する事後確率を推定することで、モード推論のための強力なツールを提供します。このアプローチはCross, Hoogerheide, Labonne, and Van Dijk (2024)の手法に基づき、2段階のプロセスで実行されます。第一段階では、Malsiner-Walli, Frühwirth-Schnatter, and Grün (2016)によるベイズマルコフ連鎖モンテカルロ(MCMC)法を用い、構成要素(成分)の数が未知である柔軟な混合モデルを推定します。第二段階では、適切な検出アルゴリズムを用いて、連続および離散確率分布のモードを推定します。これらのモード推定値に基づき、モードの数、位置、不確実性に関する事後確率が算出されます。BayesMultiModeは多様な混合モデルに対応しており、既存の混合モデル用ソフトウェアを補完・拡張するものです。本パッケージに実装されたモード検出アルゴリズムは、外部ソフトウェアで生成された混合モデル推定用のMCMCサンプルにも対応しています。また、実証例として、前述の4分野から得られた連続および離散の経験分布を使用しています。これにより、頻度論的な検定では単峰性という帰無仮説を棄却できない場合であっても、高い事後確率を伴う信頼性の高い多峰性検出が可能となります。

Policy Learning with the polle Package

Policy Learning with the polle Package / ポリシー学習polleパッケージ

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(), which are 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.

Rパッケージpolleは、観測データに基づいた有限段階ポリシーの学習と評価のための統一的なフレームワークです。このパッケージは、二重ロバストな制限付きQ学習、ポリシーツリー学習、結果重み付け学習など、因果ポリシー学習のための既存および新規の手法を多数実装しています。現実的なポリシーのみを考慮することで、(ほぼ)正値違反に対処します。非常に柔軟な機械学習手法を用いて不要成分を推定でき、クロスフィッティングによってポリシー値の妥当な推論が保証されます。このライブラリは、データ構造の指定、ユーザー指定ポリシーの定義、ポリシー学習手法の指定、および(学習済み)ポリシーの評価に使用される4つの主要関数policy_data()、policy_def()、policy_learn()、policy_eval()を中心としたシンプルな構文で構成されています。パッケージの機能は、再現可能な豊富な例によって示されています。

BCDAG: An R Package for Bayesian Structure and Causal Learning of Gaussian DAGs

BCDAG: An R Package for Bayesian Structure and Causal Learning of Gaussian DAGs / BCDAG: ガウスDAGのベイズ的構造学習および因果学習のためのRパッケージ

Directed acyclic graphs (DAGs) provide a powerful framework to represent dependence relationships among variables in multivariate settings; in addition, under causal assumptions on the underlying data generating mechanism, they allow for the identification and estimation of causal effects between variables even from pure observational data. In this setting, the process of inferring the DAG structure from the data is referred to as causal structure learning or causal discovery. We introduce BCDAG, an R package for Bayesian causal discovery and causal effect estimation from Gaussian observational data, based on the methodology proposed by Castelletti and Mascaro (2021). We summarize the main features of the underlying method and illustrate its implementation using real and simulated data. Our algorithms scale efficiently with the number of observations and, whenever the DAGs are sufficiently sparse, with the number of variables in the dataset. In addition, the package provides functions for convergence diagnostics and for visualizing and summarizing posterior inference.

有向非巡回グラフ(DAG)は、多変量環境における変数間の依存関係を表現するための強力な枠組みを提供します。さらに、データの生成メカニズムに関する因果的仮定を置くことで、純粋な観測データからでも変数間の因果効果を識別・推定することが可能になります。このような状況において、データからDAG構造を推定するプロセスは、因果構造学習(causal structure learning)や因果発見(causal discovery)と呼ばれます。本稿では、Castelletti and Mascaro (2021)が提案した手法に基づき、ガウス分布に従う観測データからベイズ的な因果発見と因果効果の推定を行うためのRパッケージ「BCDAG」を紹介します。ここでは、その手法の主な特徴を概説するとともに、実データやシミュレーションデータを用いた実装例を示します。当社のアルゴリズムは、観測数に応じて効率的にスケーリングします。また、DAG(有向非巡回グラフ)が十分に疎(スパース)である場合には、データセット内の変数数に応じても効率的にスケーリングします。さらに、本パッケージには、収束診断や、事後推論結果の可視化・要約を行うための関数も用意されています。

fastcpd: Fast Change Point Detection in R

fastcpd: Fast Change Point Detection in R / fastcpd: Rにおける高速な変化点検知

Change point analysis is concerned with detecting and locating structural breaks in the underlying model of a sequence of observations ordered by time, space or other variables. A widely adopted approach for change point analysis is to minimize an objective function with a penalty term on the number of change points. This framework includes several well-established procedures, such as the penalized log-likelihood using the (modified) Bayesian information criterion or the minimum description length. The resulting optimization problem can be solved in polynomial time by dynamic programming or its improved version, such as the pruned exact linear time (PELT) algorithm (Killick, Fearnhead, and Eckley 2012). However, existing computational methods often suffer from two primary limitations: (1) methods based on direct implementation of dynamic programming or PELT are often time-consuming for long data sequences due to repeated computation of the cost value over different segments of the data sequence; (2) state-of-the-art R packages do not provide enough flexibility for users to handle different change point settings and models. In this work, we present the fastcpd package, aiming to provide an efficient and versatile framework for change point detection in several commonly encountered settings. The core of our algorithm is built upon PELT and the sequential gradient descent method recently proposed by Zhang and Dawn (2023). We illustrate the usage of the fastcpd package through several examples, including mean/variance changes in a (multivariate) Gaussian sequence, parameter changes in regression models, structural breaks in ARMA/GARCH/VAR models, and changes in user-specified models.

変化点分析は、時間、空間、あるいはその他の変数によって順序付けられた観測値の系列において、その背後にあるモデルの構造的変化(構造変化)を検出し、その位置を特定することを目的としています。変化点分析において広く採用されている手法の一つに、変化点の数に対するペナルティ項を含む目的関数を最小化するというアプローチがあります。この枠組みには、(修正)ベイズ情報量規準(BIC)や最小記述長(MDL)を用いたペナルティ付き対数尤度など、確立された手法がいくつか含まれます。この最適化問題は、動的計画法、あるいはその改良版であるPELT(Pruned Exact Linear Time)アルゴリズム(Killick, Fearnhead, and Eckley 2012)などを用いることで、多項式時間で解くことが可能です。しかし、既存の計算手法には主に2つの限界があります。(1)動的計画法やPELTを直接実装した手法では、データ系列の異なるセグメントに対してコスト値を繰り返し計算する必要があるため、長いデータ系列に対しては計算に多くの時間を要することがあります。(2)最先端のRパッケージであっても、ユーザーが多様な変化点の設定やモデルに対応できるだけの十分な柔軟性を備えていない場合があります。本研究では、一般的によく見られるいくつかの設定において、変化点検出のための効率的かつ汎用的な枠組みを提供することを目的とした「fastcpd」パッケージを提案します。提案アルゴリズムの核心は、PELTと、ZhangおよびDawn(2023)によって最近提案された逐次勾配降下法に基づいています。本稿では、(多変量)ガウス系列における平均や分散の変化、回帰モデルにおけるパラメータの変化、ARMA/GARCH/VARモデルにおける構造変化、そしてユーザーが指定したモデルにおける変化など、いくつかの具体例を通じてfastcpdパッケージの使用法を解説します。

CPU- and GPU-Based Distributed Sampling in Dirichlet Process Mixtures for Large-Scale Analysis

CPU- and GPU-Based Distributed Sampling in Dirichlet Process Mixtures for Large-Scale Analysis / 大規模解析のためのディリクレ過程混合モデルにおけるCPUおよびGPUベースの分散サンプリング

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, central-processing- unit (CPU) implementation (in Julia) and a multiple-stream graphics-processing-unit (GPU) implementation (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 (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 multiple 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.

教師なし学習の分野では、ディリクレ過程混合モデル(DPMM)に代表されるベイズ非パラメトリック混合モデルは、モデルの複雑さをデータに合わせて調整するための原理的なアプローチを提供します。このようなモデルは、クラスタ数が不明なクラスタリングタスクにおいて特に有用です。しかし、その潜在能力と数学的な洗練さにもかかわらず、DPMMは実務者に広く採用される主流ツールにはなっていません。これはおそらく、これらのモデルはスケーラビリティが低いという誤解と、大規模データセットを効率的に処理できる高性能(かつ使いやすい)ソフトウェアツールの不足が原因でしょう。本稿では、スケーラブルなDPMM推論のための、使いやすい新しい統計ソフトウェアパッケージを提案することで、この実用的なギャップを埋めます。より具体的には、DPMMにおける高性能分散サンプリングベース推論のための効率的で容易に変更可能な実装を提供します。ユーザーは、マルチマシン、マルチコア、中央処理装置(CPU)実装(Julia)とマルチストリームグラフィックス処理装置(GPU)実装(CUDA/C++)のいずれかを自由に選択できます。CPUとGPUの実装には共通の(オプションの)Pythonラッパーが付属しており、ユーザーは同じインターフェースで単一のエントリポイントを利用できます。アルゴリズム面では、当社の実装はChangとFisher III(2013)による最先端のDPMMサンプラーを活用しています。ChangとFisher IIIの実装(MATLAB/C++)はCPUのみを使用し、単一のマルチコアマシン向けに設計されていましたが、ここで提案するパッケージは、複数のマルチコアマシンまたは複数のGPUストリームに計算を効率的に分散します。これにより、処理速度が向上し、メモリとストレージの制限が緩和され、ChangとFisher III(2013)や他のDPMM手法ではこれまで不可能だった、より大規模で高次元のデータセットにDPMMを適合させることができます。

cv: An R Package for Cross-Validating Regression Models

cv: An R Package for Cross-Validating Regression Models / cv: 回帰モデルの交差検証を行うためのRパッケージ

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.

また、標準的なRの回帰モデルに対する交差検証を、統一的かつ使いやすい総称的関数(ジェネリック関数)を通じて実装する「cv」パッケージについても説明します。cv()関数用のメソッドは、混合効果モデルを含む、一般的に用いられる多くの統計モデルクラスに対して提供されており、追加のモデルクラス用のメソッドを記述することで、cvパッケージを容易に拡張することが可能です。さらに、cv()関数は、変数変換、予測変数の選択、競合するモデル間での選択などを含む複雑なモデル選択手順に対しても、交差検証を行うことができます。`cv()`関数は一般的に並列計算をサポートしており、線形モデルや一般化線形モデル向けに用意されたメソッドでは、計算の効率化が図られています。

参考文献

関連情報