% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/hatvalues.R
\name{hatvalues.brma}
\alias{hatvalues.brma}
\title{Hat Values for brma Objects}
\usage{
\method{hatvalues}{brma}(model, ...)
}
\arguments{
\item{model}{a fitted brma object}

\item{...}{additional arguments (currently ignored)}
}
\value{
A numeric vector of length \code{K}, one posterior mean leverage per
observation.
}
\description{
Computes hat values (leverages) from a fitted brma object.
Returns posterior mean leverages, one for each observation.
}
\details{
Hat values (leverages) measure the influence of each observation on the
fitted values. In a Bayesian meta-analysis, the random effects variance \eqn{\tau^2}
is uncertain, so the hat matrix depends on the posterior samples of \eqn{\tau^2}.

This function computes the diagonal elements of the hat matrix:
\deqn{h_i = (X (X^T W X)^{-1} X^T W)_{ii}}
where \eqn{W} is the weight matrix inverse to the marginal variance matrix.

The hat matrix is computed for each posterior draw and then averaged over
draws, matching the vector output shape used by \code{metafor}.

This method is available only for normal outcome models without
weightfunction selection.
}
\examples{
\dontrun{
if (requireNamespace("metadat", quietly = TRUE) &&
    requireNamespace("metafor", quietly = TRUE)) {
  data(dat.bcg, package = "metadat")
  dat <- metafor::escalc(
    measure = "RR",
    ai      = tpos,
    bi      = tneg,
    ci      = cpos,
    di      = cneg,
    data    = dat.bcg
  )

  fit <- brma(yi = yi, vi = vi, data = dat, measure = "RR")
  hatvalues(fit)
}
}

}
