MPFeatTrend_rollmean: MPFeatTrend_rollmean

Description Usage Arguments Value See Also Examples

View source: R/multi_peak_features.R

Description

Smooth by rolling mean and perform linear regression. Rolling mean is extended at extremeties by linear extrapolation, see ?rollex. Aims at giving an estimation of long-term trend in multi-peak signals.

Usage

1
MPFeatTrend_rollmean(x, window.size, robust = FALSE)

Arguments

x

a numerical vector.

window.size

integer, width of window for rolling mean.

robust

logical. If TRUE perform robusts linear regression. Median-Based Linear Models are used, see ?mblm::mblm

Value

A list of 2: $model, the full linear model; $trend, slope of the linear model.

See Also

MPFeatTrend_extrema

Examples

1
2
3
4
5
6
7
8
9
width <- 30
x <- sim_phase_shifted_with_fixed_trend(n = 1, noise = 0, slope = 0.1)
# Rolling mean extended by linear extrapolation.
# This is also performed in MPFeatTrend_rollmean.
x.roll <- rollex(x$value, width)
plot(x$value, type = "b")
lines(x.roll, col ="red", lwd = 2, lty = "dashed")
x.trend <- MPFeatTrend_rollmean(x = x$value, window.size = width)
abline(x.trend$model, col = "blue", lwd = 2, lty = "dashed")

majpark21/TSexploreR documentation built on Oct. 16, 2019, 2:46 p.m.