-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDELETEB.G
26 lines (26 loc) · 1.32 KB
/
DELETEB.G
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/* This proc approximates the delta-betas (observation-deleted betas
MINUS fitted betas) for models linear in the natural parameter of a
one-parameter exponential-family error distribution.
for generalized-linear (in the natural parameter) regressions.
Inputs: x = regressor (design) matrix, including constant if present
e = observed minus fitted y (residual on mean scale)
w = final fitted weight
b = coefficients
bcov = estimated covariance matrix for b
Output: matrix of approximations to one-step delta-betas
-- row i is approx. delta-beta for deleting observation i.
*/
proc deleteb(x,e,w,b,bcov);
local crwx,ch;
/* h = sqrt(w).*x*bcov*(x.*sqrt(w))' may be too big to fit in memory, so
use the following trick to avoid computing h. h = crwx'crwx but we
don't need all of h, just its diagonal, which is sumc(crwx.*crwx): */
crwx = chol(bcov)*(sqrt(w).*x)';
/* variance adjustment factor for approximate delta-betas
(needed because bcov is not recomputed for each observation): */
ch = 1-sumc(crwx.*crwx);
/* return approx. delta-betas (each row is an approximation to the
first Newton step toward what b would become after dropping
the corresponding observation): */
retp(-(e./ch).*(x*bcov));
endp;