Zurcher.jl
- This is a teaching-oriented package for the Bus Engine Replacement Model after Rust (1987) used for my Computational Econ Course
- We implement both naive nfxp and mpec estimation. It is naive nfxp because it uses standard VFI instead of the much more performant polyalgorithm developed by Rust in his paper. For a thorough benchmarking exercise I refer to
- ECTA Comment by Fedor Iskhakov, Jinhyuk Lee, John Rust, Bertel Schjerning, Kyoungwon Seo
- Matlab implementation which includes the polyalgorithm and analytic derivatives for likelihood function distributed as part of the DSE2019 summer school. Several parts of my code have been copied and modified from that code base.
What is the point of this package?
- The main point is to demonstrate the relative easiness with which we can tackle an MPEC problem with the
JuMP.jl
package. - JuMP is like AMPL, but for free and embedded in a proper programming language.
- For a similar, even more impressive demonstration of this please visit https://github.com/UBCECON567/BLPDemand.jl
Zurcher.Harold
— TypeHarold Zurcher DataType
- This type represents an instance of Harold Zurcher, the decision maker in Rust (1987)
- The default constructor builds
Harold
for the values in table X of the paper.
Zurcher.bellman
— Methodbellman(h::Harold, ev0::Vector)
Bellman Operator T(EV)
. Notice the centering of the log sum function by M
.
Zurcher.busdata
— Methodbusdata(z::Harold; bustype = 4)
Data Loader.
Zurcher.ccp
— Methodccp(h::Harold, ev0::Vector)
Conditional Choice Probability function returning the proability of replacing the engine at a given mileage state x
.
Zurcher.dataplots
— Methoddataplots()
return a dict of plots and tables from the data.
Zurcher.loglikelihood
— Methodlog likelihood function
\[l_n(\theta,EV_\theta) = \log \mathcal{L}_n(\theta,EV_\theta) = \sum_{i=1}^{162}\sum_{t=2}^{T_i} \left( \log P(d_{i,t}|x_{i,t}) + \log \pi(x_{i,t}|x_{i,t-1},d_{i,t-1}) \right)\]
Zurcher.make_trans
— Methodmake_trans(θ, n)
Build a transition matrix of mileage states for n
mileage bins and a vector θ of probabilities to move to each possible bin (or to stay in the same bin).
Zurcher.mpec
— Methodmpec(; β = 0.9, is_silent = false, doθ = false,n = 175, θ = [0.107, 0.5152 ,0.3622, 0.0143,0.0009])
MPEC estimation. Can choose to do partial MLE (don't estimate the θs for mileage transition).
Zurcher.nested_likelihood
— Methodnested_likelihood(x::Vector{Float64}, h::Harold, d::DataFrame)
Outer loop of NFXP proceedure. takes candidate vector x
of parameters, solves model, and evaluates the log likelihood.
Zurcher.nfxp
— Methodnfxp(; β = 0.9, is_silent = false, doθ = false,n = 175, θ = [0.107, 0.5152 ,0.3622, 0.0143,0.0009])
Nested Fixed Point estimation. Can choose to do partial MLE (don't estimate the θs for mileage transition).
Zurcher.plotit
— Methodplotit(;n=90, β=0.9)
Test plot.
Zurcher.runit
— Methodrunit(;n=90, β=0.9999,c=2.4, θ=[0.3, 0.68, 0.02])
Test run.
Zurcher.simit
— Methodsimit(; T=500,n=500, θ=[0.3,0.6,0.1])
Simulate one bus.
Zurcher.vfi
— Methodvfi(h::Harold)
Value Function Iterator. Will iterate on bellman
until the absolute norm is less than value h.tol
.
end