R/ebnm_fns.R
ebnm_normal_scale_mixture.Rd
Solves the empirical Bayes normal means (EBNM) problem using the family of
scale mixtures of normals. Identical to function ebnm
with argument prior_family = "normal_scale_mixture"
. For details
about the model, see ebnm
.
ebnm_normal_scale_mixture(
x,
s = 1,
mode = 0,
scale = "estimate",
g_init = NULL,
fix_g = FALSE,
output = ebnm_output_default(),
optmethod = NULL,
control = NULL,
...
)
A vector of observations. Missing observations (NA
s) are
not allowed.
A vector of standard errors (or a scalar if all are equal). Standard errors may not be exactly zero, and missing standard errors are not allowed.
A scalar specifying the mode of the prior \(g\) or
"estimate"
if the mode is to be estimated from the data.
The nonparametric family of scale mixtures of normals is
approximated via a finite mixture of normal distributions
$$\pi_1 N(\mu, \sigma_1^2) + \ldots + \pi_K N(\mu, \sigma_K^2),$$
where parameters \(\pi_k\) are estimated and the grid of standard
deviations \((\sigma_1, \ldots, \sigma_K)\) is fixed in advance. By
making the grid sufficiently dense, one can obtain an arbitrarily good
approximation. The grid can be specified by the user via parameter
scale
, in which case the argument should be the vector of
standard deviations \((\sigma_1, \ldots, \sigma_K)\); alternatively,
if scale = "estimate"
, then
ebnm
sets the grid via function ebnm_scale_normalmix
.
Note that ebnm
sets the grid differently from
function ash
. To use the ash
grid, set
scale = "estimate"
and pass in gridmult
as an additional
parameter. See ash
for defaults and details.
The prior distribution \(g\). Usually this is left
unspecified (NULL
) and estimated from the data. However, it can be
used in conjuction with fix_g = TRUE
to fix the prior (useful, for
example, to do computations with the "true" \(g\) in simulations). If
g_init
is specified but fix_g = FALSE
, g_init
specifies the initial value of \(g\) used during optimization. This has
the side effect of fixing the mode
and scale
parameters. When
supplied, g_init
should be an object of class
normalmix
or an ebnm
object in which the fitted
prior is an object of class normalmix
.
If TRUE
, fix the prior \(g\) at g_init
instead
of estimating it.
A character vector indicating which values are to be returned.
Function ebnm_output_default()
provides the default return values, while
ebnm_output_all()
lists all possible return values. See Value
below.
A string specifying which optimization function is to be
used. Options are provided by package
ashr
. The default method uses the mix-SQP algorithm implemented in
the mixsqp
package. See the ash
function
documentation for other options.
A list of control parameters to be passed to the
optimization function specified by parameter optmethod
.
When parameter gridmult
is set, an
ash
-style grid will be used instead of the default
ebnm
grid (see parameter scale
above). Other additional
parameters are ignored.
An ebnm
object. Depending on the argument to output
, the
object is a list containing elements:
data
A data frame containing the observations x
and standard errors s
.
posterior
A data frame of summary results (posterior means, standard deviations, second moments, and local false sign rates).
fitted_g
The fitted prior \(\hat{g}\).
log_likelihood
The optimal log likelihood attained, \(L(\hat{g})\).
posterior_sampler
A function that can be used to
produce samples from the posterior. The sampler takes a single
parameter nsamp
, the number of posterior samples to return per
observation.
S3 methods coef
, confint
, fitted
, logLik
,
nobs
, plot
, predict
, print
, quantile
,
residuals
, simulate
, summary
, and vcov
have been implemented for ebnm
objects. For details, see the
respective help pages, linked below under See Also.
See ebnm
for examples of usage and model details.
Available S3 methods include coef.ebnm
,
confint.ebnm
,
fitted.ebnm
, logLik.ebnm
,
nobs.ebnm
, plot.ebnm
,
predict.ebnm
, print.ebnm
,
print.summary.ebnm
, quantile.ebnm
,
residuals.ebnm
, simulate.ebnm
,
summary.ebnm
, and vcov.ebnm
.