balancing_estimating_equations holds the pieces a stacked sandwich variance
needs after balancing: the fitted parameters, the per-unit estimating
functions, the analytic Jacobian, and each unit's weight derivatives. It is
produced by methods whose weights solve smooth estimating equations and is
NULL otherwise.
Arguments
- parameters
The fitted parameters, a numeric vector.
- psi
The
nbypestimating functions at the solution.- jacobian
The
pbypanalytic Jacobian at the solution.- weight_jacobian
The
nbypweight derivatives.- weights_raw
The balancing weights whose derivative is
weight_jacobian, a length-nnumeric vector. The weight derivatives are stored at whatever per-group reporting scale a method uses internally, so a consumer that needs the derivative of the reported weights rescalesweight_jacobianby the ratio of the reported weights toweights_raw.- psi_fn
An optional function re-evaluating
psiat new parameters.- weights_fn
An optional function returning the reported balancing weights at new parameters, a plain double vector with the sampling weights excluded. At the fitted parameters it reproduces
as.numeric(weights(fit, include_sampling_weights = FALSE)). The per-group reporting scale is fixed at the fit rather than recomputed at each set of parameters, so the function's derivative isweight_jacobianrescaled by the ratio of the reported weights toweights_raw, which is the weight coupling a stacked variance needs.- parts_fn
An optional function returning both of the above at one set of parameters, a list with elements
weightsandpsiholding exactly whatweights_fnandpsi_fnreturn there. A method whose estimating functions are a transformation of its own weights computes the pair together for the price of one, and a consumer that needs both at every parameter vector, as a stacked sandwich does, halves its work by asking for them together. It is an optimization rather than a contract: a consumer reads it when it is present and falls back to the two functions when it is not, so a method supplies it only when the saving is real.