Skip to content

Commit

Permalink
BUG/DOC: add missing micro parts for Petrin tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffgortmaker committed Feb 16, 2023
1 parent 16b5ddc commit bee963a
Showing 1 changed file with 40 additions and 30 deletions.
70 changes: 40 additions & 30 deletions docs/notebooks/tutorial/petrin.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
{
"cell_type": "code",
"execution_count": 34,
"execution_count": 1,
"id": "46118395",
"metadata": {},
"outputs": [
Expand All @@ -32,7 +32,7 @@
"'0.13.0'"
]
},
"execution_count": 34,
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -303,7 +303,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 3,
"id": "06a6f43e",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -456,7 +456,7 @@
"4 0.707514 2.450663 34.397295 0 0 1 2 1 "
]
},
"execution_count": 6,
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -480,7 +480,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 4,
"id": "281e3283",
"metadata": {},
"outputs": [
Expand All @@ -492,7 +492,7 @@
" 1 + log(hpwt) + log(wt) + log(mpg) + air + fwd + trend + jp + eu + trend:jp + trend:eu + log(q))"
]
},
"execution_count": 7,
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -518,7 +518,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 5,
"id": "f059f23b",
"metadata": {},
"outputs": [
Expand All @@ -528,7 +528,7 @@
"1 + I(low / income) + I(mid / income) + I(high / income) + I(log(fs) * fv) + age + fs + mid + high"
]
},
"execution_count": 10,
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -548,7 +548,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 6,
"id": "862bdbdb",
"metadata": {},
"outputs": [
Expand All @@ -573,7 +573,7 @@
"=============================================================================================================================================="
]
},
"execution_count": 11,
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -624,7 +624,7 @@
},
{
"cell_type": "code",
"execution_count": 21,
"execution_count": 7,
"id": "878bbae6",
"metadata": {},
"outputs": [
Expand All @@ -634,7 +634,7 @@
"CEX: 29125 Observations in All Markets"
]
},
"execution_count": 21,
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -662,7 +662,7 @@
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": 8,
"id": "0ae456a1",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -749,7 +749,7 @@
"E[new | high] 0.1581"
]
},
"execution_count": 22,
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -773,7 +773,7 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 9,
"id": "e377d87f",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -830,7 +830,7 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 10,
"id": "3c4dd5b1",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -867,7 +867,7 @@
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": 11,
"id": "f3cca7b2",
"metadata": {},
"outputs": [],
Expand All @@ -881,6 +881,16 @@
" name=\"E[1{j > 0} * high_i]\",\n",
" dataset=micro_dataset, \n",
" compute_values=lambda t, p, a: np.outer(a.demographics[:, 8], np.r_[0, p.X2[:, 0]]),\n",
")\n",
"mid_part = pyblp.MicroPart(\n",
" name=\"E[mid_i]\",\n",
" dataset=micro_dataset,\n",
" compute_values=lambda t, p, a: np.outer(a.demographics[:, 7], np.r_[1, p.X2[:, 0]]),\n",
")\n",
"high_part = pyblp.MicroPart(\n",
" name=\"E[high_i]\",\n",
" dataset=micro_dataset,\n",
" compute_values=lambda t, p, a: np.outer(a.demographics[:, 8], np.r_[1, p.X2[:, 0]]),\n",
")"
]
},
Expand All @@ -896,7 +906,7 @@
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": 12,
"id": "aa4d08b4",
"metadata": {},
"outputs": [],
Expand All @@ -915,7 +925,7 @@
},
{
"cell_type": "code",
"execution_count": 27,
"execution_count": 13,
"id": "bfed6012",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -1006,7 +1016,7 @@
},
{
"cell_type": "code",
"execution_count": 28,
"execution_count": 14,
"id": "6e390ca3",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -1037,7 +1047,7 @@
},
{
"cell_type": "code",
"execution_count": 31,
"execution_count": 15,
"id": "df67dc3c",
"metadata": {},
"outputs": [
Expand All @@ -1049,15 +1059,15 @@
"GMM Objective Gradient Hessian Hessian Clipped Weighting Matrix Covariance Matrix\n",
"Step Value Norm Min Eigenvalue Max Eigenvalue Shares Condition Number Condition Number \n",
"---- --------- -------- -------------- -------------- ------- ---------------- -----------------\n",
" 2 +1.8E+02 +4.4E-05 +4.3E-01 +1.3E+03 0 +2.8E+11 +8.1E+07 \n",
" 2 +1.8E+02 +4.3E-05 +4.4E-01 +1.3E+03 0 +2.8E+11 +8.1E+07 \n",
"=======================================================================================================\n",
"\n",
"Cumulative Statistics:\n",
"===========================================================================\n",
"Computation Optimizer Optimization Objective Fixed Point Contraction\n",
" Time Converged Iterations Evaluations Iterations Evaluations\n",
"----------- --------- ------------ ----------- ----------- -----------\n",
" 00:20:22 Yes 72 87 10899 33588 \n",
" 00:20:41 Yes 72 87 10904 33599 \n",
"===========================================================================\n",
"\n",
"Nonlinear Coefficient Estimates (Robust SEs Adjusted for 898 Clusters in Parentheses):\n",
Expand Down Expand Up @@ -1141,7 +1151,7 @@
"==========================================================================================================="
]
},
"execution_count": 31,
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -1181,7 +1191,7 @@
},
{
"cell_type": "code",
"execution_count": 35,
"execution_count": 16,
"id": "7db17fa8",
"metadata": {},
"outputs": [],
Expand All @@ -1200,7 +1210,7 @@
},
{
"cell_type": "code",
"execution_count": 43,
"execution_count": 17,
"id": "0c3822e0",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -1230,7 +1240,7 @@
},
{
"cell_type": "code",
"execution_count": 44,
"execution_count": 18,
"id": "0c6c0749",
"metadata": {},
"outputs": [],
Expand All @@ -1248,17 +1258,17 @@
},
{
"cell_type": "code",
"execution_count": 45,
"execution_count": 19,
"id": "b4d00395",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[425.90823299]])"
"array([[425.90825406]])"
]
},
"execution_count": 45,
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
Expand Down

0 comments on commit bee963a

Please sign in to comment.