posterior.mean | R Documentation |
Compute the posterior mean under spike-and-slab Gaussian prior
posterior.mean(z, sigma, p, mu, sigma.prior, deriv = 0)
z |
a vector of z-scores |
sigma |
a vector of standard deviations of |
p |
prior: mixture proportion |
mu |
prior: mean |
sigma.prior |
prior: standard deviation |
deriv |
compute the posterior mean ( |
Similar to fit.mixture.model
, this function assumes that z
is distributed as N(\gamma, 1)
and \gamma
follows a Gaussian mixture model. The function computes the posterior mean E[\gamma|z]
.
a vector
require(mr.raps)
data(lipid.cad)
data <- subset(lipid.cad, lipid == "hdl" & restrict &
gwas.selection == "teslovich_2010" &
gwas.outcome == "cardiogramplusc4d_1000genome")
z <- data$beta.exposure / data$se.exposure
prior.param <- fit.mixture.model(z)
z.seq <- seq(-5, 5, 0.1)
gamma.hat <- posterior.mean(z.seq, 1, prior.param$p, prior.param$mu, prior.param$sigma)
gamma.hat.deriv <- posterior.mean(z.seq, 1, prior.param$p,
prior.param$mu, prior.param$sigma, deriv = 1)
par(mfrow = c(1, 2))
plot(z.seq, gamma.hat, type = "l")
plot(z.seq, gamma.hat.deriv, type = "l")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.