Skip to Main Content
Table 5A

Continued

### Calculate new estimate of Vartrue, set to zero if negative and 
### store in vector v 
vart <− (n/(n− p))* varo− varm 
vart <− max(vart, 0) 
v[i+ 1] <− vart 
### Terminate iterations when Vhattrue has converged (at 10−8) and calculate 
new estimates of lnSIR (newbeta) and var(lnSIR) (newvar) 
if (Mod(v[i+ 1]− v) < 1e-007) { 
vart <− v[i+ 1] 
vstar <− (((n− p− 2)* vhat)/(n− p)) 
tstar <− vart* diag(n)+ vhat− vstar 
newbeta <− W %*% ((tstar %*% bhat)+ (vstar %*%mu)) 
### The definition of newvar is taken from Ref. 15 
H <− z %*% (solve (t(z) %*% W %*% z)) %*% t(z) %*% W 
bstar <− ((n− p− 2)* W %*% vhat)/(n− p) 
E <− bstar %*% D* sqrt (varm/diag(vhat)) 
newvar <− diag(vhat− (t(diag(n)− H) %*% vhat %*% bstar)+ 
(2* E %*% t (E))/(n− p− 2)) 
 
break 
 
In an example such as that presented in this article, for which we assume no correlations between the original estimates (and no prior knowledge is incorporated), the above program simplifies. Vhat becomes a vector of variances instead of a variance-covariance matrix, and z is no longer necessary. 
 
function (bhat, vhat, niter) 
### Define the number of estimates (n) 
n <− length (bhat) 
### Set initial value for Vhattrue (vart) to 0 
vart <− 0 
### Generate vector to store values of Vhattrue from each iteration 
v <− vector (length = niter+ 1) 
v [1] <− 0 
### Start iterative loop 
for (i in 1:niter) { 
### Define a vector of weights (w) and calculate lnSIRmean (pi) 
### vhat is a vector of the variances of the original estimates 
w <− 1/(vhat+ vart) 
pi <− sum (w* bhat)/sum(w) 
### Calculate D, Vhatobs (varo) and Vhatmean (varm) 
D <− bhat− pi 
varo <− sum(w* D* D)/sum(w) 
varm <− sum(w* vhat)/sum(w) 
### Calculate new estimate of Vartrue, set to zero if negative and 
### store in vector v 
vart <− max((varo− varm), 0) 
v[i+ 1] <− vart 
### Terminate iterations when Vhattrue has converged and calculate new 
estimates of lnSIR (newbeta) and var(lnSIR) (newvar) 
if (Mod(v[i+ 1] − v) < 1e-007) {  
vart <− v[i+ 1] 
newbeta <− w*((vart* bhat)+ (vhat* pi)) 
E <− w* vhat* D* sqrt(varm/vhat) 
newvar <− vhat* (1− vhat * w)+ (2* E* t(E))/n 
 
break 
### Calculate new estimate of Vartrue, set to zero if negative and 
### store in vector v 
vart <− (n/(n− p))* varo− varm 
vart <− max(vart, 0) 
v[i+ 1] <− vart 
### Terminate iterations when Vhattrue has converged (at 10−8) and calculate 
new estimates of lnSIR (newbeta) and var(lnSIR) (newvar) 
if (Mod(v[i+ 1]− v) < 1e-007) { 
vart <− v[i+ 1] 
vstar <− (((n− p− 2)* vhat)/(n− p)) 
tstar <− vart* diag(n)+ vhat− vstar 
newbeta <− W %*% ((tstar %*% bhat)+ (vstar %*%mu)) 
### The definition of newvar is taken from Ref. 15 
H <− z %*% (solve (t(z) %*% W %*% z)) %*% t(z) %*% W 
bstar <− ((n− p− 2)* W %*% vhat)/(n− p) 
E <− bstar %*% D* sqrt (varm/diag(vhat)) 
newvar <− diag(vhat− (t(diag(n)− H) %*% vhat %*% bstar)+ 
(2* E %*% t (E))/(n− p− 2)) 
 
break 
 
In an example such as that presented in this article, for which we assume no correlations between the original estimates (and no prior knowledge is incorporated), the above program simplifies. Vhat becomes a vector of variances instead of a variance-covariance matrix, and z is no longer necessary. 
 
function (bhat, vhat, niter) 
### Define the number of estimates (n) 
n <− length (bhat) 
### Set initial value for Vhattrue (vart) to 0 
vart <− 0 
### Generate vector to store values of Vhattrue from each iteration 
v <− vector (length = niter+ 1) 
v [1] <− 0 
### Start iterative loop 
for (i in 1:niter) { 
### Define a vector of weights (w) and calculate lnSIRmean (pi) 
### vhat is a vector of the variances of the original estimates 
w <− 1/(vhat+ vart) 
pi <− sum (w* bhat)/sum(w) 
### Calculate D, Vhatobs (varo) and Vhatmean (varm) 
D <− bhat− pi 
varo <− sum(w* D* D)/sum(w) 
varm <− sum(w* vhat)/sum(w) 
### Calculate new estimate of Vartrue, set to zero if negative and 
### store in vector v 
vart <− max((varo− varm), 0) 
v[i+ 1] <− vart 
### Terminate iterations when Vhattrue has converged and calculate new 
estimates of lnSIR (newbeta) and var(lnSIR) (newvar) 
if (Mod(v[i+ 1] − v) < 1e-007) {  
vart <− v[i+ 1] 
newbeta <− w*((vart* bhat)+ (vhat* pi)) 
E <− w* vhat* D* sqrt(varm/vhat) 
newvar <− vhat* (1− vhat * w)+ (2* E* t(E))/n 
 
break 
Close Modal

or Create an Account

Close Modal
Close Modal