Understanding Automatic Diagnostics
Source:vignettes/automatic-diagnostics.Rmd
automatic-diagnostics.Rmdeventsurvey() and eventsurvey_summary()
automatically check features of the data and design that deserve
attention. The checks help users notice calendar gaps, small period
samples, pooled variance substitutions, limited pre-event information,
and windows that cover longer calendar spans than the requested number
of observed periods.
Each check is labeled OK or Review. A
Review status is not an error and does not change the
estimate. It asks the analyst to confirm that the data and design are
appropriate for the application.
All estimation examples below use estimand-specific calibration. ## The five checks
| Check |
Review is shown when |
Suggested response |
|---|---|---|
| Calendar coverage | One or more calendar periods are unobserved in the analysis span | Confirm that schedule = "observed" matches
the design, or use schedule = "consecutive" when
uninterrupted calendar periods are required. Do not create outcomes for
dates with no respondents. |
| Responses per period | Any observed period contains fewer than 10 responses | Inspect the affected period means and interpret them cautiously. The threshold is a prompt for review, not a universal minimum sample-size rule. |
| Variance information | A period-specific variance is unavailable | Review the affected periods. The package substitutes the pooled within-period variance for uncertainty calculations; it does not create outcomes. |
| Reference windows | Fewer than five rolling pre-event reference windows are available | Interpret the misspecification bound cautiously and use a longer pre-event series when available. |
| Elapsed window spans | A window containing the requested number of observed periods spans more calendar periods than requested | Decide whether the longer elapsed fitting and forecasting horizons remain substantively comparable. |
Inspect the diagnostics
Covariate-adjusted fits also enforce full-rank regressions with
positive residual degrees of freedom in every window and at least two
complete responses in every pre-event and forecast period. These
requirements produce errors when violated; the five descriptive checks
do not substitute for them. fit$model_diagnostics reports
the parameter count, final residual degrees of freedom, and
fitting-window RMSEs. In-sample RMSE generally decreases when predictors
are added; judge usefulness with the rolling forecast errors, too. The
daily variance check describes raw outcome summaries; adjusted inference
uses respondent influence functions rather than these marginal
variances.
Begin with the complete daily schedule in
sample_data.
library(eventsurvey)
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
complete <- sample_data
fit_complete <- eventsurvey(y ~ day, complete)
fit_complete$diagnostics
#> check status
#> 1 Calendar coverage OK
#> 2 Responses per period OK
#> 3 Variance information OK
#> 4 Reference windows OK
#> 5 Elapsed window spans OK
#> detail
#> 1 No calendar periods are missing from the analysis span.
#> 2 The minimum observed-period sample size is 26.
#> 3 Every observed period has an estimable within-period variance.
#> 4 18 rolling pre-event reference windows calibrate the bias bound.
#> 5 All fitting and forecasting windows span the requested number of calendar periods.
#> recommendation
#> 1 No action needed.
#> 2 No action needed.
#> 3 No action needed.
#> 4 No action needed.
#> 5 No action needed.All five checks are OK in this example. The same table
appears near the top of the HTML report created by
eventsurvey_report().
fit_complete |>
eventsurvey_report("eventsurvey-report.html")Sparse survey dates
Many surveys do not receive responses every calendar day. Here, several entire dates are removed from the complete data.
unobserved_days <- c(-24, -17, -11, -4, 2)
sparse <- complete |>
filter(!day %in% unobserved_days)
fit_sparse <- eventsurvey(y ~ day, sparse)
fit_sparse$diagnostics
#> check status
#> 1 Calendar coverage Review
#> 2 Responses per period OK
#> 3 Variance information OK
#> 4 Reference windows Review
#> 5 Elapsed window spans Review
#> detail
#> 1 4 pre-event and 1 forecast calendar period(s) are unobserved.
#> 2 The minimum observed-period sample size is 26.
#> 3 Every observed period has an estimable within-period variance.
#> 4 Only 2 rolling pre-event reference window(s) calibrate the bias bound.
#> 5 A 6-period window spans as many as 7 fitting and 7 forecasting calendar periods.
#> recommendation
#> 1 Confirm that schedule = "observed" matches the intended design; outcomes are not interpolated.
#> 2 No action needed.
#> 3 No action needed.
#> 4 Interpret the bound cautiously and use a longer pre-event series when available.
#> 5 Check whether the longer elapsed horizons remain substantively comparable.

