% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/wrappers.R
\name{ranef.brma}
\alias{ranef.brma}
\title{Random Effects for brma Objects}
\usage{
\method{ranef}{brma}(object, bias_adjusted = FALSE, probs = c(0.025, 0.975), ...)
}
\arguments{
\item{object}{a fitted brma object}

\item{bias_adjusted}{whether to adjust for publication bias. Defaults to
\code{FALSE}. See \code{\link{blup.brma}} for details.}

\item{probs}{quantiles of the posterior distribution to be displayed.
Defaults to \code{c(.025, .975)} for 95\% credible intervals.}

\item{...}{additional arguments forwarded to \code{\link{predict.brma}} for
supported options such as \code{conditional}. \code{newdata}, \code{type},
\code{quiet}, \code{output_measure}, and \code{transform} are controlled by
this method.}
}
\value{
For 2-level models, a \code{brma_samples} object. For 3-level
models, a named list of \code{brma_samples} objects (one per variance
component).
}
\description{
Extracts random effect deviations from a fitted brma object.
These are posterior-sample offsets from the fixed-effect predictions,
analogous to random-effect deviations returned by \code{metafor::ranef()}.
}
\details{
Random effects are computed as the difference between the true
effects (BLUPs) and the fixed-effect predictions:
\deqn{u_i = \hat{\theta}_i - \hat{\mu}_i}

For standard (2-level) models, returns a single \code{brma_samples}
object with the estimate-level random effects.

For multilevel (3-level) models, returns a list with two observation-aligned
\code{brma_samples} matrices, one column per estimate row:
\describe{
\item{\code{cluster}}{Cluster-level random effects
(\eqn{\gamma_j \cdot \tau_{between}}), representing between-cluster
deviations from the fixed effects.}
\item{\code{estimate}}{Estimate-level random effects
(\eqn{\theta_i - \mu_i - \gamma_j \cdot \tau_{between}}),
representing within-cluster deviations from the cluster means.}
}
}
\examples{
\dontrun{
if (requireNamespace("metadat", quietly = TRUE)) {
  data(dat.lehmann2018, package = "metadat")
  fit <- brma(
    yi      = yi,
    vi      = vi,
    data    = dat.lehmann2018,
    measure = "SMD",
    seed    = 1,
    silent  = TRUE
  )

  ranef(fit)
}
}

}
\seealso{
\code{\link[=blup.brma]{blup.brma()}}, \code{\link[=predict.brma]{predict.brma()}}, \code{\link[=pooled_effect]{pooled_effect()}}
}
