% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/predictInterval_helpers.R
\name{simulate_random_effects}
\alias{simulate_random_effects}
\title{Simulate random‑effect contributions for all grouping factors}
\usage{
simulate_random_effects(
  merMod,
  newdata,
  n.sims,
  .parallel = FALSE,
  seed = NULL,
  new.levels = c("zero", "draw")
)
}
\arguments{
\item{merMod}{A merMod object.}

\item{newdata}{Data frame containing the prediction covariates.}

\item{n.sims}{Number of simulations.}

\item{.parallel}{Logical flag to enable parallel execution via foreach.}

\item{seed}{Optional random seed for reproducibility.}

\item{new.levels}{Character; how to treat grouping levels present in
`newdata` but absent from the fitted model. `"zero"` drops the random
effect for such levels; `"draw"` samples each unobserved level's effect
from the estimated random-effect covariance (`VarCorr`).}
}
\value{
List of matrices (rows = observations, cols = simulations).
}
\description{
For each random effect term the function draws `n.sims` samples from the
conditional multivariate normal distribution (BLUPs + post‑var). The result is a
named list where each element is an array of dimensions `nrow(newdata)` ×
`n.sims`.
}
