Giter VIP home page Giter VIP logo

jabbring / mht-likelihood Goto Github PK

View Code? Open in Web Editor NEW
5.0 1.0 2.0 2.4 MB

Replication package for Abbring and Salimans (2021), "The Likelihood of Mixed Hitting Times," with MATLAB code for estimating mixed hitting-time models

License: MIT License

MATLAB 95.79% Makefile 1.00% TeX 3.21%
estimation likelihood maximum-likelihood first-passage-times hitting-times strike-durations duration-analysis identification mixture mixed-hitting-time-model duration survival survival-analysis matlab

mht-likelihood's Introduction

The Likelihood of Mixed Hitting Times: Replication Package

This repository contains MATLAB code for replicating the numerical results in Abbring and Salimans (2021). This covers the computation of the likelihood of the mixed hitting-time (MHT) model, maximum likelihood (ML) estimation of parametric versions of this model, and an application to the analysis of Kennan's (1985) strike data.

Makefile and scripts

The results in Abbring and Salimans (2021) were obtained using v1.1.1 of this package, by running make on a MacBook Pro (2018, 15inch, 2.9GHz 6-Core Intel Core i9, 32 GB 2400 MHz DDR4) with macOS 10.15.7, MATLAB R2020b (with Optimization Toolbox), and TeX Live 2018 (make.log logs this run). As specified in the makefile, this executes the MATLAB scripts

  • figure1.m - replicates Figure 1
  • figure2.m - replicates Figure 2
  • figure3.m - replicates Figure 3
  • table1.m - replicates Table 1 and estimates a version with gamma shocks
  • table1lowM.m - recalculates Table 1 with M=15
  • table1mig.m - recalculates Columns I-V of Table 1 using the exact likelihood for the Gaussian case
  • figure4.m - replicates Figure 4
  • checkgradient.m - checks analytic gradients against numerical ones

and then runs pdfTeX on replication.tex, which depends on csv and tex files outputted by MATLAB in the previous step, to display the resulting figures and tables in replication.pdf. As an extra check, the scripts for computing Figures 1-4 can be adapted, by changing dispplot=false into dispplot=true, to plot these figures directly.

The repository also contains a script

  • simtest.m - simulates data and estimates the model on these data

Users can adapt these scripts to apply the procedures they call in other contexts. In particular, table1.m shows how to use the package to estimate the MHT model with jumps.

The scripts require a range of MATLAB functions and a data set.

Functions

1. Model specification

The procedures require parametric specifications <heter> of the unobserved heterogeneity specification and <shocks> of the jumps in the latent Lévy process. The calculation of the factors entering the summands in the approximations of the mixed survival function and probability density are coded up as functions <heter><shocks> in files <heter><shocks>.m:

  • pointpoint.m - Discrete heterogeneity and discrete shocks at Poisson times
  • pointgamma.m - Discrete heterogeneity and gamma shocks at Poisson times
  • gammapoint.m - Gamma heterogeneity and discrete shocks at Poisson times
  • gammagamma.m- Gamma heterogeneity and gamma shocks at Poisson times

Users can extend the set of specifications by adding different functions <heter><shocks>.

2. Probability densities and cumulate distributions

  • numinvlap.m - MHT pdf (of ln T, so t.f_T(t)) and cdf values (calculated by Laplace transform inversion) and their gradients with respect to the parameter vector
  • numinvlap2.m - idem, but with input of design parameter M
  • igausscdf.m - inverse Gaussian cdf
  • igausspdf.m - inverse Gaussian pdf
  • weibullcdf.m - Weibull MPH cdf
  • weibullpdf.m - Weibull MPH pdf

3. Likelihood calculation

  • mhtobj.m - minus the log likelihood of the MHT model (calculated by Laplace transform inversion) and its gradient with respect to the parameter vector
  • mhtobj2.m - idem, but with input of design parameter M
  • mhtgrad.m - same as mhtobj.m, but only returning the gradient
  • mhtgrad2.m - same as mhtobj2.m, but only returning the gradient
  • lhmigauss.m - likelihood of the MHT model (calculated using explicit expressions for the Gaussian case)
  • nllhmigauss.m - minus the log likelihood of the MHT model (calculated using explicit expressions for the Gaussian case) and its gradient with respect to the parameter vector
  • nllhmph.m - minus the log likelihood of the Weibull MPH model and its gradient with respect to the parameter vector

4. Maximum likelihood estimation

  • mhtmle.m - ML estimation of the general MHT model (based on Laplace inversion)
  • mhtmle2.m - idem, but with input of design parameter M
  • migaussmle.m - ML estimation of the Gaussian special case

5. Simulation

  • randraw.m - efficient random number generator (by Alex Bar Guy and Alexander Podgaetsky)
  • simmht.m - simulates durations from mixed hitting time model

6. Numerical differentiation

  • numgrad.m - calculation of gradient using finite (central) differences
  • numjac.m - calculation of Jacobian using finite (central) differences (used to compute Hessian from gradient functions)

Data

References

We welcome the use of this software under an MIT license.

© 2020 Jaap H. Abbring and Tim Salimans

DOI

mht-likelihood's People

Contributors

jabbring avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.