Generalized Additive Mixed Models Calculator – Free Online GAMM & GLMM Mixed Models Tool

Generalized Additive Mixed Models (GAMM) Calculator – Free Online GAMM & GLMM Mixed Models Tool
Statistical Models · Mixed Models

Generalized Additive Mixed Models (GAMM & GLMM) Calculator

Run a free generalized additive mixed model online. Estimate smooth-term effects, random-intercept variance, ICC, AIC, BIC, and adjusted R² across nested or longitudinal data — with APA-format results and four publication-ready visualization plots.

GAMM GLMM Random Effects Smooth Splines Free Online APA Format
Clusters
REML
Estimation
4
Plots
100%
Free

📥 Input Data

Enter each cluster (group / subject / site) as one comma-separated row of numeric responses (Y values). The predictor (X) is auto-generated as the position index 1, 2, 3, … per cluster (use the X-axis option below to relabel). You can rename each group and add or remove clusters as needed.

📂 Upload CSV or Excel file

Accepted: .csv, .txt, .xlsx, .xls. Click columns that should each become a cluster — selected columns will be loaded as separate clusters.

Add a row, type values one per cell, and click Use Manual Data. Each row becomes a separate cluster.

📈 GAMM Results

Detailed statistics

Visualization plots

📈 Fitted smooth + raw data

📊 Random effects (cluster intercepts)

🔬 Residual diagnostics

🎯 Q–Q plot of residuals

📐 Technical Notes & Formulas Used

A. Generalized Additive Mixed Model (GAMM) — model equation

y_ij = β₀ + f(x_ij) + u_j + ε_ij
Where:
y_ij = outcome for observation i in cluster j
β₀ = global intercept (fixed effect)
f(x_ij) = smooth (spline) function of predictor x — sum of basis functions
u_j ~ N(0, σ²_u) = random intercept for cluster j
ε_ij ~ N(0, σ²_ε) = residual error

B. Penalised regression spline (smooth term)

f(x) = Σ_{k=1}^{K} β_k · B_k(x) subject to penalty λ ∫ [f''(x)]² dx
B_k(x) = k-th cubic basis function (truncated power / B-spline)
K = basis dimension (user-set, see k in this tool)
λ = smoothing parameter chosen by REML / GCV
EDF = effective degrees of freedom = trace(F) where F is the influence matrix

C. Variance components (random-effect & ICC)

σ²_u = Var(cluster intercepts) σ²_ε = Var(within-cluster residuals) ICC = σ²_u / (σ²_u + σ²_ε)
σ²_u = between-cluster variance (group SD squared)
σ²_ε = within-cluster residual variance
ICC = intraclass correlation coefficient (0–1); higher → stronger clustering

D. Smooth-term significance test (approximate F)

F = (RSS_null − RSS_full) / EDF_smooth ÷ (RSS_full / df_resid)
RSS_null = residual sum of squares with intercept + random effect only
RSS_full = RSS with smooth term included
df_resid = n − EDF_smooth − number of clusters

E. Model fit indices

R²_marginal = Var(fixed) / [Var(fixed) + σ²_u + σ²_ε] R²_conditional = [Var(fixed) + σ²_u] / [Var(fixed) + σ²_u + σ²_ε] AIC = −2·logL + 2·(EDF + 2) BIC = −2·logL + log(n)·(EDF + 2)
R²_marginal = variance explained by fixed effects only (Nakagawa & Schielzeth, 2013)
R²_conditional = variance explained by fixed + random effects
logL = log-likelihood at REML estimates

F. Assumptions of GAMM / GLMM

  • Random effects are normally distributed: u_j ~ N(0, σ²_u)
  • Residuals are normally distributed and homoscedastic (for Gaussian GAMM)
  • Observations within clusters are exchangeable (no unmodelled time dependence beyond the smooth)
  • Smooth basis dimension k is large enough (rule: EDF should be well below k)
  • At least 5–10 clusters for the random effect to be identifiable
🎯 When to Use GAMM & GLMM Mixed Models

This free generalized additive mixed models calculator is designed for researchers analysing clustered, longitudinal, or repeated-measures data where the predictor's effect is expected to be non-linear. The smooth term captures curvature; the random effect captures cluster correlation. Together they replace the assumptions of plain OLS and standard GLM that fail under both.

Decision checklist

You have a continuous outcome variable Y
You have a continuous predictor X with possibly non-linear effect
Observations are nested (subjects, schools, sites, plots) — at least 5 clusters
You expect within-cluster correlation (repeated measures, longitudinal data)
Do NOT use if effect of X is clearly linear → use plain GLMM / LMM
Do NOT use if no clustering structure → use GAM (no random effect)
Do NOT use with fewer than 5 clusters → treat group as fixed factor (ANCOVA)
Do NOT use if outcome is binary or count → switch family to binomial / Poisson GAMM

