% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/rolling.R
\name{dcce_rolling}
\alias{dcce_rolling}
\title{Rolling-Window Panel Estimation}
\usage{
dcce_rolling(
  data,
  unit_index,
  time_index,
  formula,
  model = "cce",
  window = 20L,
  step = 1L,
  min_units = 5L,
  verbose = FALSE,
  ...
)
}
\arguments{
\item{data}{A panel data.frame.}

\item{unit_index}{Character: unit identifier column.}

\item{time_index}{Character: time identifier column.}

\item{formula}{Two-sided model formula passed through to \code{dcce()}.}

\item{model}{Character: estimator to use (default \code{"cce"}). Same
choices as \code{dcce()}.}

\item{window}{Integer: window length in time periods.}

\item{step}{Integer: number of time periods to advance between windows.
Default \code{1L}.}

\item{min_units}{Integer: minimum number of cross-sectional units a
window must retain after NA handling to be kept. Default \code{5L}.}

\item{verbose}{Logical: print progress? Default \code{FALSE}.}

\item{...}{Additional arguments passed to \code{dcce()}
(e.g. \code{cross_section_vars}, \code{cross_section_lags},
\code{fast}).}
}
\value{
An object of class \code{dcce_rolling} containing:
\describe{
\item{fits}{List of \code{dcce_fit} objects, one per window
(or \code{NULL} for windows that failed).}
\item{coefficients}{A tibble with one row per
(window end-date, term) combination, columns \code{window_end},
\code{window_start}, \code{term}, \code{estimate}, \code{std.error},
\code{conf.low}, \code{conf.high}.}
\item{window}{The window length.}
\item{step}{The step size.}
\item{n_windows}{Number of successful windows.}
\item{call}{The original call.}
}
}
\description{
Fits a sequence of \code{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.
}
\details{
At each window the function subsets the panel to observations whose
time index falls in \eqn{[t_k, t_k + \text{window} - 1]}, runs
\code{dcce()} with the user-supplied arguments, and collects the
Mean Group coefficient vector and its standard errors. The result is
returned as a \code{dcce_rolling} object containing the full list of
fits and a tidy tibble of coefficients indexed by window end-date.
}
\examples{
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)
}
