diff --git a/docs/compare-fixest-pyfixest.ipynb b/docs/compare-fixest-pyfixest.ipynb
index 4399a210..8da46ef1 100644
--- a/docs/compare-fixest-pyfixest.ipynb
+++ b/docs/compare-fixest-pyfixest.ipynb
@@ -16,7 +16,7 @@
},
{
"cell_type": "code",
- "execution_count": 53,
+ "execution_count": 79,
"metadata": {},
"outputs": [
{
@@ -48,7 +48,7 @@
"%autoreload 2\n",
"\n",
"# Get data using pyfixest\n",
- "data = pf.get_data(model=\"Feols\", N=1000)"
+ "data = pf.get_data(model=\"Feols\", N=10_000, seed = 99292)"
]
},
{
@@ -74,11 +74,15 @@
},
{
"cell_type": "code",
- "execution_count": 54,
+ "execution_count": 80,
"metadata": {},
"outputs": [],
"source": [
- "fit = pf.feols(\"Y ~ X1 + X2 | f1 + f2\", data = data, ssc = pf.ssc(adj = True, cluster_adj = False), vcov = \"iid\")"
+ "fit = pf.feols(\n",
+ " fml = \"Y ~ X1 + X2 | f1 + f2\",\n",
+ " data = data,\n",
+ " vcov = \"iid\"\n",
+ ")"
]
},
{
@@ -90,11 +94,16 @@
},
{
"cell_type": "code",
- "execution_count": 55,
+ "execution_count": 81,
"metadata": {},
"outputs": [],
"source": [
- "fit_weights = pf.feols(\"Y ~ X1 + X2 | f1 + f2\", data = data, weights = \"weights\", ssc = pf.ssc(adj = True, cluster_adj = False), vcov = \"iid\")"
+ "fit_weights = pf.feols(\n",
+ " fml = \"Y ~ X1 + X2 | f1 + f2\",\n",
+ " data = data,\n",
+ " weights = \"weights\",\n",
+ " vcov = \"iid\"\n",
+ ")"
]
},
{
@@ -106,7 +115,7 @@
},
{
"cell_type": "code",
- "execution_count": 56,
+ "execution_count": 82,
"metadata": {},
"outputs": [
{
@@ -125,7 +134,7 @@
" ro.Formula(\"Y ~ X1 + X2 | f1 + f2\"),\n",
" data=data,\n",
" vcov=\"iid\",\n",
- " ssc=fixest.ssc(True, \"none\", False, \"min\", \"min\", False),\n",
+ " ssc=fixest.ssc(True, \"none\", True, \"min\", \"min\", False),\n",
")\n",
"\n",
"r_fit_weights = fixest.feols(\n",
@@ -133,7 +142,7 @@
" data=data,\n",
" weights=ro.Formula(\"~weights\"),\n",
" vcov=\"iid\",\n",
- " ssc=fixest.ssc(True, \"none\", False, \"min\", \"min\", False),\n",
+ " ssc=fixest.ssc(True, \"none\", True, \"min\", \"min\", False),\n",
")"
]
},
@@ -146,17 +155,17 @@
},
{
"cell_type": "code",
- "execution_count": 57,
+ "execution_count": 83,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
- "array([[-3.46944695e-18, -2.62580214e-20],\n",
- " [-2.62580214e-20, 5.42101086e-20]])"
+ "array([[-7.04731412e-19, -3.34180967e-22],\n",
+ " [-3.34594558e-22, -1.38913403e-19]])"
]
},
- "execution_count": 57,
+ "execution_count": 83,
"metadata": {},
"output_type": "execute_result"
}
@@ -176,17 +185,17 @@
},
{
"cell_type": "code",
- "execution_count": 58,
+ "execution_count": 84,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
- "array([[ 0.00000000e+00, -1.60936260e-20],\n",
- " [-1.60936260e-20, -1.08420217e-19]])"
+ "array([[ 1.68051337e-18, -1.69406589e-21],\n",
+ " [-1.69406589e-21, -1.49077799e-19]])"
]
},
- "execution_count": 58,
+ "execution_count": 84,
"metadata": {},
"output_type": "execute_result"
}
@@ -204,31 +213,101 @@
},
{
"cell_type": "code",
- "execution_count": 59,
+ "execution_count": 85,
"metadata": {},
"outputs": [
{
- "name": "stdout",
- "output_type": "stream",
- "text": [
- " est1 est2\n",
- "------------ ----------------------- -----------------------\n",
- "depvar Y Y\n",
- "--------------------------------------------------------------\n",
- "X1 -0.924046*** (0.054373) -0.854266*** (0.054288)\n",
- "X2 -0.174107*** (0.014412) -0.164147*** (0.014849)\n",
- "--------------------------------------------------------------\n",
- "f2 x x\n",
- "f1 x x\n",
- "--------------------------------------------------------------\n",
- "R2 0.659044 -\n",
- "S.E. type iid iid\n",
- "Observations 997 997\n",
- "--------------------------------------------------------------\n",
- "Significance levels: * p < 0.05, ** p < 0.01, *** p < 0.001\n",
- "Format of coefficient cell:\n",
- "Coefficient (Std. Error)\n"
- ]
+ "data": {
+ "text/html": [
+ "\n",
+ "
\n",
+ " Significance levels: * p < 0.05, ** p < 0.01, *** p < 0.001. Format of coefficient cell:\n",
+ "Coefficient (Std. Error)\n",
+ " \n",
+ " \n",
+ " | \n",
+ " est1 | \n",
+ " est2 | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " depvar | \n",
+ " Y | \n",
+ " Y | \n",
+ "
\n",
+ " \n",
+ " X1 | \n",
+ " 0.112019*** (0.016947) | \n",
+ " 0.123687*** (0.016880) | \n",
+ "
\n",
+ " \n",
+ " X2 | \n",
+ " 0.732788*** (0.004595) | \n",
+ " 0.732244*** (0.004584) | \n",
+ "
\n",
+ " \n",
+ " f1 | \n",
+ " x | \n",
+ " x | \n",
+ "
\n",
+ " \n",
+ " f2 | \n",
+ " x | \n",
+ " x | \n",
+ "
\n",
+ " \n",
+ " R2 | \n",
+ " 0.774375 | \n",
+ " - | \n",
+ "
\n",
+ " \n",
+ " S.E. type | \n",
+ " iid | \n",
+ " iid | \n",
+ "
\n",
+ " \n",
+ " Observations | \n",
+ " 9997 | \n",
+ " 9997 | \n",
+ "
\n",
+ " \n",
+ "
\n"
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "execution_count": 85,
+ "metadata": {},
+ "output_type": "execute_result"
}
],
"source": [
@@ -237,7 +316,7 @@
},
{
"cell_type": "code",
- "execution_count": 60,
+ "execution_count": 86,
"metadata": {},
"outputs": [
{
@@ -282,20 +361,20 @@
" \n",
" 2 | \n",
" X1 | \n",
- " -0.924046*** (0.054373) | \n",
- " -0.854266*** (0.054288) | \n",
+ " 0.112019*** (0.016947) | \n",
+ " 0.123687*** (0.016880) | \n",
"
\n",
" \n",
" 3 | \n",
" X2 | \n",
- " -0.174107*** (0.014412) | \n",
- " -0.164147*** (0.014849) | \n",
+ " 0.732788*** (0.004595) | \n",
+ " 0.732244*** (0.004584) | \n",
"
\n",
" \n",
" 4 | \n",
" Fixed-Effects: | \n",
- " ----------------------- | \n",
- " ----------------------- | \n",
+ " ---------------------- | \n",
+ " ---------------------- | \n",
"
\n",
" \n",
" 5 | \n",
@@ -312,8 +391,8 @@
"
\n",
" 7 | \n",
" _______________ | \n",
- " _______________________ | \n",
- " _______________________ | \n",
+ " ______________________ | \n",
+ " ______________________ | \n",
"
\n",
" \n",
" 8 | \n",
@@ -324,42 +403,42 @@
"
\n",
" 9 | \n",
" Observations | \n",
- " 997 | \n",
- " 997 | \n",
+ " 9,997 | \n",
+ " 9,997 | \n",
"
\n",
" \n",
" 10 | \n",
" R2 | \n",
- " 0.65904 | \n",
- " 0.65208 | \n",
+ " 0.77438 | \n",
+ " 0.77526 | \n",
"
\n",
" \n",
" 11 | \n",
" Within R2 | \n",
- " 0.30263 | \n",
- " 0.26968 | \n",
+ " 0.71822 | \n",
+ " 0.71886 | \n",
"
\n",
" \n",
"\n",
""
],
"text/plain": [
- " 0 1 2\n",
- "0 Dependent Var.: Y Y\n",
- "1 \n",
- "2 X1 -0.924046*** (0.054373) -0.854266*** (0.054288)\n",
- "3 X2 -0.174107*** (0.014412) -0.164147*** (0.014849)\n",
- "4 Fixed-Effects: ----------------------- -----------------------\n",
- "5 f1 Yes Yes\n",
- "6 f2 Yes Yes\n",
- "7 _______________ _______________________ _______________________\n",
- "8 S.E. type IID IID\n",
- "9 Observations 997 997\n",
- "10 R2 0.65904 0.65208\n",
- "11 Within R2 0.30263 0.26968"
+ " 0 1 2\n",
+ "0 Dependent Var.: Y Y\n",
+ "1 \n",
+ "2 X1 0.112019*** (0.016947) 0.123687*** (0.016880)\n",
+ "3 X2 0.732788*** (0.004595) 0.732244*** (0.004584)\n",
+ "4 Fixed-Effects: ---------------------- ----------------------\n",
+ "5 f1 Yes Yes\n",
+ "6 f2 Yes Yes\n",
+ "7 _______________ ______________________ ______________________\n",
+ "8 S.E. type IID IID\n",
+ "9 Observations 9,997 9,997\n",
+ "10 R2 0.77438 0.77526\n",
+ "11 Within R2 0.71822 0.71886"
]
},
- "execution_count": 60,
+ "execution_count": 86,
"metadata": {},
"output_type": "execute_result"
}
@@ -384,17 +463,25 @@
},
{
"cell_type": "code",
- "execution_count": 61,
+ "execution_count": 87,
"metadata": {},
"outputs": [],
"source": [
- "fit = pf.feols(\"Y ~ X1 + X2 | f1 + f2\", data = data, ssc = pf.ssc(adj = True, cluster_adj = False), vcov = \"hetero\")\n",
- "fit_weights = pf.feols(\"Y ~ X1 + X2 | f1 + f2\", data = data, ssc = pf.ssc(adj = True, cluster_adj = False), vcov = \"hetero\", weights = \"weights\")"
+ "fit = pf.feols(\n",
+ " fml = \"Y ~ X1 + X2 | f1 + f2\", data = data,\n",
+ " vcov = \"hetero\"\n",
+ ")\n",
+ "fit_weights = pf.feols(\n",
+ " fml = \"Y ~ X1 + X2 | f1 + f2\",\n",
+ " data = data,\n",
+ " vcov = \"hetero\",\n",
+ " weights = \"weights\"\n",
+ ")"
]
},
{
"cell_type": "code",
- "execution_count": 62,
+ "execution_count": 88,
"metadata": {},
"outputs": [
{
@@ -413,7 +500,7 @@
" ro.Formula(\"Y ~ X1 + X2 | f1 + f2\"),\n",
" data=data,\n",
" vcov=\"hetero\",\n",
- " ssc=fixest.ssc(True, \"none\", False, \"min\", \"min\", False),\n",
+ " ssc=fixest.ssc(True, \"none\", True, \"min\", \"min\", False),\n",
")\n",
"\n",
"fit_weights_r = fixest.feols(\n",
@@ -421,7 +508,7 @@
" data=data,\n",
" weights=ro.Formula(\"~weights\"),\n",
" vcov=\"hetero\",\n",
- " ssc=fixest.ssc(True, \"none\", False, \"min\", \"min\", False),\n",
+ " ssc=fixest.ssc(True, \"none\", True, \"min\", \"min\", False),\n",
")"
]
},
@@ -434,17 +521,17 @@
},
{
"cell_type": "code",
- "execution_count": 63,
+ "execution_count": 89,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
- "array([[ 2.61539922e-14, 6.55185745e-14],\n",
- " [ 6.55185745e-14, -8.23562681e-15]])"
+ "array([[-1.61925594e-16, -2.13306719e-17],\n",
+ " [-2.13306719e-17, -5.39593869e-17]])"
]
},
- "execution_count": 63,
+ "execution_count": 89,
"metadata": {},
"output_type": "execute_result"
}
@@ -455,17 +542,17 @@
},
{
"cell_type": "code",
- "execution_count": 64,
+ "execution_count": 90,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
- "array([[7.61158497e-13, 3.29128177e-13],\n",
- " [3.29128177e-13, 9.55965450e-14]])"
+ "array([[-2.04968421e-16, -9.53780274e-18],\n",
+ " [-9.53780274e-18, -3.03136151e-17]])"
]
},
- "execution_count": 64,
+ "execution_count": 90,
"metadata": {},
"output_type": "execute_result"
}
@@ -476,31 +563,101 @@
},
{
"cell_type": "code",
- "execution_count": 65,
+ "execution_count": 91,
"metadata": {},
"outputs": [
{
- "name": "stdout",
- "output_type": "stream",
- "text": [
- " est1 est2\n",
- "------------ ----------------------- -----------------------\n",
- "depvar Y Y\n",
- "--------------------------------------------------------------\n",
- "X1 -0.924046*** (0.054704) -0.854266*** (0.063090)\n",
- "X2 -0.174107*** (0.015009) -0.164147*** (0.016769)\n",
- "--------------------------------------------------------------\n",
- "f2 x x\n",
- "f1 x x\n",
- "--------------------------------------------------------------\n",
- "R2 0.659044 -\n",
- "S.E. type hetero hetero\n",
- "Observations 997 997\n",
- "--------------------------------------------------------------\n",
- "Significance levels: * p < 0.05, ** p < 0.01, *** p < 0.001\n",
- "Format of coefficient cell:\n",
- "Coefficient (Std. Error)\n"
- ]
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ " Significance levels: * p < 0.05, ** p < 0.01, *** p < 0.001. Format of coefficient cell:\n",
+ "Coefficient (Std. Error)\n",
+ " \n",
+ " \n",
+ " | \n",
+ " est1 | \n",
+ " est2 | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " depvar | \n",
+ " Y | \n",
+ " Y | \n",
+ "
\n",
+ " \n",
+ " X1 | \n",
+ " 0.112019*** (0.017009) | \n",
+ " 0.123687*** (0.019361) | \n",
+ "
\n",
+ " \n",
+ " X2 | \n",
+ " 0.732788*** (0.004553) | \n",
+ " 0.732244*** (0.005140) | \n",
+ "
\n",
+ " \n",
+ " f1 | \n",
+ " x | \n",
+ " x | \n",
+ "
\n",
+ " \n",
+ " f2 | \n",
+ " x | \n",
+ " x | \n",
+ "
\n",
+ " \n",
+ " R2 | \n",
+ " 0.774375 | \n",
+ " - | \n",
+ "
\n",
+ " \n",
+ " S.E. type | \n",
+ " hetero | \n",
+ " hetero | \n",
+ "
\n",
+ " \n",
+ " Observations | \n",
+ " 9997 | \n",
+ " 9997 | \n",
+ "
\n",
+ " \n",
+ "
\n"
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "execution_count": 91,
+ "metadata": {},
+ "output_type": "execute_result"
}
],
"source": [
@@ -509,7 +666,7 @@
},
{
"cell_type": "code",
- "execution_count": 66,
+ "execution_count": 92,
"metadata": {},
"outputs": [
{
@@ -554,20 +711,20 @@
" \n",
" 2 | \n",
" X1 | \n",
- " -0.924046*** (0.054704) | \n",
- " -0.854266*** (0.063090) | \n",
+ " 0.112019*** (0.017009) | \n",
+ " 0.123687*** (0.019361) | \n",
"
\n",
" \n",
" 3 | \n",
" X2 | \n",
- " -0.174107*** (0.015009) | \n",
- " -0.164147*** (0.016769) | \n",
+ " 0.732788*** (0.004553) | \n",
+ " 0.732244*** (0.005140) | \n",
"
\n",
" \n",
" 4 | \n",
" Fixed-Effects: | \n",
- " ----------------------- | \n",
- " ----------------------- | \n",
+ " ---------------------- | \n",
+ " ---------------------- | \n",
"
\n",
" \n",
" 5 | \n",
@@ -584,54 +741,54 @@
"
\n",
" 7 | \n",
" _______________ | \n",
- " _______________________ | \n",
- " _______________________ | \n",
+ " ______________________ | \n",
+ " ______________________ | \n",
"
\n",
" \n",
" 8 | \n",
" S.E. type | \n",
- " Heteroskedasticity-rob. | \n",
- " Heteroskedasticity-rob. | \n",
+ " Heteroskedastici.-rob. | \n",
+ " Heteroskedastici.-rob. | \n",
"
\n",
" \n",
" 9 | \n",
" Observations | \n",
- " 997 | \n",
- " 997 | \n",
+ " 9,997 | \n",
+ " 9,997 | \n",
"
\n",
" \n",
" 10 | \n",
" R2 | \n",
- " 0.65904 | \n",
- " 0.65208 | \n",
+ " 0.77438 | \n",
+ " 0.77526 | \n",
"
\n",
" \n",
" 11 | \n",
" Within R2 | \n",
- " 0.30263 | \n",
- " 0.26968 | \n",
+ " 0.71822 | \n",
+ " 0.71886 | \n",
"
\n",
" \n",
"\n",
""
],
"text/plain": [
- " 0 1 2\n",
- "0 Dependent Var.: Y Y\n",
- "1 \n",
- "2 X1 -0.924046*** (0.054704) -0.854266*** (0.063090)\n",
- "3 X2 -0.174107*** (0.015009) -0.164147*** (0.016769)\n",
- "4 Fixed-Effects: ----------------------- -----------------------\n",
- "5 f1 Yes Yes\n",
- "6 f2 Yes Yes\n",
- "7 _______________ _______________________ _______________________\n",
- "8 S.E. type Heteroskedasticity-rob. Heteroskedasticity-rob.\n",
- "9 Observations 997 997\n",
- "10 R2 0.65904 0.65208\n",
- "11 Within R2 0.30263 0.26968"
+ " 0 1 2\n",
+ "0 Dependent Var.: Y Y\n",
+ "1 \n",
+ "2 X1 0.112019*** (0.017009) 0.123687*** (0.019361)\n",
+ "3 X2 0.732788*** (0.004553) 0.732244*** (0.005140)\n",
+ "4 Fixed-Effects: ---------------------- ----------------------\n",
+ "5 f1 Yes Yes\n",
+ "6 f2 Yes Yes\n",
+ "7 _______________ ______________________ ______________________\n",
+ "8 S.E. type Heteroskedastici.-rob. Heteroskedastici.-rob.\n",
+ "9 Observations 9,997 9,997\n",
+ "10 R2 0.77438 0.77526\n",
+ "11 Within R2 0.71822 0.71886"
]
},
- "execution_count": 66,
+ "execution_count": 92,
"metadata": {},
"output_type": "execute_result"
}
@@ -656,7 +813,7 @@
},
{
"cell_type": "code",
- "execution_count": 67,
+ "execution_count": 93,
"metadata": {},
"outputs": [
{
@@ -671,37 +828,46 @@
}
],
"source": [
- "fit = pf.feols(\"Y ~ X1 + X2 | f1 + f2\", data = data, ssc = pf.ssc(adj = True, cluster_adj = False), vcov = {\"CRV1\": \"f1\"})\n",
- "fit_weights = pf.feols(\"Y ~ X1 + X2 | f1 + f2\", data = data, ssc = pf.ssc(adj = True, cluster_adj = False), vcov = {\"CRV1\":\"f1\"}, weights = \"weights\")\n",
+ "fit = pf.feols(\n",
+ " fml = \"Y ~ X1 + X2 | f1 + f2\",\n",
+ " data = data,\n",
+ " vcov = {\"CRV1\": \"f1\"}\n",
+ ")\n",
+ "fit_weights = pf.feols(\n",
+ " fml = \"Y ~ X1 + X2 | f1 + f2\",\n",
+ " data = data,\n",
+ " vcov = {\"CRV1\":\"f1\"},\n",
+ " weights = \"weights\"\n",
+ ")\n",
"\n",
"fit_r = fixest.feols(\n",
" ro.Formula(\"Y ~ X1 + X2 | f1 + f2\"),\n",
" data=data,\n",
" vcov= ro.Formula(\"~f1\"),\n",
- " ssc=fixest.ssc(True, \"none\", False, \"min\", \"min\", False),\n",
+ " ssc=fixest.ssc(True, \"none\", True, \"min\", \"min\", False),\n",
")\n",
"fit_r_weights = fixest.feols(\n",
" ro.Formula(\"Y ~ X1 + X2 | f1 + f2\"),\n",
" data=data,\n",
" weights=ro.Formula(\"~weights\"),\n",
" vcov= ro.Formula(\"~f1\"),\n",
- " ssc=fixest.ssc(True, \"none\", False, \"min\", \"min\", False),\n",
+ " ssc=fixest.ssc(True, \"none\", True, \"min\", \"min\", False),\n",
")"
]
},
{
"cell_type": "code",
- "execution_count": 68,
+ "execution_count": 94,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
- "array([[-8.45259193e-13, 8.24642309e-15],\n",
- " [ 8.24642140e-15, -9.52734528e-15]])"
+ "array([[ 4.20345182e-16, -6.97387636e-17],\n",
+ " [-6.97404577e-17, -1.42166010e-17]])"
]
},
- "execution_count": 68,
+ "execution_count": 94,
"metadata": {},
"output_type": "execute_result"
}
@@ -712,17 +878,17 @@
},
{
"cell_type": "code",
- "execution_count": 69,
+ "execution_count": 95,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
- "array([[-2.75502512e-04, 7.09991484e-05],\n",
- " [ 7.09991484e-05, 2.83672348e-06]])"
+ "array([[-3.95318402e-05, 2.05473422e-05],\n",
+ " [ 2.05473422e-05, 1.13249200e-06]])"
]
},
- "execution_count": 69,
+ "execution_count": 95,
"metadata": {},
"output_type": "execute_result"
}
@@ -733,31 +899,101 @@
},
{
"cell_type": "code",
- "execution_count": 70,
+ "execution_count": 96,
"metadata": {},
"outputs": [
{
- "name": "stdout",
- "output_type": "stream",
- "text": [
- " est1 est2\n",
- "------------ ----------------------- -----------------------\n",
- "depvar Y Y\n",
- "--------------------------------------------------------------\n",
- "X1 -0.924046*** (0.059910) -0.854266*** (0.060868)\n",
- "X2 -0.174107*** (0.014363) -0.164147*** (0.016854)\n",
- "--------------------------------------------------------------\n",
- "f2 x x\n",
- "f1 x x\n",
- "--------------------------------------------------------------\n",
- "R2 0.659044 -\n",
- "S.E. type by: f1 by: f1\n",
- "Observations 997 997\n",
- "--------------------------------------------------------------\n",
- "Significance levels: * p < 0.05, ** p < 0.01, *** p < 0.001\n",
- "Format of coefficient cell:\n",
- "Coefficient (Std. Error)\n"
- ]
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ " Significance levels: * p < 0.05, ** p < 0.01, *** p < 0.001. Format of coefficient cell:\n",
+ "Coefficient (Std. Error)\n",
+ " \n",
+ " \n",
+ " | \n",
+ " est1 | \n",
+ " est2 | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " depvar | \n",
+ " Y | \n",
+ " Y | \n",
+ "
\n",
+ " \n",
+ " X1 | \n",
+ " 0.112019*** (0.015816) | \n",
+ " 0.123687*** (0.018311) | \n",
+ "
\n",
+ " \n",
+ " X2 | \n",
+ " 0.732788*** (0.004476) | \n",
+ " 0.732244*** (0.005249) | \n",
+ "
\n",
+ " \n",
+ " f1 | \n",
+ " x | \n",
+ " x | \n",
+ "
\n",
+ " \n",
+ " f2 | \n",
+ " x | \n",
+ " x | \n",
+ "
\n",
+ " \n",
+ " R2 | \n",
+ " 0.774375 | \n",
+ " - | \n",
+ "
\n",
+ " \n",
+ " S.E. type | \n",
+ " by: f1 | \n",
+ " by: f1 | \n",
+ "
\n",
+ " \n",
+ " Observations | \n",
+ " 9997 | \n",
+ " 9997 | \n",
+ "
\n",
+ " \n",
+ "
\n"
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "execution_count": 96,
+ "metadata": {},
+ "output_type": "execute_result"
}
],
"source": [
@@ -766,7 +1002,7 @@
},
{
"cell_type": "code",
- "execution_count": 71,
+ "execution_count": 97,
"metadata": {},
"outputs": [
{
@@ -811,20 +1047,20 @@
" \n",
" 2 | \n",
" X1 | \n",
- " -0.924046*** (0.059910) | \n",
- " -0.854266*** (0.060868) | \n",
+ " 0.112019*** (0.015816) | \n",
+ " 0.123687*** (0.018311) | \n",
"
\n",
" \n",
" 3 | \n",
" X2 | \n",
- " -0.174107*** (0.014363) | \n",
- " -0.164147*** (0.016854) | \n",
+ " 0.732788*** (0.004476) | \n",
+ " 0.732244*** (0.005249) | \n",
"
\n",
" \n",
" 4 | \n",
" Fixed-Effects: | \n",
- " ----------------------- | \n",
- " ----------------------- | \n",
+ " ---------------------- | \n",
+ " ---------------------- | \n",
"
\n",
" \n",
" 5 | \n",
@@ -841,8 +1077,8 @@
"
\n",
" 7 | \n",
" _______________ | \n",
- " _______________________ | \n",
- " _______________________ | \n",
+ " ______________________ | \n",
+ " ______________________ | \n",
"
\n",
" \n",
" 8 | \n",
@@ -853,42 +1089,42 @@
"
\n",
" 9 | \n",
" Observations | \n",
- " 997 | \n",
- " 997 | \n",
+ " 9,997 | \n",
+ " 9,997 | \n",
"
\n",
" \n",
" 10 | \n",
" R2 | \n",
- " 0.65904 | \n",
- " 0.65208 | \n",
+ " 0.77438 | \n",
+ " 0.77526 | \n",
"
\n",
" \n",
" 11 | \n",
" Within R2 | \n",
- " 0.30263 | \n",
- " 0.26968 | \n",
+ " 0.71822 | \n",
+ " 0.71886 | \n",
"
\n",
" \n",
"\n",
""
],
"text/plain": [
- " 0 1 2\n",
- "0 Dependent Var.: Y Y\n",
- "1 \n",
- "2 X1 -0.924046*** (0.059910) -0.854266*** (0.060868)\n",
- "3 X2 -0.174107*** (0.014363) -0.164147*** (0.016854)\n",
- "4 Fixed-Effects: ----------------------- -----------------------\n",
- "5 f1 Yes Yes\n",
- "6 f2 Yes Yes\n",
- "7 _______________ _______________________ _______________________\n",
- "8 S.E.: Clustered by: f1 by: f1\n",
- "9 Observations 997 997\n",
- "10 R2 0.65904 0.65208\n",
- "11 Within R2 0.30263 0.26968"
+ " 0 1 2\n",
+ "0 Dependent Var.: Y Y\n",
+ "1 \n",
+ "2 X1 0.112019*** (0.015816) 0.123687*** (0.018311)\n",
+ "3 X2 0.732788*** (0.004476) 0.732244*** (0.005249)\n",
+ "4 Fixed-Effects: ---------------------- ----------------------\n",
+ "5 f1 Yes Yes\n",
+ "6 f2 Yes Yes\n",
+ "7 _______________ ______________________ ______________________\n",
+ "8 S.E.: Clustered by: f1 by: f1\n",
+ "9 Observations 9,997 9,997\n",
+ "10 R2 0.77438 0.77526\n",
+ "11 Within R2 0.71822 0.71886"
]
},
- "execution_count": 71,
+ "execution_count": 97,
"metadata": {},
"output_type": "execute_result"
}
@@ -906,7 +1142,7 @@
},
{
"cell_type": "code",
- "execution_count": 72,
+ "execution_count": 98,
"metadata": {},
"outputs": [],
"source": [
@@ -915,7 +1151,7 @@
},
{
"cell_type": "code",
- "execution_count": 73,
+ "execution_count": 99,
"metadata": {},
"outputs": [
{
@@ -932,35 +1168,49 @@
}
],
"source": [
- "fit_iid = pf.fepois(\"Y ~ X1 + X2 | f1 + f2\", data = data, ssc = pf.ssc(adj = True, cluster_adj = False), vcov = \"iid\", iwls_tol = 1e-10)\n",
- "fit_hetero = pf.fepois(\"Y ~ X1 + X2 | f1 + f2\", data = data, ssc = pf.ssc(adj = True, cluster_adj = False), vcov = \"hetero\", iwls_tol = 1e-10)\n",
- "fit_crv = pf.fepois(\"Y ~ X1 + X2 | f1 + f2\", data = data, ssc = pf.ssc(adj = True, cluster_adj = False), vcov = {\"CRV1\":\"f1\"}, iwls_tol = 1e-10)\n",
+ "fit_iid = pf.fepois(\n",
+ " fml = \"Y ~ X1 + X2 | f1 + f2\",\n",
+ " data = data,\n",
+ " vcov = \"iid\",\n",
+ " iwls_tol = 1e-10\n",
+ ")\n",
+ "fit_hetero = pf.fepois(\n",
+ " fml = \"Y ~ X1 + X2 | f1 + f2\", data = data,\n",
+ " vcov = \"hetero\",\n",
+ " iwls_tol = 1e-10\n",
+ ")\n",
+ "fit_crv = pf.fepois(\n",
+ " fml = \"Y ~ X1 + X2 | f1 + f2\",\n",
+ " data = data,\n",
+ " vcov = {\"CRV1\":\"f1\"},\n",
+ " iwls_tol = 1e-10\n",
+ ")\n",
"\n",
"fit_r_iid = fixest.fepois(\n",
" ro.Formula(\"Y ~ X1 + X2 | f1 + f2\"),\n",
" data=data,\n",
" vcov=\"iid\",\n",
- " ssc=fixest.ssc(True, \"none\", False, \"min\", \"min\", False),\n",
+ " ssc=fixest.ssc(True, \"none\", True, \"min\", \"min\", False),\n",
")\n",
"\n",
"fit_r_hetero = fixest.fepois(\n",
" ro.Formula(\"Y ~ X1 + X2 | f1 + f2\"),\n",
" data=data,\n",
" vcov=\"hetero\",\n",
- " ssc=fixest.ssc(True, \"none\", False, \"min\", \"min\", False),\n",
+ " ssc=fixest.ssc(True, \"none\", True, \"min\", \"min\", False),\n",
")\n",
"\n",
"fit_r_crv = fixest.fepois(\n",
" ro.Formula(\"Y ~ X1 + X2 | f1 + f2\"),\n",
" data=data,\n",
" vcov=ro.Formula(\"~f1\"),\n",
- " ssc=fixest.ssc(True, \"none\", False, \"min\", \"min\", False),\n",
+ " ssc=fixest.ssc(True, \"none\", True, \"min\", \"min\", False),\n",
")"
]
},
{
"cell_type": "code",
- "execution_count": 74,
+ "execution_count": 100,
"metadata": {},
"outputs": [
{
@@ -970,7 +1220,7 @@
" [-6.55604931e-10, 1.69958097e-09]])"
]
},
- "execution_count": 74,
+ "execution_count": 100,
"metadata": {},
"output_type": "execute_result"
}
@@ -981,17 +1231,17 @@
},
{
"cell_type": "code",
- "execution_count": 75,
+ "execution_count": 101,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
- "array([[ 2.17883089e-08, -7.37971037e-10],\n",
- " [-7.37971037e-10, 3.07279240e-09]])"
+ "array([[ 2.18101847e-08, -7.38711972e-10],\n",
+ " [-7.38711972e-10, 3.07587753e-09]])"
]
},
- "execution_count": 75,
+ "execution_count": 101,
"metadata": {},
"output_type": "execute_result"
}
@@ -1002,17 +1252,17 @@
},
{
"cell_type": "code",
- "execution_count": 76,
+ "execution_count": 102,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
- "array([[ 1.53194424e-08, -1.16909821e-10],\n",
- " [-1.16909821e-10, 3.07270399e-09]])"
+ "array([[ 1.58300904e-08, -1.20806815e-10],\n",
+ " [-1.20806815e-10, 3.17512746e-09]])"
]
},
- "execution_count": 76,
+ "execution_count": 102,
"metadata": {},
"output_type": "execute_result"
}
@@ -1023,31 +1273,110 @@
},
{
"cell_type": "code",
- "execution_count": 77,
+ "execution_count": 103,
"metadata": {},
"outputs": [
{
- "name": "stdout",
- "output_type": "stream",
- "text": [
- " est1 est2 est3\n",
- "------------ -------------------- -------------------- --------------------\n",
- "depvar Y Y Y\n",
- "------------------------------------------------------------------------------\n",
- "X1 -0.006591 (0.040758) -0.006591 (0.039125) -0.006591 (0.034180)\n",
- "X2 -0.014924 (0.010994) -0.014924 (0.010496) -0.014924 (0.010135)\n",
- "------------------------------------------------------------------------------\n",
- "f2 x x x\n",
- "f1 x x x\n",
- "------------------------------------------------------------------------------\n",
- "R2 - - -\n",
- "S.E. type iid hetero by: f1\n",
- "Observations 997 997 997\n",
- "------------------------------------------------------------------------------\n",
- "Significance levels: * p < 0.05, ** p < 0.01, *** p < 0.001\n",
- "Format of coefficient cell:\n",
- "Coefficient (Std. Error)\n"
- ]
+ "data": {
+ "text/html": [
+ "\n",
+ "\n",
+ " Significance levels: * p < 0.05, ** p < 0.01, *** p < 0.001. Format of coefficient cell:\n",
+ "Coefficient (Std. Error)\n",
+ " \n",
+ " \n",
+ " | \n",
+ " est1 | \n",
+ " est2 | \n",
+ " est3 | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " depvar | \n",
+ " Y | \n",
+ " Y | \n",
+ " Y | \n",
+ "
\n",
+ " \n",
+ " X1 | \n",
+ " -0.006591 (0.040758) | \n",
+ " -0.006591 (0.039145) | \n",
+ " -0.006591 (0.034745) | \n",
+ "
\n",
+ " \n",
+ " X2 | \n",
+ " -0.014924 (0.010994) | \n",
+ " -0.014924 (0.010501) | \n",
+ " -0.014924 (0.010303) | \n",
+ "
\n",
+ " \n",
+ " f1 | \n",
+ " x | \n",
+ " x | \n",
+ " x | \n",
+ "
\n",
+ " \n",
+ " f2 | \n",
+ " x | \n",
+ " x | \n",
+ " x | \n",
+ "
\n",
+ " \n",
+ " R2 | \n",
+ " - | \n",
+ " - | \n",
+ " - | \n",
+ "
\n",
+ " \n",
+ " S.E. type | \n",
+ " iid | \n",
+ " hetero | \n",
+ " by: f1 | \n",
+ "
\n",
+ " \n",
+ " Observations | \n",
+ " 997 | \n",
+ " 997 | \n",
+ " 997 | \n",
+ "
\n",
+ " \n",
+ "
\n"
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "execution_count": 103,
+ "metadata": {},
+ "output_type": "execute_result"
}
],
"source": [
@@ -1056,7 +1385,7 @@
},
{
"cell_type": "code",
- "execution_count": 78,
+ "execution_count": 104,
"metadata": {},
"outputs": [
{
@@ -1105,15 +1434,15 @@
" 2 | \n",
" X1 | \n",
" -0.006591 (0.040758) | \n",
- " -0.006591 (0.039125) | \n",
- " -0.006591 (0.034180) | \n",
+ " -0.006591 (0.039145) | \n",
+ " -0.006591 (0.034745) | \n",
" \n",
" \n",
" 3 | \n",
" X2 | \n",
" -0.014924 (0.010994) | \n",
- " -0.014924 (0.010496) | \n",
- " -0.014924 (0.010135) | \n",
+ " -0.014924 (0.010501) | \n",
+ " -0.014924 (0.010302) | \n",
"
\n",
" \n",
" 4 | \n",
@@ -1186,8 +1515,8 @@
" 0 1 2 \\\n",
"0 Dependent Var.: Y Y \n",
"1 \n",
- "2 X1 -0.006591 (0.040758) -0.006591 (0.039125) \n",
- "3 X2 -0.014924 (0.010994) -0.014924 (0.010496) \n",
+ "2 X1 -0.006591 (0.040758) -0.006591 (0.039145) \n",
+ "3 X2 -0.014924 (0.010994) -0.014924 (0.010501) \n",
"4 Fixed-Effects: -------------------- -------------------- \n",
"5 f1 Yes Yes \n",
"6 f2 Yes Yes \n",
@@ -1201,8 +1530,8 @@
" 3 \n",
"0 Y \n",
"1 \n",
- "2 -0.006591 (0.034180) \n",
- "3 -0.014924 (0.010135) \n",
+ "2 -0.006591 (0.034745) \n",
+ "3 -0.014924 (0.010302) \n",
"4 -------------------- \n",
"5 Yes \n",
"6 Yes \n",
@@ -1214,7 +1543,7 @@
"12 2,934.7 "
]
},
- "execution_count": 78,
+ "execution_count": 104,
"metadata": {},
"output_type": "execute_result"
}
@@ -1222,13 +1551,6 @@
"source": [
"pd.DataFrame(fixest.etable(fit_r_iid, fit_r_hetero, fit_r_crv, digits = 6)).T"
]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": []
}
],
"metadata": {