REPLICATION PACKAGE
===================

Niku Määttänen and Marko Terviö, "Income Distribution and Housing Prices:
An Assignment Model Approach", Journal of Economic Theory 151 (2014), 381-410.

This package reproduces Figures 1-7, Table 1 and Table B1. A few entries of
the two tables differ from the printed article; discrepancies.txt lists them.

CONTENTS

  readme.txt         This file.
  discrepancies.txt  Results that differ from the printed article.
  BUILD.txt          Date and version of this archive; pre-built outputs.
  mathematica/       Figures 1 and 2 (the model): parameters, equilibrium
                     solver and figure script. Wolfram Language.
  stata/             Survey preprocessing and Table B1. Stata.
  matlab/            Figures 3 to 7 and Table 1. Matlab.
  data/raw/          American Housing Survey extracts, 1998 and 2007.
  data/processed/    The twelve Matlab inputs written by stata/preprocess.do,
                     included so that the Matlab step runs without Stata.
  data/retained/     The twelve inputs as exported by the authors in 2010; the
                     Matlab step can use them instead of data/processed/.
  data/external/     Metropolitan population counts for Table B1.
  config/            Checksums of all input files.
  output/            All programs write here. The equilibrium grid, Figures 1
                     and 2 and TableB1.csv are included pre-built.

Each code folder has a README with details. The data folders document their
sources and columns.

REQUIREMENTS

  Figures 1-2   Mathematica 15.0 (wolframscript or the front end).
  Stata steps   Stata 16.1 or later, built-in commands only. Tested with 19.5.
  Matlab step   Base Matlab, no toolboxes. Tested with R2026a.

No internet access is needed. The Mathematica step is independent of the
others. The Matlab step runs directly from the included inputs. Table B1
requires the Stata preprocessing first. The included Stata outputs were
produced with Stata/SE.

HOW TO RUN

Extract the archive into a new, writable folder and make that folder the
working directory in each program. All commands and paths below are
relative to it. The Mathematica and Matlab steps also run from any other
directory when given the full path to the file or folder.

1. Figures 1 and 2 (under a minute):

       wolframscript -file mathematica/HousingEquilibrium.wl
       wolframscript -file mathematica/HousingFigures.wl

   The first command solves the model's equilibrium and writes the grid to
   output/model/; the second draws the figures from it and writes
   Figure1.png, Figure1.eps, Figure2.png and Figure2.eps to
   output/figures/. The article used Figure1.png and Figure2.eps. The
   figure script runs the solver itself if its output is missing.

2. Preprocessing, in Stata:

       do "stata/preprocess.do"

   Writes the twelve Matlab inputs to data/processed/, reproducing the
   included copies, and data/processed/ahs-observations.dta, which step 4
   needs.

3. Figures 3 to 7 and Table 1, in Matlab:

       addpath('matlab');
       R = run_figures;

   Writes Figure3 to Figure7 as PDF and PNG to output/figures/, Table1.csv
   to output/tables/, and the plotted series and diagnostics. Figure 4 is
   written for both survey years; see discrepancies.txt.
   R = run_figures('retained') repeats the step with the authors' 2010
   inputs and writes under output/retained/.

4. Table B1, in Stata, after step 2:

       do "stata/make_table_b1.do"

   Writes output/tables/TableB1.csv.

WHAT TO EXPECT

Figures 1 and 2 reproduce the published figures to pixel accuracy; fonts
and line widths differ slightly. Figures 3 to 7 reproduce the published
curves. Table 1 matches 21 of its 24 printed entries and Table B1 61 of
66; discrepancies.txt gives the reproduced and printed values of the rest.
The programs always write the calculated values.

DATA

The survey inputs are extracts from the public-use American Housing Survey
metropolitan files for 1998 and 2007 (U.S. Census Bureau and HUD), limited
to the six metropolitan areas, owner-occupied households and the variables
used. One variable is added: price_tie_order, the order in which the
authors' 2010 calculation ranked households with equal house values. The
income smoother depends on that order, so it is kept explicitly. See
data/raw/README.md for the selection and data/downloads/README.md for the
source files.

The equilibrium behind Figures 1 and 2 is computed from the model
primitives by mathematica/HousingEquilibrium.wl; the parameters are set in
mathematica/HousingModel.wl. The population counts are from Census table
CPH-T-2 (2000 and 2010, December 2009 metropolitan definitions).