Real-world examples

  1. Ecology — Modelling plant growth (height) as a non-linear function of light intensity across multiple greenhouses. Greenhouses are random; light effect is smooth.
  2. Education — Reading test scores over time across multiple schools. Time has a curve (early gain, plateau); schools are random clusters.
  3. Medicine — Heart-rate response to drug dose across patients in different hospitals. Dose-response is non-linear; hospitals are random.
  4. Climate science — Forest CO₂ flux as a smooth function of temperature, with random site effects across different sites.
  5. Animal behaviour — Bird song rate as a smooth function of hour-of-day with random territory effects.

Sample-size guidance

Per cluster: at least 5–10 observations per cluster. Number of clusters: at least 5–10 (Bolker et al., 2009 recommend ≥ 5). Total n: aim for ≥ 10 × k (basis dimension) per smooth term.

Decision tree — which model do I run?

Continuous Y → linear effect of X? → no clustering → OLS
↘ → nested data → LMM (linear mixed model)
↘ non-linear effect → no clustering → GAM
→ nested data → GAMM ← (this tool)
Binary / Count Y → linear, no nesting → GLM
→ linear, nested → GLMM
→ non-linear, nested → GAMM (binomial/Poisson family)
📘 How to Use This GAMM Mixed Models Calculator (Step-by-Step)
  1. Pick a sample dataset from the dropdown — Plant Growth loads on page open.
  2. Enter your own data by either typing one comma-separated row per cluster, uploading a CSV/Excel file, or using the manual grid.
  3. Rename clusters by clicking the group-name field at the top of each row.
  4. Label your axes using the X-axis name (predictor) and Y-axis name (outcome) inputs.
  5. Choose smoothness: set the basis dimension k (5 is default). Larger k = more flexible curve.
  6. Set random structure: random intercept only (default) or random intercept + slope.
  7. Set α to 0.05 (default), 0.01, or 0.10.
  8. Click "Run GAMM Analysis" — results, four plots, interpretation, and conclusion appear below.
  9. Read the interpretation — five auto-filled reporting templates (APA, thesis, plain language, abstract, pre-registration) sit ready to copy.
  10. Export the report as a .txt or save as PDF using the print dialog.

❓ Frequently Asked Questions

What is a generalized additive mixed model (GAMM) and when should I use it?
A generalized additive mixed model (GAMM) combines a generalized additive model with random effects from a mixed model. Use it when your outcome shows a non-linear relationship with a predictor and your data are clustered or repeated (e.g., subjects measured over time). The smooth term captures the curve; the random effect captures the cluster correlation. A typical use case is modelling plant growth as a smooth function of temperature across multiple field sites.
What is the difference between GAMM and GLMM?
A GLMM (generalized linear mixed model) fits straight-line predictor effects with random effects. A GAMM extends a GLMM by replacing those linear terms with smooth, flexible curves (penalised splines). If you suspect non-linearity in a predictor, GAMM is the right choice; if every effect is plausibly linear, GLMM is sufficient. You can compare them with AIC: a sizeable AIC drop from GLMM to GAMM indicates real curvature.
What does the smooth-term p-value mean in a GAMM?
The smooth-term p-value tests the null hypothesis that the smooth function is a flat horizontal line — that is, the predictor has no effect on the outcome. A small p-value (below α) means the predictor's relationship with the outcome is significantly non-flat, but it does not, by itself, tell you the shape of the relationship — for that, look at the EDF and the fitted curve.
How do I interpret the random-effect variance (group SD) in a mixed model?
The random-effect standard deviation tells you how much the outcome varies across clusters (subjects, sites, schools) after accounting for the fixed effects. A larger group SD means clusters differ more from each other; a small SD means they behave similarly. The intraclass correlation (ICC) re-expresses this as the proportion of total variance attributable to clusters — values above 0.10 typically justify a mixed model.
What is the ICC (intraclass correlation) in a GAMM or GLMM?
The ICC is the share of total variance in the outcome that is between clusters rather than within them. Computed as group variance divided by (group variance + residual variance). Values above 0.10 typically justify a mixed model; values near zero suggest a simple GAM or OLS would suffice. ICCs above 0.30 indicate strong clustering — the random effect is doing real work.
How is AIC used to compare GAMM models?
Akaike Information Criterion (AIC) balances model fit against complexity. Lower AIC is better. A difference greater than 2 between models is considered noticeable; greater than 10 is strong evidence in favour of the lower-AIC model. Use AIC to compare candidate GAMMs with different smoothness, different random structures, or against a GLMM benchmark.
What sample size do I need for a GAMM or mixed model?
As a practical guide, aim for at least 30 total observations per smooth term and at least 5–10 clusters (groups) for the random effect to be estimable. With fewer than 5 groups, the variance component is poorly identified — consider treating the grouping factor as fixed instead. Total observations should be at least 10 times the basis dimension k.
Can I use this calculator for published research?
This tool is suitable for teaching, exploratory analysis, and assignment work. For peer-reviewed publication, validate results in mgcv::gamm() or gamm4::gamm4() in R, or pyGAM in Python, which provide full smooth-term inference, REML, and diagnostic plots. Cite the tool as: STATS UNLOCK. (2025). Generalized additive mixed models calculator. https://statsunlock.com.
What does effective degrees of freedom (EDF) mean?
Effective degrees of freedom (EDF) summarise the complexity of a fitted smooth. EDF = 1 corresponds to a straight line; EDF = 2 a gentle curve; EDF > 4 a strongly wiggly fit. EDF near the basis dimension (k) suggests you may need a larger k. EDF is the trace of the influence matrix and lies between 0 and k.
How do I report GAMM results in APA 7th format?
Report the smooth-term test as F(EDF, residual df) = ___, p = ___, the random-effect standard deviation, model AIC, and adjusted R². For example: "A GAMM with random intercepts for greenhouse revealed a significant smooth effect of light intensity on plant growth, F(3.42, 24.1) = 8.91, p < .001, R²ₐ = .67." See the Results-writing section above for five auto-filled templates.
📚 References

