Skip to main content

heap - STATA software code 'heap'

This is a STATA software code (under review by the STATA Journal):

This command is for estimating discrete outcome variable models in the presence of heaping at known points. (Wiji Arulampalam, Valentina Corradi, Daniel Gutknecht, and Zizhong, Yan.) Software code; Accompanying paper (SSRN; Warwick).


Self-reported survey data are often plagued by the presence of heaping. Accounting for this measurement error is crucial for the identification and consistent estimation of the underlying model (parameters) from such data. This paper introduces two Stata commands. The first command, heapmph, estimates the parameters of a discrete-time mixed proportional hazard model with gamma unobserved heterogeneity, allowing for fixed and random right censoring, and different sized heap points. The second command, heapop, extends the framework to ordered probability models, subject to heaping. Suitable specification tests are also provided.

*Program Installation:
net from
net describe heap
net install heap, all replace

*Example data, may be accessed using:
net get heap, all replace
use "heap_demonstration.dta", clear

*Helpfile can be accessed by using:
"help heapmph" or "heapop"

*Examples of the usage of the command:
heapmph duration age_m school_m ,censor(18) hstar(5) jbar(3) kbar(12) rbar(1)
heapop duration age_m school_m ,censor(18) hstar(5) jbar(3) kbar(12) rbar(1)

*Corresponding author of the code:

Dr. Zizhong Yan
Center for Econometrics and Microdata Practice,
Institute for Economic and Social Research,
Jinan University, Guangzhou, China.
Home page: