fit_smoothing_parameters: Fit parameters for LOESS data smoothing

View source: R/17-fit_smoothing_parameters.R

fit_smoothing_parametersR Documentation

Fit parameters for LOESS data smoothing

Description

This function fits the span and degree parameters for the LOESS data smoothing method by testing different combinations of span and degree values and selecting the best parameters based on the R² value.

Usage

fit_smoothing_parameters(
  x,
  time,
  threads = 10,
  span_values = seq(0.1, 0.5, by = 0.01),
  degree_values = 1:2,
  progressbar = TRUE,
  seed = 123
)

Arguments

x

A numeric vector of values to be smoothed.

time

A numeric vector of timestamps corresponding to x. (POSIXct)

span_values

A numeric vector of span values to test (default is seq(0.1, 0.5, by = 0.01)).

degree_values

A numeric vector of degree values to test (default is 1:2).

seed

An integer for the random seed (default is 123).

Value

A list of the best span and degree parameters for the LOESS data smoothing method.

Author(s)

Zirui Qiang list("zirui_qiang@outlook.com")

Minghang Li list("minghli@ethz.ch")

Examples

data("step_data", package = "laggedcor")
best_params <- fit_smoothing_parameters(x = step_data$step,
                                        time = step_data$time)
best_params


jaspershen/laggedcor documentation built on June 10, 2025, 5:42 p.m.