Skip to contents

Estimates the variance-covariance matrix of log-incidence estimates by modelling residual autocorrelation with an exponential decay model.

Usage

vcov_from_residuals(
  data,
  mu,
  sigma,
  max_lag = 10,
  min_alpha = 0.01,
  max_alpha = 2
)

Arguments

data

Numeric vector: observed case counts I_t

mu

Numeric vector: estimated log-incidence (log lambda_t)

sigma

Numeric vector: estimated standard error of log lambda_t

max_lag

Integer: maximum lag for ACF estimation (default: 10)

min_alpha

Positive number: minimum decay rate (default: 0.01)

max_alpha

Positive number: maximum decay rate (default: 2.0)

Value

List with:

  • vcov_matrix: T x T estimated VCOV matrix for log lambda_t

  • alpha: fitted decay parameter

  • acf_obs: observed ACF of Pearson residuals

  • acf_fit: fitted ACF values

  • residuals: Pearson residuals used

  • times: time indices

Details

This function was generated by Qwen3-235B-A22B-2507

Examples

T <- 50
mu <- 5 + 0.05 * (1:T) + stats::arima.sim(list(ar = 0.8), n = T, sd = 0.3)
sigma <- rep(0.2, T)
lambda <- exp(mu)
data <- stats::rpois(T, lambda)

result <- vcov_from_residuals(data, mu, sigma, max_lag = 8)
dim(result$vcov_matrix)  # Should be T x T
#> [1] 50 50