The following references support the statistical methods used in this generalized additive mixed models calculator, covering GLMM mixed models, smooth-term significance testing, and best practices in hypothesis testing and reporting.

  1. Wood, S. N. (2017). Generalized additive models: An introduction with R (2nd ed.). Chapman & Hall/CRC. https://doi.org/10.1201/9781315370279
  2. Wood, S. N. (2011). Fast stable restricted maximum likelihood and marginal likelihood estimation of semiparametric generalized linear models. Journal of the Royal Statistical Society: Series B, 73(1), 3–36. https://doi.org/10.1111/j.1467-9868.2010.00749.x
  3. Lin, X., & Zhang, D. (1999). Inference in generalized additive mixed models by using smoothing splines. Journal of the Royal Statistical Society: Series B, 61(2), 381–400. https://doi.org/10.1111/1467-9868.00183
  4. Pedersen, E. J., Miller, D. L., Simpson, G. L., & Ross, N. (2019). Hierarchical generalized additive models in ecology: An introduction with mgcv. PeerJ, 7, e6876. https://doi.org/10.7717/peerj.6876
  5. Bolker, B. M., Brooks, M. E., Clark, C. J., Geange, S. W., Poulsen, J. R., Stevens, M. H. H., & White, J.-S. S. (2009). Generalized linear mixed models: A practical guide for ecology and evolution. Trends in Ecology & Evolution, 24(3), 127–135. https://doi.org/10.1016/j.tree.2008.10.008
  6. Nakagawa, S., & Schielzeth, H. (2013). A general and simple method for obtaining R² from generalized linear mixed-effects models. Methods in Ecology and Evolution, 4(2), 133–142. https://doi.org/10.1111/j.2041-210x.2012.00261.x
  7. Zuur, A. F., Ieno, E. N., Walker, N. J., Saveliev, A. A., & Smith, G. M. (2009). Mixed effects models and extensions in ecology with R. Springer. https://doi.org/10.1007/978-0-387-87458-6
  8. Hastie, T., & Tibshirani, R. (1990). Generalized additive models. Chapman & Hall.
  9. Pinheiro, J. C., & Bates, D. M. (2000). Mixed-effects models in S and S-PLUS. Springer. https://doi.org/10.1007/b98882
  10. Bates, D., Mächler, M., Bolker, B., & Walker, S. (2015). Fitting linear mixed-effects models using lme4. Journal of Statistical Software, 67(1), 1–48. https://doi.org/10.18637/jss.v067.i01
  11. Harrison, X. A., Donaldson, L., Correa-Cano, M. E., Evans, J., Fisher, D. N., Goodwin, C. E. D., Robinson, B. S., Hodgson, D. J., & Inger, R. (2018). A brief introduction to mixed effects modelling and multi-model inference in ecology. PeerJ, 6, e4794. https://doi.org/10.7717/peerj.4794
  12. Simpson, G. L. (2018). Modelling palaeoecological time series using generalised additive models. Frontiers in Ecology and Evolution, 6, 149. https://doi.org/10.3389/fevo.2018.00149
  13. American Psychological Association. (2020). Publication manual of the American Psychological Association (7th ed.). APA. https://doi.org/10.1037/0000165-000
  14. R Core Team. (2024). R: A language and environment for statistical computing. R Foundation for Statistical Computing. https://www.R-project.org/
  15. Wood, S. N. (2024). mgcv: Mixed GAM computation vehicle with automatic smoothness estimation [R package version 1.9-1]. https://cran.r-project.org/package=mgcv

Leave a Reply

Your email address will not be published. Required fields are marked *

Previous Post
Next Post

© 2026 STATS UNLOCK . statsunlock.com –  All Rights Reserved.