benbhansen-stats / propertee

Prognostic Regression Offsets with Propagation of ERrors, for Treatment Effect Estimation (IES R305D210029).
https://benbhansen-stats.github.io/propertee/
Other
2 stars 0 forks source link

Matrix transpositions in sandwich variance calculations (b36f2fb) #121

Closed jwasserman2 closed 1 year ago

jwasserman2 commented 1 year ago

Using a robust regression for covariate adjustment, @adamSales uncovered in commit b36f2fb that flexida tags v0.1.1 and beyond generated sandwich variance calculations that were only satisfied for square, symmetric bread matrices. This was due to less careful attention to transposition of matrices when forming the output of estfun.DirectAdjusted.

The solution can be illustrated through matrix multiplication. We aim to estimate sandwich variances $A^{-1}MA^{-T}$, whose lower right submatrix corresponding to the covariance matrix of the ITT effects is derived below:

Screenshot 2023-05-04 at 1 42 00 PM

$\Phi$ and $\Psi$ are the matrices of empirical estimating equations for the covariate adjustment and ITT effect models, respectively (estfun(camod) and estfun.base_S3Class(dmod)).

One important note is that the sandwich has an $A{22}^{-1}$ on the lefthand side and an $A{22}^{-T}$ on the righthand side. The second important note is that the portion in brackets corresponds to the crossproduct of estfun.DirectAdjusted(). The matrix in brackets suggests that estfun.DirectAdjusted should be $\Psi - \Phi A{11}^{-T}A{21}^{T}$.

benthestatistician commented 1 year ago

This looks right to me, thanks. (It prompted a few spec corrections (b5b1266), changing $\Psi - \Phi A{11}^{-1}A{21}^t$'s to $\Psi - \Phi A{11}^{-t}A{21}^t$.)