Skip to content

Commit

Permalink
Update robustness-check.ipynb
Browse files Browse the repository at this point in the history
  • Loading branch information
artamonoff committed May 19, 2024
1 parent d502cf6 commit 46cd929
Showing 1 changed file with 173 additions and 5 deletions.
178 changes: 173 additions & 5 deletions econometrica-1/jupyter-notebooks/robustness-check.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 58,189 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 2,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"(526, 24)"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df = pd.read_csv('wage1.csv')\n",
"df.shape"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Нас интересует влияние опыта работы `exper` на зарплату `wage`. Рассмотрим несколько моделей с `log(wage)` в качестве зависимой переменной\n",
"\n",
"Обратим внимание на значимость коэффициента при `exper` при разных стандартных уровнях значимости"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/html": [
"<table class=\"simpletable\">\n",
"<tr>\n",
" <td></td> <th>np.log(wage) I</th> <th>np.log(wage) II</th> <th>np.log(wage) III</th> <th>np.log(wage) IIII</th>\n",
"</tr>\n",
"<tr>\n",
" <th>Intercept</th> <td>1.7476***</td> <td>1.4381***</td> <td>1.5002***</td> <td>1.2881***</td> \n",
"</tr>\n",
"<tr>\n",
" <th></th> <td>(0.0398)</td> <td>(0.0605)</td> <td>(0.0483)</td> <td>(0.0615)</td> \n",
"</tr>\n",
"<tr>\n",
" <th>exper</th> <td>0.0038**</td> <td>0.0022</td> <td>0.0428***</td> <td>0.0378***</td> \n",
"</tr>\n",
"<tr>\n",
" <th></th> <td>(0.0016)</td> <td>(0.0015)</td> <td>(0.0053)</td> <td>(0.0055)</td> \n",
"</tr>\n",
"<tr>\n",
" <th>female</th> <td>-0.3930***</td> <td>-0.3652***</td> <td>-0.3796***</td> <td>-0.3680***</td> \n",
"</tr>\n",
"<tr>\n",
" <th></th> <td>(0.0425)</td> <td>(0.0405)</td> <td>(0.0406)</td> <td>(0.0390)</td> \n",
"</tr>\n",
"<tr>\n",
" <th>smsa</th> <td></td> <td>0.2553***</td> <td></td> <td>0.2454***</td> \n",
"</tr>\n",
"<tr>\n",
" <th></th> <td></td> <td>(0.0449)</td> <td></td> <td>(0.0443)</td> \n",
"</tr>\n",
"<tr>\n",
" <th>married</th> <td></td> <td>0.2419***</td> <td></td> <td>0.1456***</td> \n",
"</tr>\n",
"<tr>\n",
" <th></th> <td></td> <td>(0.0433)</td> <td></td> <td>(0.0440)</td> \n",
"</tr>\n",
"<tr>\n",
" <th>south</th> <td></td> <td>-0.0625</td> <td></td> <td>-0.0923**</td> \n",
"</tr>\n",
"<tr>\n",
" <th></th> <td></td> <td>(0.0438)</td> <td></td> <td>(0.0433)</td> \n",
"</tr>\n",
"<tr>\n",
" <th>west</th> <td></td> <td>0.0805</td> <td></td> <td>0.0586</td> \n",
"</tr>\n",
"<tr>\n",
" <th></th> <td></td> <td>(0.0648)</td> <td></td> <td>(0.0613)</td> \n",
"</tr>\n",
"<tr>\n",
" <th>I(exper ** 2)</th> <td></td> <td></td> <td>-0.0009***</td> <td>-0.0008***</td> \n",
"</tr>\n",
"<tr>\n",
" <th></th> <td></td> <td></td> <td>(0.0001)</td> <td>(0.0001)</td> \n",
"</tr>\n",
"<tr>\n",
" <th>R-squared</th> <td>0.1488</td> <td>0.2471</td> <td>0.2310</td> <td>0.3036</td> \n",
"</tr>\n",
"<tr>\n",
" <th>R-squared Adj.</th> <td>0.1456</td> <td>0.2384</td> <td>0.2266</td> <td>0.2942</td> \n",
"</tr>\n",
"</table><br/>\n",
"Standard errors in parentheses.<br/>\n",
"* p<.1, ** p<.05, ***p<.01"
],
"text/latex": [
"\\begin{table}\n",
"\\caption{}\n",
"\\label{}\n",
"\\begin{center}\n",
"\\begin{tabular}{lllll}\n",
"\\hline\n",
" & np.log(wage) I & np.log(wage) II & np.log(wage) III & np.log(wage) IIII \\\\\n",
"\\hline\n",
"Intercept & 1.7476*** & 1.4381*** & 1.5002*** & 1.2881*** \\\\\n",
" & (0.0398) & (0.0605) & (0.0483) & (0.0615) \\\\\n",
"exper & 0.0038** & 0.0022 & 0.0428*** & 0.0378*** \\\\\n",
" & (0.0016) & (0.0015) & (0.0053) & (0.0055) \\\\\n",
"female & -0.3930*** & -0.3652*** & -0.3796*** & -0.3680*** \\\\\n",
" & (0.0425) & (0.0405) & (0.0406) & (0.0390) \\\\\n",
"smsa & & 0.2553*** & & 0.2454*** \\\\\n",
" & & (0.0449) & & (0.0443) \\\\\n",
"married & & 0.2419*** & & 0.1456*** \\\\\n",
" & & (0.0433) & & (0.0440) \\\\\n",
"south & & -0.0625 & & -0.0923** \\\\\n",
" & & (0.0438) & & (0.0433) \\\\\n",
"west & & 0.0805 & & 0.0586 \\\\\n",
" & & (0.0648) & & (0.0613) \\\\\n",
"I(exper ** 2) & & & -0.0009*** & -0.0008*** \\\\\n",
" & & & (0.0001) & (0.0001) \\\\\n",
"R-squared & 0.1488 & 0.2471 & 0.2310 & 0.3036 \\\\\n",
"R-squared Adj. & 0.1456 & 0.2384 & 0.2266 & 0.2942 \\\\\n",
"\\hline\n",
"\\end{tabular}\n",
"\\end{center}\n",
"\\end{table}\n",
"\\bigskip\n",
"Standard errors in parentheses. \\newline \n",
"* p<.1, ** p<.05, ***p<.01"
],
"text/plain": [
"<class 'statsmodels.iolib.summary2.Summary'>\n",
"\"\"\"\n",
"\n",
"================================================================================\n",
" np.log(wage) I np.log(wage) II np.log(wage) III np.log(wage) IIII\n",
"--------------------------------------------------------------------------------\n",
"Intercept 1.7476*** 1.4381*** 1.5002*** 1.2881*** \n",
" (0.0398) (0.0605) (0.0483) (0.0615) \n",
"exper 0.0038** 0.0022 0.0428*** 0.0378*** \n",
" (0.0016) (0.0015) (0.0053) (0.0055) \n",
"female -0.3930*** -0.3652*** -0.3796*** -0.3680*** \n",
" (0.0425) (0.0405) (0.0406) (0.0390) \n",
"smsa 0.2553*** 0.2454*** \n",
" (0.0449) (0.0443) \n",
"married 0.2419*** 0.1456*** \n",
" (0.0433) (0.0440) \n",
"south -0.0625 -0.0923** \n",
" (0.0438) (0.0433) \n",
"west 0.0805 0.0586 \n",
" (0.0648) (0.0613) \n",
"I(exper ** 2) -0.0009*** -0.0008*** \n",
" (0.0001) (0.0001) \n",
"R-squared 0.1488 0.2471 0.2310 0.3036 \n",
"R-squared Adj. 0.1456 0.2384 0.2266 0.2942 \n",
"================================================================================\n",
"Standard errors in parentheses.\n",
"* p<.1, ** p<.05, ***p<.01\n",
"\"\"\""
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.describe()"
"formulas = ['np.log(wage)~1 exper female', \n",
"'np.log(wage)~1 exper female smsa married south west', \n",
"'np.log(wage)~1 exper female I(exper**2)', \n",
"'np.log(wage)~1 exper female smsa married south west I(exper**2)']\n",
"\n",
"mod = []\n",
"res = []\n",
"\n",
"for formula in formulas:\n",
"\tmod.append(smf.ols(formula, df))\n",
"\tres.append(mod[-1].fit(cov_type='HC3'))\n",
"\n",
"summary_col(res, stars=True)"
]
}
],
Expand Down

0 comments on commit 46cd929

Please sign in to comment.