Description Usage Arguments Value Examples
View source: R/multi_peak_features.R
Compute a set of features aimed at characterizing multipeak/oscillating signals.
1 2 | MPFeatAllFeat(x, window.rollmean, window.extrema, extrema = "maxi",
trim.remain = NULL, robust.linreg = FALSE, robust.decomp = TRUE)
|
x |
a numerical vector. |
window.rollmean |
integer, window width for classical decomposition. In case of multi-peak signal, should correspond to the number of points in one period. See ?classical.decomposition. |
window.extrema |
integer, window width for detecting local extrema. Used for detecting peaks maxima or minima. See ?MPFeatTrend_extrema. |
extrema |
one of c("mini", "maxi"). Which extrema should be looked for and regressed on for trend estimation? See ?MPFeatTrend_extrema. |
trim.remain |
numeric, what is the minimum absolute remainder to be considered for computing amplitude variation? See ?MPFeatAmp_variation. |
robust.linreg |
logical, whether linear regression for trend estimation should be performed robustly. See ?mblm::mblm |
robust.decomp |
logical, whether classical decomposition for amplitude features should be performed robustly. See ?classical.decomposition. |
Alist of 5 features of x: $trend.extrema: slope of linear regression performed on local extrema. Estimator for long-term trend.
$trend.rollmean: slope of linear regression performed on rolling mean. Estimator for long-term trend.
$amplt.dist.euclid: Euc lidean distance between x and its rolling mean. Not scaled! Estimator for oscillation amplitude.
$amplt.season: amplitude (max-min) of the seasonal component. Estimator for oscillation amplitude.
$amplt.variation: mean remainder of classical decomposition, after optionally trimming of small remainders. Estimator for oscillation amplitude variation.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | # One sinusoid with linear trend
x <- sim_phase_shifted_with_fixed_trend(n = 1, noise = 0, slope = 0.1)
# How many points in one oscillation? Check maximum in power spectrum
x.spec <- spectrum(x$value)
x.period <- round(1/x.spec$freq[which.max(x.spec$spec)])
# Check by plotting extended rolling mean
plot(x$value, type = "b")
lines(seq_along(x$value), rollex(x$value, 31), col = "blue")
legend("topleft", legend="rolling mean", fill="blue")
# Extract features
x.features <- MPFeatAllFeat(x$value, x.period, 5)
# Visualize trend
plot(x$value, type = "b")
abline(a=0, b=x.features$trend.extrema, col = "blue")
abline(a=0, b=x.features$trend.rollmean, col = "red")
legend("topleft", legend=c("extrema", "rollmean"), fill=c("blue","red"),
title = "Trend estimation method")
# Visualize amplitude season
plot_decomposition(classical.decomposition(x$value, x.period))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.