Learn R Programming

dcce (version 0.4.2)

dcce_rolling: Rolling-Window Panel Estimation

Description

Fits a sequence of dcce() models on overlapping time windows of the panel, producing a time path of coefficient estimates. Useful for detecting coefficient drift, parameter instability, or regime shifts in long panels.

Usage

dcce_rolling(
  data,
  unit_index,
  time_index,
  formula,
  model = "cce",
  window = 20L,
  step = 1L,
  min_units = 5L,
  verbose = FALSE,
  ...
)

Value

An object of class dcce_rolling containing:

fits

List of dcce_fit objects, one per window (or NULL for windows that failed).

coefficients

A tibble with one row per (window end-date, term) combination, columns window_end, window_start, term, estimate, std.error, conf.low, conf.high.

window

The window length.

step

The step size.

n_windows

Number of successful windows.

call

The original call.

Arguments

data

A panel data.frame.

unit_index

Character: unit identifier column.

time_index

Character: time identifier column.

formula

Two-sided model formula passed through to dcce().

model

Character: estimator to use (default "cce"). Same choices as dcce().

window

Integer: window length in time periods.

step

Integer: number of time periods to advance between windows. Default 1L.

min_units

Integer: minimum number of cross-sectional units a window must retain after NA handling to be kept. Default 5L.

verbose

Logical: print progress? Default FALSE.

...

Additional arguments passed to dcce() (e.g. cross_section_vars, cross_section_lags, fast).

Details

At each window the function subsets the panel to observations whose time index falls in \([t_k, t_k + \text{window} - 1]\), runs dcce() with the user-supplied arguments, and collects the Mean Group coefficient vector and its standard errors. The result is returned as a dcce_rolling object containing the full list of fits and a tidy tibble of coefficients indexed by window end-date.

Examples

Run this code
data(pwt8)
roll <- dcce_rolling(
  data       = pwt8,
  unit_index = "country",
  time_index = "year",
  formula    = d_log_rgdpo ~ log_hc + log_ck + log_ngd,
  model      = "cce",
  cross_section_vars = ~ .,
  window     = 20,
  step       = 2
)
print(roll)

Run the code above in your browser using DataLab