Skip to content

Commit 31bc665

Browse files
committed
Minor updates of readme and notebooks
1 parent 2fde580 commit 31bc665

File tree

7 files changed

+35
-33
lines changed

7 files changed

+35
-33
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2021 Matthew D. Cocci and Mikkel Plagborg-Moller
3+
Copyright (c) 2023 Matthew D. Cocci and Mikkel Plagborg-Moller
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ Python package that computes worst-case standard errors (SE) for minimum distanc
55
The computed worst-case SE for the estimated parameters are sharp upper bounds on the true SE (which depend on the unknown moment correlation structure). For over-identified models, the package also computes the efficient moment selection that minimizes the worst-case SE. Additionally, the package can carry out tests of parameter restrictions or over-identifying restrictions.
66

77
**Reference:**
8-
Cocci, Matthew D., and Mikkel Plagborg-Møller (2021), "Standard Errors for Calibrated Parameters", [arXiv:2109.08109](https://arxiv.org/abs/2109.08109)
8+
Cocci, Matthew D., and Mikkel Plagborg-Møller (2023), "Standard Errors for Calibrated Parameters", [arXiv:2109.08109](https://arxiv.org/abs/2109.08109)
99

10-
Tested in: Python 3.8.11 (Anaconda distribution) on Windows 10 PC
10+
Tested in: Python 3.8.18 (Anaconda distribution) on Windows 10 PC with NumPy version 1.24.3.
1111

1212
Other versions: [Matlab](https://github.com/mikkelpm/stderr_calibration_matlab)
1313

@@ -19,9 +19,9 @@ Other versions: [Matlab](https://github.com/mikkelpm/stderr_calibration_matlab)
1919

2020
- [stderr_calibration](stderr_calibration): Python package for minimum distance estimation, standard errors, and testing
2121

22-
- [estimate_hank.py](estimate_hank.py): Empirical application to estimation of a heterogeneous agent New Keynesian macro model, using impulse response estimates from [Chang, Chen & Schorfheide (2021)](https://cpb-us-w2.wpmucdn.com/web.sas.upenn.edu/dist/e/242/files/2021/05/EvalHAmodels_v6_pub.pdf) and [Miranda-Agrippino & Ricco (2021)](https://doi.org/10.1257/mac.20180124), which are stored in the [data](data) folder
22+
- [estimate_hank.py](estimate_hank.py): Empirical application to estimation of a heterogeneous agent New Keynesian macro model, using impulse response estimates from [Chang, Chen & Schorfheide (2023)](https://web.sas.upenn.edu/schorf/files/2023/09/EvalHAmodels_v15_nocolor.pdf) and [Miranda-Agrippino & Ricco (2021)](https://doi.org/10.1257/mac.20180124), which are stored in the [data](data) folder
2323

24-
- [sequence_jacobian](sequence_jacobian): Copy of the [Sequence-Space Jacobian](https://github.com/shade-econ/sequence-jacobian) package developed by [Auclert, Bardóczy, Rognlie & Straub (2021)](http://web.stanford.edu/~aauclert/sequence_space_jacobian.pdf), with minor changes made to the file [hank.py](sequence_jacobian/hank.py)
24+
- [sequence_jacobian](sequence_jacobian): Copy of the [Sequence-Space Jacobian](https://github.com/shade-econ/sequence-jacobian) package developed by [Auclert, Bardóczy, Rognlie & Straub (2021)](https://doi.org/10.3982/ECTA17434), with minor changes made to the file [hank.py](sequence_jacobian/hank.py)
2525

2626
- [tests](tests): Unit tests intended for use with the [pytest](https://docs.pytest.org/) framework
2727

docs/example.html

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
.highlight .m { color: var(--jp-mirror-editor-number-color) } /* Literal.Number */
3737
.highlight .s { color: var(--jp-mirror-editor-string-color) } /* Literal.String */
3838
.highlight .ow { color: var(--jp-mirror-editor-operator-color); font-weight: bold } /* Operator.Word */
39+
.highlight .pm { color: var(--jp-mirror-editor-punctuation-color) } /* Punctuation.Marker */
3940
.highlight .w { color: var(--jp-mirror-editor-variable-color) } /* Text.Whitespace */
4041
.highlight .mb { color: var(--jp-mirror-editor-number-color) } /* Literal.Number.Bin */
4142
.highlight .mf { color: var(--jp-mirror-editor-number-color) } /* Literal.Number.Float */
@@ -13976,7 +13977,7 @@ <h1 id="Standard-errors-for-calibrated-parameters:-Example">Standard errors for
1397613977
<p>We observe the noisy estimates $(\hat{\mu}_1,\hat{\mu}_2,\hat{\mu}_3) = (1.1,0.8,-0.1)$ of the true moments. The standard errors of the three empirical moments are $(\hat{\sigma}_1,\hat{\sigma}_2,\hat{\sigma}_3)=(0.1,0.2,0.05)$.</p>
1397713978
<p>We will estimate the parameters $(\theta_1,\theta_2)$ by minimum distance, matching the model-implied moments $h(\theta_1,\theta_2)$ to the empirical moments:
1397813979
$$\hat{\theta} = \text{argmin}_{\theta}\; (\hat{\mu}-h(\theta))'\hat{W}(\hat{\mu}-h(\theta)).$$</p>
13979-
<p>To compute standard errors for the estimated parameters, test hypotheses, and compute the efficient weight matrix $\hat{W}$, we use the formulas in <a href="https://scholar.princeton.edu/mikkelpm/calibration">Cocci &amp; Plagborg-Møller (2021)</a>, which do not require knowledge of the correlation structure of the empirical moments.</p>
13980+
<p>To compute standard errors for the estimated parameters, test hypotheses, and compute the efficient weight matrix $\hat{W}$, we use the formulas in <a href="https://arxiv.org/abs/2109.08109">Cocci &amp; Plagborg-Møller (2023)</a>, which do not require knowledge of the correlation structure of the empirical moments.</p>
1398013981
<h2 id="Define-the-model">Define the model<a class="anchor-link" href="#Define-the-model">&#182;</a></h2><p>We first import relevant packages and define the model and data.</p>
1398113982

1398213983
</div>
@@ -14119,12 +14120,12 @@ <h2 id="Test-of-parameter-restrictions">Test of parameter restrictions<a class="
1411914120
<div class="jp-RenderedText jp-OutputArea-output" data-mime-type="text/plain">
1412014121
<pre> pcost dcost gap pres dres k/t
1412114122
0: 2.0000e+00 2.0000e+00 1e+00 9e-02 0e+00 1e+00
14122-
1: 2.8317e+00 2.7762e+00 4e-01 3e-02 2e-17 3e-01
14123-
2: 2.8651e+00 2.8553e+00 6e-02 4e-03 5e-17 4e-02
14124-
3: 2.8870e+00 2.8845e+00 1e-02 6e-04 7e-17 5e-03
14125-
4: 2.8889e+00 2.8888e+00 4e-04 2e-05 4e-18 2e-04
14126-
5: 2.8889e+00 2.8889e+00 9e-06 6e-07 2e-17 4e-06
14127-
6: 2.8889e+00 2.8889e+00 2e-07 1e-08 1e-17 9e-08
14123+
1: 2.8317e+00 2.7762e+00 4e-01 3e-02 8e-18 3e-01
14124+
2: 2.8651e+00 2.8553e+00 6e-02 4e-03 1e-17 4e-02
14125+
3: 2.8870e+00 2.8845e+00 1e-02 6e-04 4e-17 5e-03
14126+
4: 2.8889e+00 2.8888e+00 4e-04 2e-05 3e-17 2e-04
14127+
5: 2.8889e+00 2.8889e+00 9e-06 6e-07 8e-18 4e-06
14128+
6: 2.8889e+00 2.8889e+00 2e-07 1e-08 7e-18 9e-08
1412814129
Optimal solution found.
1412914130

1413014131
t-statistics for testing individual parameters
@@ -14178,16 +14179,16 @@ <h2 id="Test-of-parameter-restrictions">Test of parameter restrictions<a class="
1417814179
<div class="jp-RenderedText jp-OutputArea-output" data-mime-type="text/plain">
1417914180
<pre> pcost dcost gap pres dres k/t
1418014181
0: 2.0000e+00 2.0000e+00 1e+00 9e-02 0e+00 1e+00
14181-
1: 2.8317e+00 2.7762e+00 4e-01 3e-02 2e-17 3e-01
14182-
2: 2.8651e+00 2.8553e+00 6e-02 4e-03 5e-17 4e-02
14183-
3: 2.8870e+00 2.8845e+00 1e-02 6e-04 7e-17 5e-03
14184-
4: 2.8889e+00 2.8888e+00 4e-04 2e-05 4e-18 2e-04
14185-
5: 2.8889e+00 2.8889e+00 9e-06 6e-07 2e-17 4e-06
14186-
6: 2.8889e+00 2.8889e+00 2e-07 1e-08 1e-17 9e-08
14182+
1: 2.8317e+00 2.7762e+00 4e-01 3e-02 8e-18 3e-01
14183+
2: 2.8651e+00 2.8553e+00 6e-02 4e-03 1e-17 4e-02
14184+
3: 2.8870e+00 2.8845e+00 1e-02 6e-04 4e-17 5e-03
14185+
4: 2.8889e+00 2.8888e+00 4e-04 2e-05 3e-17 2e-04
14186+
5: 2.8889e+00 2.8889e+00 9e-06 6e-07 8e-18 4e-06
14187+
6: 2.8889e+00 2.8889e+00 2e-07 1e-08 7e-18 9e-08
1418714188
Optimal solution found.
1418814189

1418914190
p-value of joint test
14190-
0.19901704910658857
14191+
0.19901704910658835
1419114192
</pre>
1419214193
</div>
1419314194
</div>

docs/example_ngm.html

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
.highlight .m { color: var(--jp-mirror-editor-number-color) } /* Literal.Number */
3737
.highlight .s { color: var(--jp-mirror-editor-string-color) } /* Literal.String */
3838
.highlight .ow { color: var(--jp-mirror-editor-operator-color); font-weight: bold } /* Operator.Word */
39+
.highlight .pm { color: var(--jp-mirror-editor-punctuation-color) } /* Punctuation.Marker */
3940
.highlight .w { color: var(--jp-mirror-editor-variable-color) } /* Text.Whitespace */
4041
.highlight .mb { color: var(--jp-mirror-editor-number-color) } /* Literal.Number.Bin */
4142
.highlight .mf { color: var(--jp-mirror-editor-number-color) } /* Literal.Number.Float */
@@ -13972,7 +13973,7 @@
1397213973
<div class="jp-Cell-inputWrapper"><div class="jp-InputPrompt jp-InputArea-prompt">
1397313974
</div><div class="jp-RenderedHTMLCommon jp-RenderedMarkdown jp-MarkdownOutput " data-mime-type="text/markdown">
1397413975
<h1 id="Standard-errors-for-calibrated-parameters:-Neoclassical-Growth-Model-example">Standard errors for calibrated parameters: Neoclassical Growth Model example<a class="anchor-link" href="#Standard-errors-for-calibrated-parameters:-Neoclassical-Growth-Model-example">&#182;</a></h1><p><em>We are grateful to Ben Moll for suggesting this example. Any errors are our own.</em></p>
13975-
<p>In this notebook we will work through the basic logic of <a href="https://scholar.princeton.edu/mikkelpm/calibration">Cocci &amp; Plagborg-Møller (2021)</a> in the context of calibrating a simple version of the Neoclassical Growth Model (NGM). Though the model is highly stylized, it helps provide intuition for our procedures. Please see our paper for other, arguably more realistic, empirical applications.</p>
13976+
<p>In this notebook we will work through the basic logic of <a href="https://arxiv.org/abs/2109.08109">Cocci &amp; Plagborg-Møller (2023)</a> in the context of calibrating a simple version of the Neoclassical Growth Model (NGM). Though the model is highly stylized, it helps provide intuition for our procedures. Please see our paper for other, arguably more realistic, empirical applications.</p>
1397613977
<h2 id="Model">Model<a class="anchor-link" href="#Model">&#182;</a></h2><p>We consider the simplest version of the NGM without population growth or technological growth. As explained in section 3.4 of <a href="https://perhuaman.files.wordpress.com/2014/06/macrotheory-dirk-krueger.pdf">Dirk Krueger's lecture notes</a> (note the difference in notation), this model implies three key steady-state equations:</p>
1397713978
<ol>
1397813979
<li><strong>Euler equation:</strong> $r = \rho$, where $\rho$ is the household discount rate and $r$ is the real interest rate.</li>
@@ -14012,7 +14013,7 @@ <h2 id="Limited-information-inference">Limited-information inference<a class="an
1401214013
where
1401314014
$$\hat{x}_1=\hat{x}_2=\widehat{\frac{K}{Y}},\quad \hat{x}_3=\left(\hat{r}+\widehat{\frac{I}{K}} \right).$$
1401414015
Notice that this upper bound only depends on things that we know: the sample averages themselves and their individual standard errors (but not the correlations across moments).</p>
14015-
<p>It's impossible to improve the bound without further knowledge of the correlation structure: The bound turns out to equal the actual standard error when the three sample averages are perfectly correlated with each other. This is proved in Lemma 1 in <a href="https://scholar.princeton.edu/mikkelpm/calibration">our paper</a>. For this reason, we refer to the standard error bound as the <em>worst-case standard error</em>.</p>
14016+
<p>It's impossible to improve the bound without further knowledge of the correlation structure: The bound turns out to equal the actual standard error when the three sample averages are perfectly correlated with each other. This is proved in Lemma 1 in <a href="https://arxiv.org/abs/2109.08109">our paper</a>. For this reason, we refer to the standard error bound as the <em>worst-case standard error</em>.</p>
1401614017
<h2 id="Numerical-example">Numerical example<a class="anchor-link" href="#Numerical-example">&#182;</a></h2><p>Our software package makes it easy to calculate worst-case standard errors. As an illustration, suppose the sample averages (with standard errors in parentheses) equal
1401714018
$$\hat{r}=0.02\;(0.002), \quad \widehat{\frac{I}{K}}=0.08\;(0.01), \quad \widehat{\frac{K}{Y}} = 3\;(0.1).$$
1401814019
We define the model equations and data as follows. Let $\theta=(\rho,\delta,\alpha)$ and $\mu=(r,\frac{I}{K},\frac{K}{Y})$ denote the vectors of parameters and moments, respectively.</p>
@@ -14146,10 +14147,10 @@ <h2 id="Over-identification-test">Over-identification test<a class="anchor-link"
1414614147
<div class="jp-RenderedText jp-OutputArea-output" data-mime-type="text/plain">
1414714148
<pre> pcost dcost gap pres dres k/t
1414814149
0: 1.0118e-29 1.0118e-29 1e-02 2e+00 0e+00 1e+00
14149-
1: -4.4391e-18 1.0118e-29 1e-04 2e-02 1e-17 1e-02
14150-
2: -8.6524e-20 1.0118e-29 1e-06 2e-04 2e-18 1e-04
14151-
3: -6.3766e-22 1.0118e-29 1e-08 2e-06 7e-18 1e-06
14152-
4: -5.9271e-24 1.0118e-29 1e-10 2e-08 2e-18 1e-08
14150+
1: -4.4391e-18 1.0118e-29 1e-04 2e-02 7e-18 1e-02
14151+
2: -7.3161e-20 1.0118e-29 1e-06 2e-04 3e-18 1e-04
14152+
3: -8.8737e-22 1.0118e-29 1e-08 2e-06 5e-18 1e-06
14153+
4: -9.2425e-24 1.0118e-29 1e-10 2e-08 7e-18 1e-08
1415314154
Optimal solution found.
1415414155
Error in matching non-targeted moment
1415514156
-0.09999999999999998
@@ -14170,7 +14171,7 @@ <h2 id="Over-identification-test">Over-identification test<a class="anchor-link"
1417014171
</div><div class="jp-RenderedHTMLCommon jp-RenderedMarkdown jp-MarkdownOutput " data-mime-type="text/markdown">
1417114172
<p>Since the absolute value of the t-statistic lies between 1.64 and 1.96, we can reject the validity of the model at the 10% significance level, but not at the 5% level.</p>
1417214173
<p>The over-identification test checks how different the estimate $\hat{\alpha}$ would have been if we had instead computed it as the sample average capital share of income $1-0.6=0.4$. Is the difference in parameter estimates between the two calibration strategies too large to be explained by statistical noise?</p>
14173-
<h2 id="Other-features-in-the-paper">Other features in the paper<a class="anchor-link" href="#Other-features-in-the-paper">&#182;</a></h2><p>The above NGM example is very simple and stylized. In <a href="https://scholar.princeton.edu/mikkelpm/calibration">our paper</a> we extend the basic ideas along various dimensions that are relevant for applied research. For example:</p>
14174+
<h2 id="Other-features-in-the-paper">Other features in the paper<a class="anchor-link" href="#Other-features-in-the-paper">&#182;</a></h2><p>The above NGM example is very simple and stylized. In <a href="https://arxiv.org/abs/2109.08109">our paper</a> we extend the basic ideas along various dimensions that are relevant for applied research. For example:</p>
1417414175
<ul>
1417514176
<li>The matched moments need not be simple sample averages, but could be regression coefficients, quantiles, etc. The moments need not be related to steady-state quantities, but could involve essentially any feature of the available data.</li>
1417614177
<li>The calibration (method-of-moments) estimator need not be available in closed form (usually one would obtain it by numerical optimization).</li>

example.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"We will estimate the parameters $(\\theta_1,\\theta_2)$ by minimum distance, matching the model-implied moments $h(\\theta_1,\\theta_2)$ to the empirical moments:\n",
1616
"$$\\hat{\\theta} = \\text{argmin}_{\\theta}\\; (\\hat{\\mu}-h(\\theta))'\\hat{W}(\\hat{\\mu}-h(\\theta)).$$\n",
1717
"\n",
18-
"To compute standard errors for the estimated parameters, test hypotheses, and compute the efficient weight matrix $\\hat{W}$, we use the formulas in [Cocci & Plagborg-Møller (2021)](https://scholar.princeton.edu/mikkelpm/calibration), which do not require knowledge of the correlation structure of the empirical moments.\n",
18+
"To compute standard errors for the estimated parameters, test hypotheses, and compute the efficient weight matrix $\\hat{W}$, we use the formulas in [Cocci & Plagborg-Møller (2023)](https://arxiv.org/abs/2109.08109), which do not require knowledge of the correlation structure of the empirical moments.\n",
1919
"\n",
2020
"## Define the model\n",
2121
"We first import relevant packages and define the model and data."
@@ -374,7 +374,7 @@
374374
"name": "python",
375375
"nbconvert_exporter": "python",
376376
"pygments_lexer": "ipython3",
377-
"version": "3.8.11"
377+
"version": "3.8.18"
378378
}
379379
},
380380
"nbformat": 4,

example_ngm.ipynb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"*We are grateful to Ben Moll for suggesting this example. Any errors are our own.*\n",
1111
"\n",
1212
"\n",
13-
"In this notebook we will work through the basic logic of [Cocci & Plagborg-Møller (2021)](https://scholar.princeton.edu/mikkelpm/calibration) in the context of calibrating a simple version of the Neoclassical Growth Model (NGM). Though the model is highly stylized, it helps provide intuition for our procedures. Please see our paper for other, arguably more realistic, empirical applications.\n",
13+
"In this notebook we will work through the basic logic of [Cocci & Plagborg-Møller (2023)](https://arxiv.org/abs/2109.08109) in the context of calibrating a simple version of the Neoclassical Growth Model (NGM). Though the model is highly stylized, it helps provide intuition for our procedures. Please see our paper for other, arguably more realistic, empirical applications.\n",
1414
"\n",
1515
"\n",
1616
"## Model\n",
@@ -68,7 +68,7 @@
6868
"$$\\hat{x}_1=\\hat{x}_2=\\widehat{\\frac{K}{Y}},\\quad \\hat{x}_3=\\left(\\hat{r}+\\widehat{\\frac{I}{K}} \\right).$$\n",
6969
"Notice that this upper bound only depends on things that we know: the sample averages themselves and their individual standard errors (but not the correlations across moments).\n",
7070
"\n",
71-
"It's impossible to improve the bound without further knowledge of the correlation structure: The bound turns out to equal the actual standard error when the three sample averages are perfectly correlated with each other. This is proved in Lemma 1 in [our paper](https://scholar.princeton.edu/mikkelpm/calibration). For this reason, we refer to the standard error bound as the *worst-case standard error*.\n",
71+
"It's impossible to improve the bound without further knowledge of the correlation structure: The bound turns out to equal the actual standard error when the three sample averages are perfectly correlated with each other. This is proved in Lemma 1 in [our paper](https://arxiv.org/abs/2109.08109). For this reason, we refer to the standard error bound as the *worst-case standard error*.\n",
7272
"\n",
7373
"\n",
7474
"## Numerical example\n",
@@ -176,7 +176,7 @@
176176
"\n",
177177
"## Other features in the paper\n",
178178
"\n",
179-
"The above NGM example is very simple and stylized. In [our paper](https://scholar.princeton.edu/mikkelpm/calibration) we extend the basic ideas along various dimensions that are relevant for applied research. For example:\n",
179+
"The above NGM example is very simple and stylized. In [our paper](https://arxiv.org/abs/2109.08109) we extend the basic ideas along various dimensions that are relevant for applied research. For example:\n",
180180
"- The matched moments need not be simple sample averages, but could be regression coefficients, quantiles, etc. The moments need not be related to steady-state quantities, but could involve essentially any feature of the available data.\n",
181181
"- The calibration (method-of-moments) estimator need not be available in closed form (usually one would obtain it by numerical optimization).\n",
182182
"- If some, but not all, of the correlations between the empirical moments are known, this can be exploited to sharpen inference.\n",
@@ -203,7 +203,7 @@
203203
"name": "python",
204204
"nbconvert_exporter": "python",
205205
"pygments_lexer": "ipython3",
206-
"version": "3.8.11"
206+
"version": "3.8.18"
207207
}
208208
},
209209
"nbformat": 4,

stderr_calibration/worstcase_se.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
1919
Reference:
2020
Cocci, Matthew D. & Mikkel Plagborg-Moller, "Standard Errors for Calibrated Parameters"
21-
https://scholar.princeton.edu/mikkelpm/calibration
21+
https://arxiv.org/abs/2109.08109
2222
"""
2323

2424

0 commit comments

Comments
 (0)