Adapter support: Confidence and prediction intervals are available in Batch mode, Streaming mode (computed per chunk and merged across overlap boundaries via
merge_strategy, likey/derivative), and Online mode whenupdate_mode = "full"is set (errors if combined with the default"incremental"mode).
Confidence and prediction coverage levels are independent; for example, a 90% confidence interval can be paired with a 99% prediction interval.
| Type | Represents | Width | Use |
|---|---|---|---|
| Confidence | Uncertainty in mean curve | Narrow | Trend location |
| Prediction | Uncertainty for new points | Wide | New data location |
Estimate uncertainty in the smoothed curve itself.
library(rfastlowess)
set.seed(42)
x <- seq(0, 2 * pi, length.out = 100)
y <- sin(x) + rnorm(100, sd = 0.3)
model <- Lowess(fraction = 0.5, intervals = intervals_opts(confidence = 0.95))
result <- fit(model, x, y)
# Plot with bands
plot(x, y, pch = 16, col = "gray",
main = "LOWESS with 95% Confidence Intervals")
lines(result$x, result$y, col = "blue", lwd = 2)
lines(result$x, result$confidence_lower, col = "blue", lty = 2)
lines(result$x, result$confidence_upper, col = "blue", lty = 2)
cat("95% CI at midpoint: [", result$confidence_lower[50], ", ",
result$confidence_upper[50], "]\n")
#> 95% CI at midpoint: [ -0.04412499 , 0.1214997 ]Estimate where new observations might fall.
library(rfastlowess)
set.seed(42)
x <- seq(0, 2 * pi, length.out = 100)
y <- sin(x) + rnorm(100, sd = 0.3)
model <- Lowess(fraction = 0.5, intervals = intervals_opts(prediction = 0.95))
result <- fit(model, x, y)
plot(x, y, pch = 16, col = "gray",
main = "LOWESS with 95% Prediction Intervals")
lines(result$x, result$y, col = "blue", lwd = 2)
lines(result$x, result$prediction_lower, col = "red", lty = 2)
lines(result$x, result$prediction_upper, col = "red", lty = 2)
cat("Prediction bounds: [", result$prediction_lower[1], ", ",
result$prediction_upper[1], "]\n")
#> Prediction bounds: [ -0.1513472 , 1.114249 ]Request both types simultaneously:
library(rfastlowess)
set.seed(42)
x <- seq(0, 2 * pi, length.out = 100)
y <- sin(x) + rnorm(100, sd = 0.3)
model <- Lowess(
fraction = 0.5,
intervals = intervals_opts(confidence = 0.90, prediction = 0.99)
)
result <- fit(model, x, y)
plot(x, y, pch = 16, col = "gray",
main = "Confidence vs Prediction Intervals")
lines(result$x, result$y, col = "blue", lwd = 2)
# Confidence interval (narrow, blue)
lines(result$x, result$confidence_lower, col = "blue", lty = 2)
lines(result$x, result$confidence_upper, col = "blue", lty = 2)
# Prediction interval (wide, red)
lines(result$x, result$prediction_lower, col = "red", lty = 3)
lines(result$x, result$prediction_upper, col = "red", lty = 3)
legend("topright",
c("Data", "Smoothed", "95% CI", "95% PI"),
pch = c(16, NA, NA, NA), lty = c(NA, 1, 2, 3),
col = c("gray", "blue", "blue", "red"))
cat("95% CI at midpoint: [", result$confidence_lower[50], ", ",
result$confidence_upper[50], "]\n")
#> 95% CI at midpoint: [ -0.03081586 , 0.1081906 ]Common levels and their z-values:
| Level | z-value | Interpretation |
|---|---|---|
| 0.90 | 1.645 | 90% of intervals contain true value |
| 0.95 | 1.960 | 95% of intervals contain true value |
| 0.99 | 2.576 | 99% of intervals contain true value |
# 99% confidence interval
model <- Lowess(fraction = 0.5, intervals = intervals_opts(confidence = 0.99))
result <- fit(model, x, y)
cat("99% CI at midpoint: [", result$confidence_lower[50], ", ",
result$confidence_upper[50], "]\n")
#> 99% CI at midpoint: [ -0.07015174 , 0.1475265 ]Set bootstrap to compute intervals from resampled fits
instead of the analytic formula. Pass seed for reproducible
resampling:
model <- Lowess(
fraction = 0.5,
intervals = intervals_opts(
confidence = 0.95,
prediction = 0.95,
bootstrap = 200
),
seed = 42
)
result <- fit(model, x, y)
cat("Bootstrap 95% CI at midpoint: [", result$confidence_lower[50], ", ",
result$confidence_upper[50], "]\n")
#> Bootstrap 95% CI at midpoint: [ -0.07091939 , 0.1507282 ]The same intervals and seed arguments are
accepted by StreamingLowess(), OnlineLowess(),
and predict().
Access standard errors directly (available when intervals are computed):
model <- Lowess(fraction = 0.5, outputs = "se")
result <- fit(model, x, y)
cat("Standard errors (first 5):", head(result$standard_errors, 5), "\n")
#> Standard errors (first 5): 0.03763669 0.03931471 0.04100582 0.04268883 0.04433928Supported In All Three Adapters: Confidence and prediction intervals are available in Batch, Streaming, and Online mode (
update_mode = "full"only).
| Feature | Batch | Streaming | Online |
|---|---|---|---|
| Standard errors | ✓ | ✓ | ✓ (update_mode = "full" only) |
| Confidence intervals | ✓ | ✓ | ✓ (update_mode = "full" only) |
| Prediction intervals | ✓ | ✓ | ✓ (update_mode = "full" only) |
sessionInfo()
#> R version 4.6.1 (2026-06-24)
#> Platform: x86_64-pc-linux-gnu
#> Running under: Ubuntu 26.04.1 LTS
#>
#> Matrix products: default
#> BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
#> LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.32.so; LAPACK version 3.12.0
#>
#> locale:
#> [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
#> [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
#> [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
#> [7] LC_PAPER=en_US.UTF-8 LC_NAME=C
#> [9] LC_ADDRESS=C LC_TELEPHONE=C
#> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
#>
#> time zone: Etc/UTC
#> tzcode source: system (glibc)
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] rfastlowess_5.0.0 rmarkdown_2.32
#>
#> loaded via a namespace (and not attached):
#> [1] digest_0.6.39 R6_2.6.1 fastmap_1.2.0 xfun_0.61
#> [5] maketools_1.3.2 cachem_1.1.0 knitr_1.52 htmltools_0.5.9
#> [9] buildtools_1.0.0 lifecycle_1.0.5 cli_3.6.6 sass_0.4.10
#> [13] jquerylib_0.1.4 compiler_4.6.1 sys_3.4.3 tools_4.6.1
#> [17] evaluate_1.0.5 bslib_0.12.0 yaml_2.3.12 otel_0.2.0
#> [21] jsonlite_2.0.0 rlang_1.3.0