dens.mixture {mixfdr} | R Documentation |
These functions are used to calculate various quantities derived from a mixture model (fdr,FDR, effectSize, etc.). They are useful if you have a mixture model and you want to calculate, for instance, the fdr estimate on a new data point. They are also very useful for plotting.
dens.mixture(x, m) groupProbs(z, m) effectSize(z, m, noiseSD = NA) fdrMixModel(z, m, nullGroups = NA) tailFDRMixModel(z, m, nullGroups = NA) plot.mix.dens(x, plot.subdens = TRUE, ...)
x |
A vector of new data points for which things are to be calculated. |
z |
A vector of new data points for which things are to be calculated. The same as x , just different notation. |
m |
A mixture model, as returned by mixFdr . You can make your own: it should be a list with elements pi, mu, sigma. Each should be a J vector with the appropriate parameter values. Some functions also need another element data, which contains the data the model was fitted on. |
nullGroups |
A J-length boolean vector indicating which groups should be counted in the null. If NA just takes the first group |
noiseSD |
The sampling variance (see details for where this comes in the model). If NA, taken from m$noiseSD if present there, otherwise min(m$sig) . |
plot.subdens |
Plot the subdensities? |
... |
Arguments to pass to hist . Note prob=TRUE is already being passed. |
dens.mixture
computes the mixture density at each x[i]
groupProbs
computes the posterior probability that each z[i]
came from each group of the mixture model.
effectSize
computes the posterior mean and variance when z[i]
is observed. The model is that z[i]
is Normal(delta[i],noiseSD), and delta[i] have a normal mixture prior (so that z[i]
have the marginal density given by m
). effectSize
calculates the posterior mean and variance for delta[i] given z[i]
. If noiseSD
is too big (bigger than any of m$sig
) then effectSize
basically increases those m$sig
to be at least noiseSD
and returns a warning.
fdrMixModel
calculates the local false discovery rate (fdr). This is P(delta[i]==0|z[i]), or more generall P(delta[i] null|z[i]).
tailFDRMixModel
calculates the tail area false discovery rate (FDR). This is P(delta[i]==0||z[i]|>z) (two-sided) or P(delta[i]==0|z[i]>z) (right) or P(delta[i]==0|z[i]<z) (left). tailFDRMixModel
computes all three.
plot.mix.dens
plots a histogram of m$data
and overlays the density curve (with the group subdensities if required).
dens.mixture
returns a vector of density values.
groupProbs
returns a length(z)
by J
matrix of posterior probabilities.
effectSize
returns a matrix, first column effect sizes, second column posterior variances.
fdrMixModel
returns a vector of fdr's.
tailFDRMixModel
returns a list. FDRTwoSided
, FDRleft
, FDRright
have two-sided, left and right FDRs respectively.
Omkar Muralidharan
See papers at the author's website http://stat.stanford.edu/~omkar
z = rnorm(10000) m = mixFdr(z, plots = FALSE) s = seq(-5,5,by=0.01) plot(s, dens.mixture(s,m), t = 'l', main = "Mixture Density") plot(s, groupProbs(s,m)[,1], t = 'l', main = "Prob of being from group 1") plot(s, effectSize(s,m)[,1], t = 'l', main = "Effect Size") plot(s, effectSize(s,m)[,2], t = 'l', main = "Posterior Effect Var") plot(s, fdrMixModel(s,m), t = 'l', main = "fdr") plot(s, tailFDRMixModel(s,m)$FDRT, t = 'l', main = "two-sided FDR") plot.mix.dens(m, TRUE, br = 100)