adjust

adjust(x, sp = uncor.spec(x), h = 1, s = 20, start.p = 5, start.g = 30, criterion = "comfortable.fit", g.update.step = 1, attit = "adventurous", pars.updated.at.once = 2, max.no.of.descents = 1, max.p = 10, limits.g = c(10, 100), kernel="normal")

Main routine of the package. Adjusts the two forecasting parameters p (size of the Yule-Walker matrix) and g (bandwidth of the kernel used in smoothing the local autocovariance). The algorithm is described in detail in subsection 5.2 of the article.

Takes:
x The series, as a vector of observations. Its length t does not have to be a power of two.
sp The uncorrected Haar spectrum of x. To obtain the spectrum, use uncor.spec.
h The prediction lag.
s The length of the "training segment" used for adjusting the parameters. In the first step, x[1:t-s-h+1] is used to forecast x[t-s+1], in the last one -- x[1:t-h] is used to forecast x[t].
start.p, start.g The initial values of p and g, respectively. At each time point t-s-h+1, ..., t-h, the forecast is performed using not only the current pair of (p,g), but also its 8 neighbours. The parameters are then updated according to the success of prediction, i.e. the parameter values used in the next forecast are the ones that did "best" in the previous one.
criterion Measures the performance of a given pair of parameters and is used for comparing the neighbouring pairs. Can be set to "comfortable.fit" (the preferred pair is the one that provides the most comfortable fit within the corresponding prediction interval; this is exactly the criterion used in the paper, see subsection 5.2 for details) or "min.distance" (the preferred pair is the one that minimises the distance between the predicted value and the actual one).
g.update.step Defines the grid for the bandwidth parameter g. If the current pair is (p, g), then the neighbouring pairs are all combinations of p-1, p, p+1 with g-g.update.step, g, g+g.update.step.
attit Attitude: "adventurous" means that the parameters are updated at each time point, "conservative" means that they are only updated if the forecast using the current pair does not fit in the corresponding prediction interval.
pars.updated.at.once If set to 2, then both parameters (p and g) can be updated at once at each time point. If set to 1, only one parameter gets updated at each step (it can be a different parameter each time, though!).
max.no.of.descents Maximum number of updates allowed at each time point. If attit == "conservative" AND the actual value falls into the prediction interval, then no update is performed. Otherwise, the update step is performed at least once. In the latter case, updates are stopped EITHER if the max.no.of.descents has been achieved OR if the predicted value fits in the prediction interval OR if it is the current pair, and not any of its neighbours, that does best in forecasting the observation.
max.p The upper limit on p.
limits.g A two-component vector. The first component is the lower limit on g, and the second one is the upper limit.
kernel The kernel used for smoothing the local covariance. Like in ksmooth, can be set to "box", "triangle", "parzen" or "normal". Also see help(ksmooth) in S-Plus.

Returns:
xhat The vector (of length s) of predicted values.
sig The vector of corresponding standard prediction errors. The length of the prediction interval (based on normality) is 3.92 * sig.
actual The vector of the actual values: x[t-s+1:t].
sqdist Squared distance between xhat and actual.
p The vector (of length s+1) of the sizes of the Yule-Walker matrices used along the segment. The last value of p should be used in the NEXT STEP, i.e. in forecasting x[t+1]. This can be done using pred.
g The vector of the values of the bandwidth used in smoothing the local covariance in each Yule-Walker matrix along the segment. The last value of g should be used in the NEXT STEP, i.e. in forecasting x[t+1]. This can be done using pred.
fits.in A binary sequence of length s indicating whether the actual values (actual) fit in the prediction intervals (symmetric intervals of length 3.92 * sig around xhat).
percent.fits.in Indicates the percentage of observations that fit in the corresponding prediction intervals.