getPiecewiseRMSE | R Documentation |
Internal function that retrieves the optimal RMSE from performing piecewise linear regression and/or harmonic regression fits on two consecutive segments.
getPiecewiseRMSE(series, changepoint, trendsOnly=F, seasonalityOnly=F, numHarmonics=2)
series |
A vector of observations on which to run changepoint analysis. For this particular function, this series should only contain two segments, separated by a single changepoint. |
changepoint |
The index indicating the changepoint. A changepoint is located immediately prior to a shift in the series. |
trendsOnly |
Boolean that, when TRUE, indicates that only linear regressions should be used. |
seasonalityOnly |
Boolean that, when TRUE, indicates that only harmonic regressions should be used. |
numHarmonics |
If harmonic regressions are used, this indicates the number of harmonics to be modeled (currently restricted to being 1 or 2). |
When both trendsOnly and seasonalityOnly are FALSE (the default), then both linear regressions and harmonic regressions are considered for the piecewise fits. The best fits on either side of the changepoint contribute to the piecewise RMSE.
For all regressions, the dependent variable is the series of observations and the independent variable is the index associated with each observation as part of that series.
Returns the optimal piecewise RMSE (a numeric value).
Matthew Quinn
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.