Skip to content

Commit

Permalink
update glm docs
Browse files Browse the repository at this point in the history
  • Loading branch information
s3alfisc committed Jan 4, 2025
1 parent 83a6f27 commit cacd42d
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 6 deletions.
5 changes: 5 additions & 0 deletions docs/_quarto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ quartodoc:
contents:
- estimation.estimation.feols
- estimation.estimation.fepois
- estimation.estimation.feglm
- did.estimation.did2s
- did.estimation.lpdid
- did.estimation.event_study
Expand All @@ -71,6 +72,10 @@ quartodoc:
- estimation.feols_.Feols
- estimation.fepois_.Fepois
- estimation.feiv_.Feiv
- estimation.feglm_.Feglm
- estimation.felogit_.Felogit
- estimation.feprobit_.Feprobit
- estimation.fegaussian_.Fegaussian
- estimation.feols_compressed_.FeolsCompressed
#- did.did.DID
#- did.did2s.DID2s
Expand Down
5 changes: 5 additions & 0 deletions docs/_sidebar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ website:
- contents:
- reference/estimation.estimation.feols.qmd
- reference/estimation.estimation.fepois.qmd
- reference/estimation.estimation.feglm.qmd
- reference/did.estimation.did2s.qmd
- reference/did.estimation.lpdid.qmd
- reference/did.estimation.event_study.qmd
Expand All @@ -15,6 +16,10 @@ website:
- reference/estimation.feols_.Feols.qmd
- reference/estimation.fepois_.Fepois.qmd
- reference/estimation.feiv_.Feiv.qmd
- reference/estimation.feglm_.Feglm.qmd
- reference/estimation.felogit_.Felogit.qmd
- reference/estimation.feprobit_.Feprobit.qmd
- reference/estimation.fegaussian_.Fegaussian.qmd
- reference/estimation.feols_compressed_.FeolsCompressed.qmd
section: Estimation Classes
- contents:
Expand Down
39 changes: 33 additions & 6 deletions pyfixest/estimation/estimation.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,8 +641,8 @@ def fepois(
fit = pf.fepois("Y ~ X1 + X2 | f1 + f2", data)
fit.summary()
```
For more examples, please take a look at the documentation of the `feols()`
function.
For more examples on the use of other function arguments, please take a look at the documentation of the [feols()](https://py-econometrics.github.io/pyfixest/reference/estimation.estimation.feols.html#pyfixest.estimation.estimation.feols) function.
"""
if separation_check is None:
separation_check = ["fe"]
Expand Down Expand Up @@ -859,13 +859,40 @@ def feglm(
```{python}
import pyfixest as pf
import numpy as np
data = pf.get_data(model = "Fepois")
fit = pf.fepois("Y ~ X1 + X2 | f1 + f2", data)
fit.summary()
data = pf.get_data()
data["Y"] = np.where(data["Y"] > 0, 1, 0)
data["f1"] = np.where(data["f1"] > data["f1"].median(), "group1", "group2")
fit_probit = pf.feglm("Y ~ X1*f1", data, family = "probit")
fit_logit = pf.feglm("Y ~ X1*f1", data, family = "logit")
fit_gaussian = pf.feglm("Y ~ X1*f1", data, family = "gaussian")
pf.etable([fit_probit, fit_logit, fit_gaussian])
```
`PyFixest` integrates with the [marginaleffects](https://marginaleffects.com/bonus/python.html) package. For example, to compute average marginal effects
for the probit model above, you can use the following code:
```{python}
# we load polars as marginaleffects outputs pl.DataFrame's
import polars as pl
from marginaleffects import avg_slopes
pl.concat([avg_slopes(model, variables = "X1") for model in [fit_probit, fit_logit, fit_gaussian]])
```
We can also compute marginal effects by group (group average marginal effects):
```{python}
avg_slopes(fit_probit, variables = "X1", by = "f1")
```
For more examples, please take a look at the documentation of the `feols()`
We find homogeneous effects by "f1" in the probit model.
For more examples of other function arguments, please take a look at the documentation of the [feols()](https://py-econometrics.github.io/pyfixest/reference/estimation.estimation.feols.html#pyfixest.estimation.estimation.feols)
function.
"""
if family not in ["logit", "probit", "gaussian"]:
raise ValueError(
Expand Down

0 comments on commit cacd42d

Please sign in to comment.