Skip to contents

Convenience wrapper that runs the full event study pipeline: prepare data, fit models, and calculate test statistics in a single call.

Usage

run_event_study(
  task,
  parameter_set = ParameterSet$new(),
  report = FALSE,
  report_args = list(),
  verbose = getOption("eventstudy.verbose", TRUE)
)

Arguments

task

An EventStudyTask object.

parameter_set

A ParameterSet object defining the event study. Defaults to a new ParameterSet with default settings.

report

Logical. When FALSE (default), the function behaves exactly as before this parameter was added. When TRUE, also renders a report via es_report() after the pipeline completes and attaches the rendered path(s) as attr(task, "report_path").

report_args

Named list forwarded to es_report() when report = TRUE. May include output_file, format, provider, and any other argument accepted by es_report(). Defaults to list() (uses es_report() defaults, which render "event_study_report.html" in the working directory).

verbose

Logical; if FALSE, suppress informational messages. Default getOption("eventstudy.verbose", TRUE).

Value

The task object with all results computed. When report = TRUE, the returned task additionally carries attr(task, "report_path") with the path(s) of the rendered report file(s). The return type is always a fitted EventStudyTask in both paths.

Examples

# \donttest{
data(dieselgate)
task <- EventStudyTask$new(dieselgate$firm, dieselgate$index, dieselgate$request)

# Run the pipeline and render a report to a temporary directory
out  <- file.path(tempdir(), "event_study_report.html")
task <- run_event_study(task, ParameterSet$new(), report = TRUE,
                        report_args = list(output_file = out))
#> Report mode: Offline rule-based narrative
#> Report generated: /tmp/RtmpE2WNJT/event_study_report.html
#> Report written to: /tmp/RtmpE2WNJT/event_study_report.html
attr(task, "report_path")  # path to the rendered HTML
#>                                      html 
#> "/tmp/RtmpE2WNJT/event_study_report.html" 
# }