Skip to main content

Module serial_dependence

Module serial_dependence 

Source
Expand description

Dependence-corrected summaries of a serially correlated sample.

Both statistics read a sequence x_1..x_n whose terms may be autocorrelated (held-out per-row losses in row order, chain draws) and correct the naive i.i.d. summary for that dependence with the lag window L = ⌊√n⌋, which grows with n while its share L/n vanishes — the standard consistent bandwidth for a sample of unknown correlation length.

Functions§

autocorr_ess
Effective sample size n / (1 + 2 Σ_{k≥1} ρ_k) from the initial positive sequence of sample autocorrelations ρ_k, truncated at the first non-positive lag (Geyer’s rule) and at the lag window ⌊√n⌋. Returns n itself for a degenerate or constant sample and never less than one.
newey_west_se
Newey–West (Bartlett-kernel) standard error of the sample mean with lag window ⌊√n⌋: √(γ_0 + 2 Σ_k w_k γ_k) / √n, w_k = 1 − k/(L+1). Infinite for a sample of fewer than two terms, where no dispersion is measurable.