% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/estpw_d_matrix_clw.R
\name{compute_D_CLW}
\alias{compute_D_CLW}
\title{Compute design-based covariance matrix D for CLW}
\usage{
compute_D_CLW(sp_des, pi_sp, Xp)
}
\arguments{
\item{sp_des}{A survey design object of class `"survey.design2"` or
`"svyrep.design"`.}

\item{pi_sp}{Numeric vector of estimated values multiplying `X_p`
in the CLW estimating equation. Length must equal the number of
rows in `sp_des$variables`.}

\item{Xp}{Numeric matrix of dimension `n_p x p`. Each row is the
covariate vector `x_j` used in the CLW estimating equation.}
}
\value{
A `p x p` covariance matrix `D`.
}
\description{
Internal helper to compute
\deqn{D = Var_p\left( \sum_{j \in s_p} d_j \pi_j x_j \right)}
from an existing survey design object created by
survey::svydesign() or survey::svrepdesign().
}
\details{
In the CLW method, the probability sample contribution in the
estimating equation is \eqn{\pi_j d_j x_j}, where `pi_j` corresponds
to the inverse of the estimated pseudo-weight. Thus the design-based
covariance matrix is obtained by treating \eqn{h_j = \pi_j x_j}
as the survey total variable.
}
\keyword{internal}
