Skip to contents

Survey fieldwork often does not produce responses every day. This article shows how eventsurvey handles such schedules without treating an unobserved date as though it contained an outcome. It compares two versions of the bundled sample_data:

  1. a complete schedule with responses every day; and
  2. a sparse schedule with several entire survey days removed.

Because the sparse dataset is a subset of the complete dataset, respondents on the retained dates have exactly the same outcomes in both analyses. The only difference is the fieldwork schedule.

Calibration and elapsed horizons

Estimand-specific calibration is applied automatically. It matches the actual elapsed forecast horizons of the final analysis and retains only complete pre-event reference windows. With missing periods, it may use fewer windows than the former observed-period algorithm, or stop when none match. It does not interpolate missing observations. The main examples below use estimand-specific calibration.

Create complete and sparse schedules

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

unobserved_days <- c(-24, -17, -11, -4, 2)
sparse <- complete |>
  filter(!day %in% unobserved_days)

fit_complete <- eventsurvey(
  y ~ day,
  complete,
  event_time = 0,
  window = 6
)

fit_sparse <- eventsurvey(
  y ~ day,
  sparse,
  event_time = 0,
  window = 6
)

The counts plots make the schedule difference visible. The sparse data have no responses on four pre-event dates and one post-event date.

plot(fit_complete, type = "counts")
plot(fit_sparse, type = "counts")
Response counts under complete daily fieldwork (left) and sparse fieldwork (right). The dashed line marks the event date.Response counts under complete daily fieldwork (left) and sparse fieldwork (right). The dashed line marks the event date.

Response counts under complete daily fieldwork (left) and sparse fieldwork (right). The dashed line marks the event date.

Inspect what the package detected

With schedule = "observed", the final fitting and forecast windows use the requested number of dates with responses. It does not renumber those dates: their actual time values enter the trend and forecast calculations. The fitted object records every gap and the elapsed span of the final windows. Estimand-specific calibration then requires pre-event reference forecasts at the same elapsed horizons as the final forecast; the fitting windows still use observed dates.

fit_sparse$settings$missing_pre_periods
#> [1] -24 -17 -11  -4
fit_sparse$settings$missing_forecast_periods
#> [1] 2
fit_sparse$settings$fit_periods
#> [1] -7 -6 -5 -3 -2 -1
fit_sparse$fitted$relative_period
#> [1] 1 3 4 5 6 7
Detected gaps and elapsed window spans. Spans are measured on the original time scale.
Schedule Missing pre-event periods Missing forecast periods Final fit span Final forecast span Reference windows
Complete None None 6 6 18
Sparse -24, -17, -11, -4 2 7 7 2

For the sparse data, the six-period fitting window consists of days -7, -6, -5, -3, -2, -1; it spans 7 calendar days. The six-period effect window uses days 1, 3, 4, 5, 6, 7 and spans 7 calendar days.

Compare the fitted counterfactuals

plot(fit_complete, type = "counterfactual")
plot(fit_sparse, type = "counterfactual")
Observed outcomes and extrapolated no-event counterfactuals under complete daily fieldwork (left) and sparse fieldwork (right). The sparse analysis uses actual calendar dates and leaves unobserved dates empty.Observed outcomes and extrapolated no-event counterfactuals under complete daily fieldwork (left) and sparse fieldwork (right). The sparse analysis uses actual calendar dates and leaves unobserved dates empty.

Observed outcomes and extrapolated no-event counterfactuals under complete daily fieldwork (left) and sparse fieldwork (right). The sparse analysis uses actual calendar dates and leaves unobserved dates empty.

The two analyses can target different post-event dates, so their estimated effects and intervals should be compared together with their target windows.

Estimated average effects for each schedule-specific target window.
Schedule Target dates Estimated average effect Honest CI lower Honest CI upper
Complete 1, 2, 3, 4, 5, 6 0.234 -1.849 2.435
Sparse 1, 3, 4, 5, 6, 7 0.008 -1.665 1.714

These estimates need not be identical. Missing pre-event dates can change the line used for extrapolation and the reference forecast errors. Missing post-event dates can also change the estimand because the first six observed dates are not necessarily the first six calendar dates. The package therefore reports the targeted dates rather than implying that the two rows estimate exactly the same quantity.

The sparse analysis retains 2 complete matching reference windows. Few matching windows make calibration more dependent on limited pre-event history. If no complete matching window exists, estimation stops with an error.

Require consecutive calendar days when appropriate

If the research design requires uninterrupted calendar dates, request strict mode explicitly:

strict_sparse <- tryCatch(
  eventsurvey(
    y ~ day,
    sparse,
    event_time = 0,
    window = 6,
    schedule = "consecutive"
  ),
  error = conditionMessage
)

For the complete data, observed-period and consecutive-period modes give the same result because no dates are missing. For the sparse data, strict mode stops and identifies pre-event days -24, -17, -11, and -4 as missing. This makes the choice explicit: observed-period mode supports irregular fieldwork, whereas consecutive-period mode enforces an uninterrupted calendar design.

Also see