Skip to contents

Covariate-spec counterpart of scm_placebo_cpp(): for each control unit, treats it as pseudo-treated with its own predictor column X0[, i] and fits the nested V/W optimisation against the remaining donors' predictors X0[, -i], evaluating the prediction loss on pre-treatment outcomes. Each leave-one-out problem is identical to a scm_weights_cpp() call on the same submatrices; iterations are independent and run in parallel under OpenMP.

Usage

scm_placebo_x_cpp(
  X0,
  Y_pre,
  Y_post,
  max_iter = 100L,
  tol = 1e-04,
  z_rows = NULL,
  multistart = FALSE
)

Arguments

X0

Predictor matrix for control units (k x N_co), on the same scale as the treated fit (SD-scaled when scale_predictors = TRUE)

Y_pre

Control pre-treatment outcomes (T_pre x N_co)

Y_post

Control post-treatment outcomes (T_post x N_co)

max_iter

Outer coordinate-descent iterations (default 100)

tol

Convergence tolerance for V updates (default 1e-4)

z_rows

Optional 1-based pre-period row indices of the outer evaluation window (the v_window of the treated fit), so each placebo refit optimises V on the same window. NULL (default) uses all rows. MSPE components are always computed on the full pre/post windows.

multistart

If TRUE, each placebo refit uses the same deterministic multi-start outer search as the treated fit, keeping the permutation test symmetric.

Value

A list with:

  • mspe_pre: N_co-vector of pre-treatment MSPE per placebo unit

  • mspe_post: N_co-vector of post-treatment MSPE per placebo unit

  • effects: N_co-vector of mean post-period gap per placebo unit

  • gaps: (T_pre + T_post) x N_co matrix of placebo gap paths A placebo unit whose solver fails yields NaN entries.