Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

smooth_cases

Smoothing single-case data


Description

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.

Usage

smooth_cases(data, dvar, mvar, FUN = "movingMedian", intensity = NULL)

smoothSC(...)

Arguments

data

A single-case data frame. See scdf to learn about this format.

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.

FUN

Function determining the smoothed scores. Default FUN = "movingMedian" is a moving Median function. Further possible values are: "movingMean" and a non-parametric "localRegression".

intensity

For FUN = "movingMedian" and "movingMean" it is the lag used for computing the average. Default is intensity = 1. In case of FUN = "localRegression" it is the proportion of surrounding data influencing each data point, which is intensity = 0.2 by default.

...

Further arguments passed to the function.

Value

Returns a data frame (for each single-case) with smoothed data points. See scdf to learn about the format of these data frames.

Author(s)

Juergen Wilbert

See Also

Other data manipulation functions: fill_missing(), longSCDF(), outlier(), ranks(), shift(), standardize(), truncate_phase()

Examples

## Use the three different smoothing functions and compare the results
study <- c(
  "Original" = Huber2014$Berta,
  "Moving Median" = smooth_cases(Huber2014$Berta, FUN = "movingMedian"),
  "Moving Mean" = smooth_cases(Huber2014$Berta, FUN = "movingMean"),
  "Local Regression" = smooth_cases(Huber2014$Berta, FUN = "localRegression")
)
plot(study)

scan

Single-Case Data Analyses for Single and Multiple Baseline Designs

v0.51
GPL
Authors
Juergen Wilbert [aut, cre], Timo Lueke [aut]
Initial release
2021-2-11

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.