Skip to contents

R-CMD-check License: GPL v3 CRAN Issues Downloads Stars Like PINstimation? - Support our Work!

Overview


PINstimation provides utilities for the estimation of probability of informed trading models: original PIN (PIN) in Easley and O’Hara (1992) and Easley et al. (1996); multilayer PIN (MPIN) in Ersan (2016); Adjusted PIN (AdjPIN) in Duarte and Young (2009); and volume- synchronized PIN (VPIN) in Easley et al. (2011, 2012); and an improved VPIN implemented (iVPIN), which follows Lin and Ke (2017). Various computation methods suggested in the literature are included. Data simulation tools and trade classification algorithms are among the supplementary utilities. The package enables fast and precise solutions for the sophisticated, error-prone and time-consuming estimation procedure of the probability of informed trading measures, and it is compact in the sense detailed estimation results can be achieved by solely the use of raw trade level data.

Changelog

New in Version 0.2.0

  • ivpin(): Implements an improved VPIN estimator based on Ke and Lin (2017). Using maximum-likelihood estimation, ivpin() provides more stable VPIN estimates—especially with small volume buckets or infrequent informed trades—by capturing information embedded in volume time. This can yield more consistent measures of flow toxicity.
  • classify_trades() and aggregate_trades() now support negative timelag values (quote leads), with updated documentation and examples showing how lag/lead quotes are used by the classification algorithms.
  • initials_adjpin(): Updated to align the generation of initial parameter sets for the adjusted PIN model with the procedure described in Ersan and Ghachem (2024).

Installation


The easiest way to get PINstimation is the following:

install.packages("PINstimation")

To get a bugfix or to use a feature from the development version, you can install the development version of PINstimation from GitHub.

# install.packages("devtools")
# library(devtools)
devtools::install_github("monty-se/PINstimation")

Loading the package

Get Started!

For a smooth introduction to the main functionalities of the package, as well as useful tips on how to get started with PINstimation, please refer to the Get Started page.


A detailed description of the package functions is available in the online documentation.

Note to frequent users


If you are a frequent user of PINstimation, you might want to avoid repetitively loading the package PINstimation whenever you open a new R session. You can do that by adding PINstimation to .R profile either manually, or using the function load_pinstimation_for_good().

To automatically load PINstimation, run load_pinstimation_for_good(), and the following code will be added to your .R profile.

After restart of the R session, PINstimation will be loaded automatically, whenever a new R session is started. To remove the automatic loading of PINstimation, just open the .R profile for editing usethis::edit_r_profile(), find the code above, and delete it.

Resources


For a smooth introduction to, and useful tips on the main functionalities of the package, please refer to:

  • The sections Get Started, and Online documentation on the package site.
  • The package documentation in PDF format is available for download here.
  • An overview of the scientific research underlying the package is available here.

Contributions


The package makes a series of original contributions to the literature:

  • An efficient, user-friendly, and comprehensive implementation of the standard models of probability of informed trading.

  • A first implementation of the estimation of the multilayer probability of informed trading (MPIN) as developed by Ersan (2016).

  • A comprehensive treatment of the estimation of the adjusted probability of informed trading as introduced by Duarte and Young (2009). This includes the implementation of the factorization of the AdjPIN likelihood function, various algorithms to generate initial parameter sets, and MLE method.

  • The introduction of the expectation-conditional maximization (ECM) algorithm as an alternative method to estimate the models of probability of informed trading. The contribution is both theoretical and computational. The theoretical contribution is included in the paper by Ghachem and Ersan (2025a). The implementation of the ECM algorithm allows the estimation of PIN, MPIN, as well as the adjusted PIN model.

  • Implementation of three layer-detection algorithms, namely of preexistent algorithm of Ersan (2016), as well as two newly developed algorithms, described in Ersan and Ghachem (2024), and Ghachem and Ersan (2025b), respectively.

  • A first implementation of the estimation of the volume-synchronized probability of informed trading (VPIN) as introduced by Easley et al. (2011, 2012), together with an improved VPIN estimator ivpin() based on Lin and Ke (2017), which uses maximum likelihood methods to deliver more stable VPIN measures, especially with small volume buckets or infrequent informed trading.

  • One do-it-all function for trade classification in buyer-initiated or seller-initiated trades that implements the standard algorithms in the field, namely Tick, Quote, LR, and EMO, along with companion tools such as classify_trades() and aggregate_trades() that handle quote–trade alignment via positive and negative timelag (quote lags and leads) and provide flexible aggregation of high-frequency trade and quote data.

Alternative packages


To our knowledge, there are two preexisting R packages for the estimation of the probability of informed trading: pinbasic, and InfoTrad.

Getting help


If you encounter a clear bug, please file an issue with a minimal reproducible example on GitHub.