phiz

Smoothing

Verification

Scope

Least-squares coefficients, standard errors, and confidence bands; loess fits, standard errors, degrees of freedom, residual standard errors, and confidence bands. Identical inputs and evaluation points across implementations.

References

Reference
R 4.6.1: lm(), predict(), loess(surface = "direct", statistics = "exact")
Versions
R 4.6.1

Data

mtcars
32 rows, R's datasets package
mpg
234 rows, ggplot2 4.0.3

Method

scripts/evidence/r-references.R computes the reference values in R and writes tests/fixtures/r-references.json. scripts/evidence/parity.php computes the same quantities with phiz's PHP implementations behind smooth() and compares them value by value.

Check
Comparison with a reference implementation
Recorded
2026-11-02, PHP 8.5.11, Debian GNU/Linux 13 (trixie) (aarch64), commit b9272c6

Tolerances

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

Applies to: Numerical results

Fits, quantiles, intervals, and polygon points

exact equality

Applies to: Counts, levels, piece sizes, and colors

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

Results

13 comparisons in 3 cases: 13 pass, 0 fail, 0 skipped.

By case

Results by case
Case Comparisons Largest abs. error Largest rel. error Status
mtcars, mpg ~ wt 4 2.1e-13 9.8e-15 pass
mpg, hwy ~ displ, loess span 0.75 degree 2 5 1.6e-11 6.9e-14 pass
mpg, hwy ~ displ, loess span 1.5 degree 1 4 3.8e-12 1.8e-14 pass

Every comparison

Every comparison
Case Quantity Criterion Values Package value Reference value Max abs. error Max rel. error Status
mtcars, mpg ~ wt lm coefficients |x − r| ≤ 1e-9 + 1e-9 × max(|r|, 1e-12) 2 2.1e-13 9.8e-15 pass
lm standard errors |x − r| ≤ 1e-9 + 1e-9 × max(|r|, 1e-12) 2 6.7e-15 3.8e-15 pass
residual degrees of freedom exact equality 1 30 30 pass
90% band at the ends of wt: fit, lower, upper |x − r| ≤ 1e-9 + 1e-9 × max(|r|, 1e-12) 6 7.1e-15 6.7e-16 pass
mpg, hwy ~ displ, loess span 0.75 degree 2 fit at 5 points |x − r| ≤ 1e-9 + 1e-9 × max(|r|, 1e-12) 5 8.3e-13 2.5e-14 pass
standard errors at 5 points |x − r| ≤ 1e-9 + 1e-9 × max(|r|, 1e-12) 5 1.3e-13 6.5e-14 pass
degrees of freedom of the t interval |x − r| ≤ 1e-9 + 1e-9 × max(|r|, 1e-12) 1 228.8880627 228.8880627 1.6e-11 6.9e-14 pass
residual standard error |x − r| ≤ 1e-9 + 1e-9 × max(|r|, 1e-12) 1 3.372111038 3.372111038 2.2e-14 6.6e-15 pass
95% band at the ends of displ: lower, upper |x − r| ≤ 1e-9 + 1e-9 × max(|r|, 1e-12) 4 1.0e-12 3.6e-14 pass
mpg, hwy ~ displ, loess span 1.5 degree 1 fit at 5 points |x − r| ≤ 1e-9 + 1e-9 × max(|r|, 1e-12) 5 1.1e-13 9.0e-15 pass
standard errors at 5 points |x − r| ≤ 1e-9 + 1e-9 × max(|r|, 1e-12) 5 1.4e-14 1.8e-14 pass
degrees of freedom of the t interval |x − r| ≤ 1e-9 + 1e-9 × max(|r|, 1e-12) 1 231.8607268 231.8607268 3.8e-12 1.7e-14 pass
residual standard error |x − r| ≤ 1e-9 + 1e-9 × max(|r|, 1e-12) 1 3.692445905 3.692445905 4.4e-15 1.2e-15 pass

Limitations

Known differences

  • ggplot2's geom_smooth() interpolates the loess surface; phiz computes it directly, as loess(surface = "direct") does. ggplot2's curve can therefore differ slightly.

Reproduction

From the repository root
Rscript scripts/evidence/r-references.R
php scripts/evidence-parity.php
Raw record
site/verifications/r-smoothing.json
Full results
site/verifications/r-smoothing.json
Input data
tests/fixtures/r-references.json