## Bisect: which package load makes vcov(fit_ardl) NA?
suppressPackageStartupMessages(library(tidyverse))
suppressPackageStartupMessages(library(lubridate))

approval <- read_csv("data/approval.csv", show_col_types = FALSE)
df <- approval |>
  mutate(date        = ym(paste(year, month, sep = "-")),
         oil         = avg.price,
         approve_lag = lag(approve, 1),
         oil_lag     = lag(oil, 1)) |>
  drop_na()

probe <- function(label) {
  fit <- lm(approve ~ approve_lag + oil + oil_lag + sept.oct.2001 + iraq.war,
            data = df)
  v <- tryCatch(vcov(fit), error = function(e) e$message)
  ok <- is.matrix(v) && all(is.finite(v))
  cat(sprintf("%-12s  vcov OK = %s   diag1 = %s\n",
              label, ok, if (ok) format(v[1,1], digits = 4) else as.character(v)))
}

probe("baseline")
suppressPackageStartupMessages(library(plm));        probe("+plm")
suppressPackageStartupMessages(library(fixest));     probe("+fixest")
suppressPackageStartupMessages(library(nlme));       probe("+nlme")
suppressPackageStartupMessages(library(lme4));       probe("+lme4")
suppressPackageStartupMessages(library(parameters));probe("+parameters")
suppressPackageStartupMessages(library(sandwich));   probe("+sandwich")
suppressPackageStartupMessages(library(lmtest));     probe("+lmtest")
suppressPackageStartupMessages(library(tseries));    probe("+tseries")
suppressPackageStartupMessages(library(MASS));       probe("+MASS")
suppressPackageStartupMessages(library(simcf));      probe("+simcf")
suppressPackageStartupMessages(library(ggdag));      probe("+ggdag")
suppressPackageStartupMessages(library(dagitty));    probe("+dagitty")
suppressPackageStartupMessages(library(patchwork));  probe("+patchwork")
suppressPackageStartupMessages(library(cowplot));    probe("+cowplot")
suppressPackageStartupMessages(library(kableExtra));probe("+kableExtra")
suppressPackageStartupMessages(library(texreg));     probe("+texreg")
