---
title: "Attacking a Regression Claim"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Attacking a Regression Claim}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(collapse = TRUE, comment = "#>")
```

`falsifyr` attacks claims, not whole models. The core question is:

> What would it take to kill this result?

Start with an ordinary fitted model and a term.

```{r}
library(falsifyr)

fit <- lm(score ~ treatment + age + baseline_score, data = fragile_trial)
res <- attack(
  fit,
  term = "treatment",
  attacks = c("row_deletion", "missingness", "noise"),
  intensity = "fast",
  seed = 1
)

res
```

The headline is the smallest kill. In the attack table, `leaderboard_rank`
orders perturbations by lethality and kill distance.

```{r}
res$attacks[, c("leaderboard_rank", "attack_family", "attack_name", "status", "p_value", "explanation")]
```

A killed claim is fragile under that attack. It does not prove that the
original claim is false, and it does not say the perturbed analysis is
preferable.

Reports are static HTML files and can be written to temporary paths in
scripted workflows.

```{r}
report_file <- report(res, file = tempfile(fileext = ".html"))
basename(report_file)
```
