| ebnm_group {ebnm} | R Documentation |
Solve the EBNM problem for grouped data
Description
Solves the empirical Bayes normal means (EBNM) problem for observations belonging to distinct groups.
Usage
ebnm_group(
x,
s = 1,
group,
prior_family = "point_normal",
mode = 0,
scale = "estimate",
g_init = NULL,
fix_g = FALSE,
output = ebnm_output_default(),
...
)
Arguments
x |
A vector of observations. Missing observations ( |
s |
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. Two prior families have
additional restrictions: when horseshoe priors are used, errors
must be homoskedastic; and since function
|
group |
A vector of character strings that gives the group to which each
observation belongs. It must have the same length as argument |
prior_family |
A named vector that specifies the prior family |
mode |
A named list that specifies, for each group, the mode of the
respective prior |
scale |
A named list that specifies, for each group, the scale
parameter(s) of the respective prior, or |
g_init |
The prior distributions |
fix_g |
If |
output |
A character vector indicating which values are to be returned.
Function |
... |
Additional parameters. When a |
Details
The EBNM model for grouped data, with observations x_j belonging to
groups k = 1, ..., K, is
x_j | \theta_j, s_j \sim N(\theta_j, s_j^2)
\theta_j \sim g_{k(j)} \in G_{k(j)}.
Solving the EBNM problem for grouped data is equivalent to solving a
separate EBNM problem for each group k = 1, ..., K, with the optimal
log likelihood equal to the sum of the optimal log likelihoods for each
separate problem.
Value
An ebnm object. Depending on the argument to output, the
object is a list containing elements:
dataA data frame containing the observations
xand standard errorss.posteriorA data frame of summary results (posterior means, standard deviations, second moments, and local false sign rates).
fitted_gThe fitted prior
\hat{g}(an object of classnormalmix,laplacemix,gammamix,unimix,tnormalmix, orhorseshoe).log_likelihoodThe optimal log likelihood attained,
L(\hat{g}).posterior_samplerA function that can be used to produce samples from the posterior. For all prior families other than the horseshoe, the sampler takes a single parameter
nsamp, the number of posterior samples to return per observation. Sinceebnm_horseshoereturns an MCMC sampler, it additionally takes parameterburn, the number of burn-in samples to discard.
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 Also
Examples
group <- c(rep("small_sd", 100), rep("large_sd", 100))
theta <- c(rnorm(100, sd = 1), rnorm(100, sd = 10))
s <- 1
x <- theta + rnorm(200, 0, s)
ebnm.group.res <- ebnm_group(x, s, group)
# Use different prior families for each group:
ebnm.group.res <- ebnm_group(
x, s, group,
prior_family = list(small_sd = "normal", large_sd = "normal_scale_mixture")
)
# Different modes and scales can be set similarly:
ebnm.group.res <- ebnm_group(
x, s, group,
mode = list(small_sd = 0, large_sd = "estimate"),
scale = list(small_sd = 1, large_sd = "estimate")
)