rfastlowess provides three execution modes for different
data sizes and processing needs:
| Mode | Class | Use Case | Memory | Key Features |
|---|---|---|---|---|
| Batch | Lowess |
Full dataset | Entire dataset | CI, PI, CV, GPU |
| Streaming | StreamingLowess |
>100K points | Per chunk | With overlap |
| Online | OnlineLowess |
Live / real-time | Sliding window | Per-point |
| Situation | Mode |
|---|---|
| Data fits in memory; needs intervals or CV | Batch |
| Data too large for memory or arrives in chunks | Streaming |
| Data arrives point-by-point in real time | Online |
Standard mode for complete datasets. Supports all features.
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,
iterations = 3,
parallel = TRUE,
outputs = "diagnostics",
intervals = intervals_opts(confidence = 0.90, prediction = 0.99)
)
result <- fit(model, x, y)
cat("95% CI at midpoint: [", result$confidence_lower[50], ", ",
result$confidence_upper[50], "]\n")
#> 95% CI at midpoint: [ -0.03081586 , 0.1081906 ]Process large datasets in chunks with configurable overlap.
| Parameter | Default | Description |
|---|---|---|
chunk_size |
5000 | Points per chunk |
overlap |
chunk_size / 10 |
Overlap between chunks |
merge_strategy |
"weighted_average" |
How to merge overlaps |
| Strategy | Behavior |
|---|---|
"average" |
Average overlapping values |
"weighted_average" |
Distance-weighted blend |
"take_first" |
Keep left chunk values |
"take_last" |
Keep right chunk values |
library(rfastlowess)
x <- seq(0, 2 * pi, length.out = 100)
y <- sin(x) + 0.1
model <- StreamingLowess(
fraction = 0.3,
iterations = 2,
chunk_size = 5000,
overlap = 500,
merge_strategy = "average"
)
process_chunk(model, x, y)
#> <LowessResult>
#> Points: 0
#> Fraction Used: 0.3
#> Iterations Used: 2
result <- finalize(model)
cat("Smoothed y[0]:", result$y[1], "\n")
#> Smoothed y[0]: 0.2577957Always call finalize(): The streaming adapter buffers overlap data. Call
finalize(model)after the last chunk to retrieve the buffered tail.
Incremental updates with a sliding window for real-time data.
| Parameter | Default | Description |
|---|---|---|
window_capacity |
1000 | Max points in window |
min_points |
2 | Points before output starts |
update_mode |
"incremental" |
Update strategy |
| Mode | Behavior | Speed |
|---|---|---|
"incremental" |
Update only affected fits | Faster |
"full" |
Recompute entire window | More accurate |
library(rfastlowess)
x <- seq(0, 2 * pi, length.out = 100)
y <- sin(x) + 0.1
model <- OnlineLowess(
fraction = 0.2,
window_capacity = 100,
min_points = 5,
update_mode = "incremental"
)
shown <- 0
for (i in seq_along(x)) {
result <- add_point(model, x[i], y[i])
if (!is.null(result) && shown < 5) {
cat("Current smoothed value:", result$y, "\n")
shown <- shown + 1
}
}
#> Current smoothed value: 0.351148
#> Current smoothed value: 0.4120334
#> Current smoothed value: 0.4716625
#> Current smoothed value: 0.5297949
#> Current smoothed value: 0.5861967| Feature | Batch | Streaming | Online |
|---|---|---|---|
| Parallel execution | ✓ | ✓ | ✗ |
| Diagnostics | ✓ | ✓ | ✗ |
| Residuals | ✓ | ✓ | ✓ |
| Robustness weights | ✓ | ✓ | ✓ |
| Confidence intervals | ✓ | ✗ | ✗ |
| Prediction intervals | ✓ | ✗ | ✗ |
| Cross-validation | ✓ | ✗ | ✗ |
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