apaTrendModels.Polynomial(series, degree, nAhead)
=apaTrendModels.Polynomial(series, degree, nAhead)Result
Fits a polynomial time trend regression with intercept to a single series and returns the fitted values and coefficients.
Syntax
series: r x 1 or 1 x r data vector containing a time series
degree: degree of the polynomial, e.g. 1 = linear, 2 = quadratic, 3 = cubic
nAhead: optional number of forecast steps appended after the last observation. Default value: 0
Algorithm
The series is regressed by ordinary least squares on a constant and the powers t, t², …, t^degree of time t.
Remarks
The result contains a header row and one row per observation with the columns Position (1-based), FittedValue, Degree, R2, RSS and the coefficients Beta0 (intercept), Beta1, … . 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 evaluating the fitted polynomial at the times t = r, …, r + nAhead − 1; the other columns repeat the fit statistics and coefficients. Polynomial forecasts can move away from the data quickly, especially for higher degrees.
