I could easily add some numerical refinementsrefine the code to prevent subtractive cancelation when $p$p
is close to 1 by defining
w <- linkderiv <- plogis(eta) * plogis(eta, lower.tail=FALSE),
but the simplemore readable code above stillalready handles the example well enough.