---
title: "Quarto and PyFixest"
jupyter: python3
format:
  pdf:
    number-sections: true
    include-in-header:
      - text: |
          \usepackage{booktabs}
          \usepackage{makecell}
          \usepackage{threeparttable}
execute:
  echo: false
  warning: false
author:
- Peter Pan^[University of Neverland]
date: last-modified
abstract: |
 \
 \
  We study the effect of X1 and X2 on Y and Y2 using PyFixest. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
 \
 \
 **Keywords**: Regressions, PyFixest, Tables, Quarto
---

{{< pagebreak >}}

# Introduction

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet."

```{python}
#| echo: false
#| output: false
import  pandas as pd
import pyfixest as pf
data = pf.get_data()
fit1 = pf.feols("Y ~ X1 + X2 | f1", data = data)
fit2 = pf.feols("Y ~ X1 + X2 | f1 + f2", data = data)
fit3 = pf.feols("Y ~ X1 *X2 | f1 + f2", data = data)
fit4 = pf.feols("Y2 ~ X1 + X2 | f1", data = data)
fit5 = pf.feols("Y2 ~ X1 + X2 | f1 + f2", data = data)
fit6 = pf.feols("Y2 ~ X1 *X2 | f1 + f2", data = data)
labels={
    "Y": "Wage",
    "Y2": "Wealth",
    "X1": "Age",
    "X2": "Years of Schooling",
    "f1": "Industry",
    "f2": "Year"
}
```

# A PyFixest Regression Table
As @tbl-main shows, LaTex Tables generated by PyFixest can be easily integrated into Quarto document when rendered as pdf.

```{python}
#| label: tbl-main
#| tbl-cap: A PyFixest Regression Table
#| output: asis
#| echo: false
#| tbl-pos: H
mynotes="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet."
tab=pf.etable([fit1, fit2, fit4, fit5],
            labels=labels, notes=mynotes, type="tex",
            model_heads=["US", "China", "US", "China"])
print(tab)
```
