Home   >   User Resources   >   Online Help   >   apaTrendModels.Piecewise
 

 

Function index Version 3.0.0

apaTrendModels.Piecewise(series, maxBreakpoints, minSegmentLength, maxIterations, nOutOfSample, useLinearModel, nAhead)

Excel=apaTrendModels.Piecewise(series, maxBreakpoints, minSegmentLength, maxIterations, nOutOfSample, useLinearModel, nAhead)

Result

Fits a piecewise linear or quadratic trend model to a single series, selects the number of breakpoints by a knee rule and returns the fitted values and breakpoint information.

Syntax

series: r x 1 or 1 x r data vector containing a time series

maxBreakpoints: maximum number of breakpoints to consider. Default value: 10

minSegmentLength: minimum number of observations between the series start, the breakpoints and the series end. Default value: 6

maxIterations: maximum number of iterations of the breakpoint search. Default value: 200

nOutOfSample: number of final observations held out from the fit. Default value: 4

useLinearModel: TRUE for a piecewise linear model, FALSE for a piecewise quadratic model. Default value: FALSE

nAhead: optional number of forecast steps appended after the last observation. Default value: 0

Algorithm

The trend is regressed on time t = 0, 1, …, using the in-sample observations only, i.e. all observations except the last nOutOfSample.

Remarks

The result contains a header row and one row per observation with the columns Position (1-based), ObservedInSampleFlag (1 for in-sample, 0 for out-of-sample), FittedValue, SelectedBreakCount, BreakPoints (1 at a breakpoint, 0 otherwise), R2 and ModelType. If nAhead is greater than 0, nAhead further rows with the Positions r + 1, …, r + nAhead follow, where r is the number of observations. Their FittedValue is the forecast obtained by continuing the last segment of the selected model at the times t = r, …, r + nAhead − 1, their ObservedInSampleFlag and BreakPoints are 0, and the other columns repeat those of the fit.