mixed
Fit linear mixed-effects models to analyze clustered or nested data, estimating fixed and random effects with selectable covariance structures.
Instructions
Fit a linear mixed-effects model. Validation: certified parity evidence. Assumptions: Continuous outcome, linear in fixed effects; Random effects (intercepts/slopes) normally distributed with the chosen covariance structure; Residuals normal and homoscedastic conditional on random effects; random effects independent of covariates. Pre-conditions: Continuous outcome; Grouping variable (or nested list of grouping levels) for random effects. Failure modes: REML/ML optimizer fails to converge with rich random-slope covariance -> Switch cov_type to 'diagonal' or 'identity', or drop random slopes; Singular covariance (boundary variance estimate) -> Simplify the random-effects covariance or remove the offending random term; Binary or count outcome passed to a linear model -> Use a generalized mixed model for the appropriate family. Alternatives: sp.regress, sp.melogit, sp.feols. Typical minimum N: 200.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| y | Yes | Dependent variable column. | |
| tol | No | Optimiser controls and inference significance level. The defaults use a tight likelihood tolerance so REML variance components and ICC agree with R ``lme4`` / Stata ``mixed`` on parity fixtures. | |
| alpha | No | Optimiser controls and inference significance level. The defaults use a tight likelihood tolerance so REML variance components and ICC agree with R ``lme4`` / Stata ``mixed`` on parity fixtures. | |
| group | Yes | Grouping variable. Pass a list like ``["school", "class"]`` to estimate a three-level nested model -- the innermost level is used as the cluster for the random slopes/intercept; the outer levels enter as additional random-intercept blocks. | |
| 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 |
| method | No | ``'reml'`` (default) or ``'ml'``. | reml |
| maxiter | No | Optimiser controls and inference significance level. The defaults use a tight likelihood tolerance so REML variance components and ICC agree with R ``lme4`` / Stata ``mixed`` on parity fixtures. | |
| x_fixed | Yes | Fixed-effect regressors (intercept is added automatically). | |
| cov_type | No | Parameterisation of the random-effect covariance matrix *G*: ``'unstructured'`` (default), ``'diagonal'``, or ``'identity'``. | unstructured |
| x_random | No | Random-slope variables. ``None`` => 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 | |||