This function is defined between equations 2 and 3 of the
supplement. It is used in functions betahat.fun.koh(),
p.eqn8.supp(), and p.joint().
Returns
$$
{\mathbf W} (\theta)=
\left(
{\mathbf H}(\theta)^T {\mathbf V}_d(\theta)^{-1} {\mathbf H}(\theta)
\right)^{-1}
$$
If only the determinant is required, setting argument det to
TRUE is faster than using det(W(..., det=FALSE)), as the
former avoids an unnecessary use of solve().