% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/spatial_cce.R
\name{.build_spatial_csa}
\alias{.build_spatial_csa}
\title{Build spatial (local) cross-sectional averages}
\usage{
.build_spatial_csa(panel, vars, W, lags = 0L)
}
\arguments{
\item{panel}{A panel data.frame from \code{.make_panel()}.}

\item{vars}{Character vector of variables to build spatial CSAs for.}

\item{W}{A validated spatial weight matrix from
\code{.spatial_validate_W()}, with rows/columns labelled by unit id.}

\item{lags}{Integer scalar or named integer vector of lag orders.
Default \code{0L} (contemporaneous only).}
}
\value{
The panel with new \code{csa_*} columns appended.
}
\description{
For each variable in \code{vars} and each unit \eqn{i} at time \eqn{t},
computes \eqn{\bar y^W_{i,t} = \sum_j w_{ij} y_{j,t}} where \eqn{W} is
the row-normalised spatial weight matrix. Appends these as new
columns on the panel, alongside lagged versions when requested.
}
\details{
Compared to \code{.build_csa()} (which appends a single global series
per variable, broadcast to all units), the spatial variant produces
unit-specific values — each unit sees its own neighbourhood average.
}
\keyword{internal}
