### Contents

1. Bugs in Code
2. Error in estimating mu
3. Final Plots
• Relative Error Plots
• 2 CV Plot
• Using Reference Panel
4. Difference in nvar
5. T1D Results
6. Microbenchmarking
7. Posterior Probabilities of Null Model

### 1. Bugs in Code

We found a couple of bugs in the code. I have corrected these and re-ran the simulations.

• In our correction, we find the PPs for many matrices of simulated Z-scores. Our code for calculating PPs from a vector of Z-scores is correct and shown below:
ppfunc <- function(z, V, W = 0.2) {
stopifnot(class(z)=="numeric")
r = W^2/(W^2 + V)
bf = 0.5 * (log(1 - r) + (r * z^2)) # log BFs
denom = logsum(bf) # denominator (on log scale so don't sum to 100)
exp(bf - denom)  # convert back from log scale
}

but it was incorrect for when z is a matrix. How?

1. Our (log) BFs were wrong because we were multiplying r by z column wise rather than row wise.

2. I was calculating the logsum of the whole matrix of BFs (obtaining one value) rather than for each row seperately to obtain one for each simulation (although this didn’t matter as we normalised the PPs afterwards).

• The method of calculating BFs from the simulated Z-score matrices was BF <- 0.5 * (log(1 - r) + (r * zstar^2)) where zstar is a nsim*nsnp matrix of Z-scores and r is a vector of length nsnp of the shrinkage factors. So that r is being recycled into a matrix to do the multiplications, but it is being recycled column wise rather than row wise!!!!! This was identified because Chris tried to match my results by applying the ppfunc over each row of zstar and we were getting different results. To fix this, I have created a .zj_pp utility function that is used within all the corrected coverage functions (note the difference of calculating the BFs, which now recycles r row wise):
.zj_pp = function(Zj, int.Sigma, int.nrep, int.ERR, int.r) {
stopifnot(class(Zj)=="numeric")
stopifnot(class(int.ERR)=="matrix")
stopifnot(class(int.r)=="numeric")
exp.zm = Zj %*% int.Sigma
mexp.zm = matrix(exp.zm, int.nrep, length(Zj), byrow = TRUE)  # matrix of Zj replicated in each row
zstar = mexp.zm + int.ERR # MATRIX of z scores
bf = 0.5 * t(log(1 - int.r) + (int.r * t(zstar^2))) # row wise
denom = apply(bf, 1, logsum) # get different denom for each rep
exp(bf - denom)  # convert back from log scale
}

### 2. Error in estimating mu

• The code for estimating $$\mu$$ was incorrect and has now been ammended. We find that our standard 4 estimates of $$\mu$$ are no longer accurate, where:

• A = max(abs(z))
• B = sum(abs(z)*ppdash)
• C = (1-ppdash[h0])*max(abs(z))
• D = mean(B,C)