suppressPackageStartupMessages({
  library(tidyverse); library(fixest)
})
lag <- dplyr::lag

democracy <- read_csv("data/democracy.csv", show_col_types = FALSE) |>
  rename_with(tolower) |> mutate(ln_gdpw = log(gdpw))

fit_fe_ar <- democracy |>
  group_by(country) |> arrange(year) |>
  mutate(ln_gdpw_lag = lag(ln_gdpw)) |> ungroup() |>
  feols(ln_gdpw ~ ln_gdpw_lag + reg + edt | country,
        data = _, cluster = ~ country)

fe <- fixef(fit_fe_ar)
cat("class(fixef):\n"); print(class(fe))
cat("names:\n"); print(names(fe))
cat("structure of fe$country:\n"); print(str(fe$country))
cat("head names of fe$country:\n"); print(head(names(fe$country), 5))
cat("\nfocus_id = 61 (Mexico)\n")
cat("fe$country[\"61\"]:"); print(fe$country["61"])
cat("fe$country[as.character(61)]:"); print(fe$country[as.character(61)])
cat("fe$country[match(61, as.numeric(names(fe$country)))]:"); print(fe$country[match(61, as.numeric(names(fe$country)))])
