posterior.mean: Compute the posterior mean under spike-and-slab Gaussian...

View source: R/shrinkage.R

posterior.meanR Documentation

Compute the posterior mean under spike-and-slab Gaussian prior

Description

Compute the posterior mean under spike-and-slab Gaussian prior

Usage

posterior.mean(z, sigma, p, mu, sigma.prior, deriv = 0)

Arguments

z

a vector of z-scores

sigma

a vector of standard deviations of z (if sigma is a single number, it is expanded to a vector)

p

prior: mixture proportion

mu

prior: mean

sigma.prior

prior: standard deviation

deriv

compute the posterior mean (deriv = 0) or its derivative (deriv = 1)

Details

Similar to fit.mixture.model, this function assumes that z is distributed as N(γ, 1) and γ follows a Gaussian mixture model. The function computes the posterior mean E[γ|z].

Value

a vector

Examples


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")


qingyuanzhao/mr.raps documentation built on June 4, 2022, 3:04 a.m.