meglm
Fit generalized linear mixed models to analyze grouped data, estimating fixed and random effects to support evidence-backed causal decision-making.
Instructions
Fit a generalised linear mixed model.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| y | Yes | Outcome column. For binomial models this is the number of successes; pair it with ``trials=`` to model proportions. | |
| tol | No | Optimisation controls / CI width. The default ``tol=1e-8`` keeps the Laplace fixed-effect solution aligned with lme4/Stata reference likelihood optima on the parity fixtures. For AGHQ (``nAGQ > 1``), the default optimiser budget is internally tightened to ``maxiter=5000`` and ``tol=1e-12``; explicit user-supplied controls are respected. | |
| nAGQ | No | Number of adaptive Gauss-Hermite quadrature points per scalar random effect. ``1`` (default) == Laplace approximation. Use ``nAGQ=7`` to match Stata ``meglm intpoints(7)``; values ``> 1`` require a single scalar random effect (no random slopes). | |
| alpha | No | Optimisation controls / CI width. The default ``tol=1e-8`` keeps the Laplace fixed-effect solution aligned with lme4/Stata reference likelihood optima on the parity fixtures. For AGHQ (``nAGQ > 1``), the default optimiser budget is internally tightened to ``maxiter=5000`` and ``tol=1e-12``; explicit user-supplied controls are respected. | |
| group | Yes | Grouping variable for random effects. | |
| detail | No | Payload depth: 'minimal' (~150 tokens) for sub-step calls where only the point estimate is needed; 'standard' (~1K tokens) for diagnostics + coefficient table; 'agent' (~2K tokens, default) adds violations / next_steps / suggested_functions so the LLM can plan its next call without another round-trip. | agent |
| family | No | ``'gaussian'``, ``'binomial'``, ``'poisson'``, ``'gamma'``, or ``'nbinomial'`` (alias ``'negbin'``). | gaussian |
| offset | No | Column of fixed offsets added to the linear predictor (e.g. ``log(exposure)`` for Poisson rate models). | |
| trials | No | Column of trial counts for binomial responses. Defaults to 1 (Bernoulli). | |
| maxiter | No | Optimisation controls / CI width. The default ``tol=1e-8`` keeps the Laplace fixed-effect solution aligned with lme4/Stata reference likelihood optima on the parity fixtures. For AGHQ (``nAGQ > 1``), the default optimiser budget is internally tightened to ``maxiter=5000`` and ``tol=1e-12``; explicit user-supplied controls are respected. | |
| x_fixed | Yes | Fixed-effect regressors (intercept added automatically). | |
| cov_type | No | Random-effect covariance: ``'unstructured'`` (default), ``'diagonal'``, ``'identity'``. | unstructured |
| x_random | No | Random-slope variables; defaults to random intercept only. | |
| as_handle | No | If true, cache the fitted result on the server and return result_id + result_uri alongside the JSON payload so a subsequent tools/call can chain without re-running. | |
| data_path | Yes | Absolute path or URL to a data file. Supported: .csv / .tsv / .txt (delimited), .parquet / .pq, .feather / .arrow, .xlsx / .xls, .dta (Stata), .json / .jsonl. Schemes: file://, s3://, gs://, https://. | |
| result_id | No | Optional handle to a previously-fitted result (returned by an earlier call when as_handle=true). Tools that operate on a fitted object accept this in place of re-supplying data_path + columns. | |
| data_columns | No | Optional column projection. Parquet/Feather/Stata loaders honour this for fast partial reads. | |
| data_sample_n | No | Optional uniform random subsample size (seed=0, deterministic) — useful on huge panels. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||