Response counts for complete daily fieldwork (left) and sparse fieldwork (right). Missing dates remain unobserved; the package does not interpolate outcomes.
The default schedule = "observed" forms windows from
ordered dates with responses while retaining their actual time values in
estimation. The calendar-coverage check reports the missing dates. The
elapsed-span check reports that a six-observed-period window may cover
more than six calendar periods. Neither check fills the gaps.
If the design instead requires consecutive calendar periods, request that restriction explicitly. The sparse example then stops and identifies the missing periods rather than silently changing the analysis.
eventsurvey(y ~ day, sparse, schedule = "consecutive")
#> Error:
#> ! Pre-event periods must be consecutive. Missing relative period(s): -24, -17, -11, -4. Restrict `data` to a consecutive analysis span.Small period samples and pooled variance
eventsurvey_summary() accepts one row per observed
period. A period with a single respondent has no estimable within-period
sample variance, so its variance can be recorded as NA. The
package uses the pooled within-period variance from the remaining
periods and flags both the small count and the substitution.
daily <- complete |>
group_by(day) |>
summarise(
mean = mean(y),
n = n(),
variance = var(y),
.groups = "drop"
) |>
mutate(
n = if_else(day == -10, 1L, n),
variance = if_else(day == -10, NA_real_, variance)
)
fit_small_period <- eventsurvey_summary(mean ~ day, daily)
fit_small_period$diagnostics
#> check status
#> 1 Calendar coverage OK
#> 2 Responses per period Review
#> 3 Variance information Review
#> 4 Reference windows OK
#> 5 Elapsed window spans OK
#> detail
#> 1 No calendar periods are missing from the analysis span.
#> 2 1 of 38 observed periods have fewer than 10 responses; 1 have one response.
#> 3 1 observed period(s) use the pooled within-period variance because their own variance is unavailable.
#> 4 18 rolling pre-event reference windows calibrate the bias bound.
#> 5 All fitting and forecasting windows span the requested number of calendar periods.
#> recommendation
#> 1 No action needed.
#> 2 Inspect small-period means and interpret them cautiously.
#> 3 Review these periods; pooled variance is used automatically without creating outcomes.
#> 4 No action needed.
#> 5 No action needed.This substitution affects the uncertainty calculation for that period. It does not replace its observed mean or add respondents.
Limited pre-event history
Under the default event-period exclusion rule, the estimator needs at least twice the requested window length plus one observed pre-event period. Meeting that minimum can leave only one rolling reference window, whereas a longer pre-event series provides more opportunities to evaluate comparable forecasts.
short_history <- sample_data |>
filter(day >= -13)
fit_short_history <- eventsurvey(y ~ day, short_history)
fit_short_history$diagnostics
#> check status
#> 1 Calendar coverage OK
#> 2 Responses per period OK
#> 3 Variance information OK
#> 4 Reference windows Review
#> 5 Elapsed window spans OK
#> detail
#> 1 No calendar periods are missing from the analysis span.
#> 2 The minimum observed-period sample size is 26.
#> 3 Every observed period has an estimable within-period variance.
#> 4 Only 1 rolling pre-event reference window(s) calibrate the bias bound.
#> 5 All fitting and forecasting windows span the requested number of calendar periods.
#> recommendation
#> 1 No action needed.
#> 2 No action needed.
#> 3 No action needed.
#> 4 Interpret the bound cautiously and use a longer pre-event series when available.
#> 5 No action needed.The analysis remains estimable, but the
Reference windows check asks the analyst to interpret the
bias bound cautiously. When additional pre-event observations genuinely
exist, including them provides a stronger diagnostic record.
A compact review workflow
The following workflow keeps diagnostics close to the results:
fit <- eventsurvey(outcome ~ interview_date, survey_data,
event_time = as.Date("2026-01-15")
)
fit$diagnostics
summary(fit)
plot(fit, type = "counts")
plot(fit, type = "diagnostics")For every Review row, document whether the feature
reflects the intended survey schedule and why the resulting comparison
remains appropriate. Change the design only for a substantive reason;
the diagnostics do not select a preferred specification
automatically.
Also see
- Reading an HTML Report to see where diagnostics appear alongside the estimates and figures.
- Methodology and Assumptions for what the diagnostics can and cannot establish.
- Sparse Survey Schedules for complete and irregular-fieldwork examples.