View source: R/deprec-smooth_cases.R
| smooth_cases | R Documentation |
This function is superseded by the more versatile
transform.scdf function.
The smooth_cases function provides procedures to smooth single-case
data (i.e., to eliminate noise). A moving average function (mean- or
median-based) replaces each data point by the average of the surrounding
data points step-by-step. With a local regression function, each data point
is regressed by its surrounding data points.
smooth_cases(data, dvar, mvar, method = "mean", intensity = NULL, FUN = NULL)
data |
A single-case data frame. See |
dvar |
Character string with the name of the dependent variable. Defaults to the attributes in the scdf file. |
mvar |
Character string with the name of the measurement time variable. Defaults to the attributes in the scdf file. |
method, FUN |
Method determining the smoothed scores. Default |
intensity |
For |
moving_median, moving_mean, and local_regression are
helper function for transform.scdf returning the smoothed
values of a numeric vector.
Returns a data frame (for each single-case) with smoothed data
points. See scdf to learn about the format of these data
frames.
Juergen Wilbert
Other data manipulation functions:
add_l2(),
as.data.frame.scdf(),
as_scdf(),
fill_missing(),
moving_median(),
print.sc_outlier(),
ranks(),
rescale(),
scdf(),
select_cases(),
set_vars(),
shift(),
standardize(),
truncate_phase()
## Use the three different smoothing functions and compare the results
study <- c(
"Original" = Huber2014$Berta,
"Moving median" = smooth_cases(Huber2014$Berta, method = "median"),
"Moving mean" = smooth_cases(Huber2014$Berta, method = "mean"),
"Local regression" = smooth_cases(Huber2014$Berta, method = "regression")
)
plot(study)
Huber2014$Berta |>
transform(
"compliance (moving median)" = moving_median(compliance),
"compliance (moving mean)" = moving_mean(compliance),
"compliance (local regression)" = local_regression(compliance, mt)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.