Learn R Programming

scan (version 0.20)

smoothSC: Smoothing single-case data

Description

The smoothSC 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

smoothSC(data, FUN = "movingMedian", intensity = NULL)

Arguments

data

A single-case data frame or a list of single-case data frames. See makeSCDF to learn about this format.

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.

Value

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

Examples

Run this code
# NOT RUN {
## Use the three different smoothing functions and compare the results
berta_mmd <- smoothSC(Huber2014$Berta)
berta_mmn <- smoothSC(Huber2014$Berta, FUN = "movingMean")
berta_lre <- smoothSC(Huber2014$Berta, FUN = "localRegression")
plotSC(list("Original" = Huber2014$Berta,"Moving Median" = berta_mmd[[1]],
    "Moving Mean" = berta_mmn[[1]],"Local Regression" = berta_lre[[1]]))
# }

Run the code above in your browser using DataLab