--- title: "Likelihood-based inference" author: "metaGLMM authors" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Likelihood-based inference} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r setup, include=FALSE} knitr::opts_chunk$set(collapse = TRUE, comment = "#>", fig.width = 6, fig.height = 4) set.seed(20260821) library(metaGLMM) ``` ## Fit a model This example uses the same aggregate-data contract for a small Gaussian random-effects model. ```{r data-fit} dat <- data.frame( study = paste0("Study ", 1:8), estimate = c(-0.80, -0.30, 0.10, 0.70, 1.10, -0.50, 0.40, 1.30), moderator = c(0, 1, 0, 1, 0, 1, 0, 1), vi = c(0.04, 0.05, 0.03, 0.06, 0.04, 0.05, 0.03, 0.05), ni = c(100, 90, 120, 80, 110, 95, 130, 85) ) fit <- metaGLMM( estimate ~ moderator, data = dat, vi = dat$vi, ni = dat$ni, tau2 = NA, tau2_var = TRUE, family = gaussian(link = "identity"), fast = TRUE ) summary(fit) ``` ## Wald intervals The default interval is based on the fixed-effect estimate and its covariance matrix. Specify a coefficient with `parm` or request all fixed effects. ```{r wald} confint(fit, method = "wald") confint(fit, parm = "moderator", level = 0.90, method = "wald") ``` ## Profile and SBC intervals The official `confint()` interface accepts three method names: `"wald"`, `"profile"`, and `"SBC"`. Names are case-insensitive and intervals target fixed effects. Profile evaluation re-optimizes the nuisance parameters at each fixed-effect value; SBC applies the simple small-sample correction to the profile cutoff. ```{r profile, eval=FALSE} profile_ci <- confint(fit, parm = "moderator", method = "profile", level = 0.95) profile_ci sbc_ci <- confint(fit, parm = "moderator", method = "SBC", level = 0.95) sbc_ci ``` The profile and SBC calculations are more expensive than Wald intervals. For a larger analysis, use a fixed QMC sequence and record the optimizer settings along with the fitted object. ## Inspecting the likelihood fit The standard methods keep the fixed-effect interface separate from heterogeneity parameters. ```{r methods} coef(fit) vcov(fit) logLik(fit) nobs(fit) fit$tau2 fit$tau stopifnot(is.finite(fit$tau), fit$tau > 0) ``` A method value outside the three documented choices is rejected rather than silently selecting a different interval procedure. The legacy `ci_metaGLMM()` and low-level profile helpers remain available for existing scripts, but new code should use `confint()`.