phplyr

Models

Verification

Scope

lm() and glm() coefficients, lmer() fixed effects, and the lmer() residual standard deviation, fitted through the phit extension. Compared with R's lm() and glm() and lme4's lmer().

References

Reference
R 4.6.1 with lme4 2.0.6
Versions
R 4.6.1, lme4 2.0.6, PHP 8.5.10, phibble v0.8.0 (9e63ca5), phit 0.5.1

Data

schools.csv
250 rows: school, study_hours, prior_score, score. Source
learning.csv
80 rows: study_hours, practice_score, passed. Source

Method

Reference results computed in R by tests/r/models.R and expr.R and stored in tests/Fixtures/. The same operations run in phplyr in tests/ModelsTest.php and tests/ExprTest.php, which compare every value. Values compared is the number of assertions in a case; a case fails if any assertion fails.

Check
Comparison with a reference implementation
Recorded
2026-11-02, PHP 8.5.10, macOS (arm64), commit 65e6a46

Tolerances

|x − r| ≤ 1e-6 + 1e-6 × max(|r|, 1)

Applies to: Coefficients and fixed effects

|x − r| ≤ 1e-5

Applies to: Residual standard deviation

Lmer()

x: package value; r: reference value. Absolute error: |x − r|. Relative error: |x − r| / max(|r|, 1). Max errors are over the values a row compares.

Results

5 comparisons: 5 pass, 0 fail, 0 skipped.

Every comparison
Case Quantity Criterion Values Package value Reference value Max abs. error Max rel. error Status
Fits mixed models like lme4 Coefficients |x − r| ≤ 1e-6 + 1e-6 × max(|r|, 1) 4 1.6e-8 3.4e-10 pass
Estimates the residual SD of a mixed model like lme4 Residual standard deviation |x − r| ≤ 1e-5 1 5.056605669 5.056605649 2.0e-8 4.0e-9 pass
lm(score ~ study_hours + prior_score + school) on schools Coefficients |x − r| ≤ 1e-6 + 1e-6 × max(|r|, 1) 15 2.8e-14 4.6e-15 pass
lm(score ~ study_hours) on schools with prior_score > 60 Coefficients |x − r| ≤ 1e-6 + 1e-6 × max(|r|, 1) 3 7.1e-15 4.5e-16 pass
glm(passed ~ study_hours + practice_score, binomial) on learning Coefficients |x − r| ≤ 1e-6 + 1e-6 × max(|r|, 1) 4 3.3e-12 1.0e-12 pass

Limitations

Exclusions

  • glmer() is not compared with lme4.
  • phit-polyfill is not compared with R; the Models benchmark compares its coefficients with the extension's.

Reproduction

From the repository root
Rscript tests/r/models.R
Rscript tests/r/expr.R
bin/site-verifications
Raw record
site/verifications/models.json
Input data
tests/Fixtures