Renders an automated report from a completed event study task in one or more
output formats. Uses a bundled RMarkdown template with configurable sections.
The narrative is assembled ONCE before the format loop – es_advise is
never called per format (NARR-01).
Usage
generate_report(
task,
output_file = "event_study_report.html",
format = "html",
title = "Event Study Report",
author = NULL,
sections = c("exec_summary", "data_methods", "results", "diagnostics", "robustness",
"references"),
cross_sectional = NULL,
confidence_level = 0.95,
interactive = TRUE,
advice = NULL,
narrative = NULL,
provider = NULL,
verbose = getOption("eventstudy.verbose", TRUE),
...
)Arguments
- task
A fitted
EventStudyTaskorPanelEventStudyTask.- output_file
Output file path (extension overridden per format). Default
"event_study_report.html".- format
Character vector of output formats, any subset of
c("html", "pdf", "word", "md"). Default"html". Multiple formats render one file per format sharing a common basename. Missing optional toolchains emit onemessage()each and are skipped; only inability to render HTML raisesstop().- title
Report title string.
Author name (optional, default
"").- sections
Character vector of sections to include. Default is all six fixed sections:
c("exec_summary","data_methods","results","diagnostics","robustness","references").- cross_sectional
Optional cross-sectional regression results to include.
- confidence_level
Confidence level for plots. Default 0.95.
- interactive
Logical. Use interactive plotly plots in HTML output. Default TRUE.
- advice
An optional grounded
Adviceobject returned byes_advise(task_type = "report_writing"). When supplied and valid, renders an AI Advisor Interpretation section. A supplied but invalidadviceis silently coerced toNULLwith onewarning()– the report is never broken.- narrative
An optional named list keyed by section (e.g.
list(exec_summary = "...", data_methods = "...", results = "...", robustness = "...")), typically fromassemble_report_narrative(). WhenNULL(default), the render output is byte-identical to the v0.63.x baseline. A supplied but invalidnarrativeis silently coerced toNULLwith onewarning().- provider
Optional LLM provider passed to
assemble_report_narrative()whennarrativeisNULL. If bothproviderandnarrativeareNULL, a fully offline narrative is assembled. Ignored when a pre-builtnarrativelist is supplied by the caller.- verbose
Logical; if FALSE, suppress informational messages. Default
getOption("eventstudy.verbose", TRUE).- ...
Additional arguments passed to
rmarkdown::render.
Value
A named character vector of output file paths, invisibly, keyed by
format name (e.g. c(html = "/tmp/report.html", pdf = "/tmp/report.pdf")).
A single-format call returns a length-1 named vector: result[["html"]]
and result[[1L]] both resolve (backward-compatible with prior
single-path callers).
See also
Other eventstudy-export:
es_report(),
export_results(),
tidy.EventStudyTask()
Examples
# \donttest{
data(dieselgate)
task <- EventStudyTask$new(dieselgate$firm, dieselgate$index, dieselgate$request)
task <- run_event_study(task, ParameterSet$new())
# Single HTML format written to a temporary directory
out <- file.path(tempdir(), "event_study_report.html")
path <- generate_report(task, output_file = out, format = "html")
#> Report mode: Offline rule-based narrative
#> Report generated: /tmp/RtmpE2WNJT/event_study_report.html
path[["html"]]
#> [1] "/tmp/RtmpE2WNJT/event_study_report.html"
# }
