predict

K-step ahead prediction

Syntax

yp = predict(sys,data,K)
yp = predict(sys,data,K,opt)
[yp,x0e,sys_pred] = predict(sys,data,K,___)
predict(sys,data,K___)

Description

yp = predict(sys,data,K) predicts the output of an identified model, sys, K steps ahead using input-output data history from data.

yp = predict(sys,data,K,opt) predicts the output using the option set opt to configure prediction behavior.

[yp,x0e,sys_pred] = predict(sys,data,K,___) also returns the estimated initial state, x0e, and a predictor system, sys_pred.

predict(sys,data,K___) plots the predicted output.

An important use of predict is to evaluate a model's properties in the mid-frequency range. Simulation with sim (which conceptually corresponds to k = inf) can lead to diverging outputs. Such divergence occurs because sim emphasizes the low-frequency behavior. One step-ahead prediction is not a powerful test of the model's properties, because the high-frequency behavior is stressed. The trivial predictor y^(t)=y(t1) can give good predictions in case the sampling of the data is fast.

Another important use of predict is to evaluate time-series models. The natural way of studying a time-series model's ability to reproduce observations is to compare its k step-ahead predictions with actual data.

For Output-Error models, there is no difference between the k step-ahead predictions and the simulated output. This lack of difference occurs because, by definition, Output-Error models only use past inputs to predict future outputs.

Difference Between forecast and predict Functions

predict predicts the response over the time span of data. forecast performs prediction into the unseen future, which is a time range beyond the last instant of measured data. predict is a tool for validating the quality of an estimated model. Use predict to determine if the prediction result matches the observed response in data.OutputData. If sys is a good prediction model, consider using it with forecast (only supports linear models).

Input Arguments

sys

Identified model.

sys may be a linear or nonlinear identified model.

data

Measured input-output data.

Specify data as an iddata object.

If sys is a time-series model, which has no input signals, then specify data as an iddata object with no inputs, or a matrix of past (already observed) time-series data.

K

Prediction horizon.

Specify K as a positive integer that is a multiple of the data sample-time. To obtain a pure simulation of the system, specify K as Inf.

Default: 1

opt

Prediction options.

opt is an option set, created using predictOptions, that specifies options including:

  • Handling of initial conditions

  • Data offsets

Output Arguments

yp

Predicted output.

yp is an iddata object. The OutputData property stores the values of the predicted output.

Outputs up to the time t-K and inputs up to the time instant t are used to predict the output at the time instant t. The time variable takes values in the range represented by data.SamplingInstants.

When K = Inf, the predicted output is a pure simulation of the system.

For multi-experiment data, yp contains a predicted data set for each experiment. The time span of the predicted outputs matches that of the observed data.

When sys is specified using an idnlhw or idnlgrey model, yp is the same as the simulated response computed using data.InputData as input.

x0e

Estimated initial states.

sys_pred

Predictor system.

sys_pred is a dynamic system whose simulation, using [data.OutputData data.InputData] as input, yields yp.OutputData as the output.

For discrete-time data, sys_pred is always a discrete-time model.

For multi-experiment data, sys_pred is an array of models, with one entry for each experiment.

When sys is a nonlinear model, sys_pred is [].

Examples

expand all

Predict Time-Series Model Response

Simulate a time-series model.

init_sys = idpoly([1 -0.99],[],[1 -1 0.2]);
e = iddata([],randn(400,1));
data = sim(init_sys,e);

data is an iddata object containing the simulated response data of a time-series model.

Estimate an ARMAX model for the simulated data.

na = 1;
nb = 2;
sys = armax(data(1:200),[na nb]);

sys is an idpoly model of the identified ARMAX model.

Obtain a 4 step-ahead prediction for the estimated model.

K = 4;
yp = predict(sys,data,K);

yp is an iddata object. To obtain the values of the predicted output, type yp.OutputData.

Analyze the prediction.

plot(data(201:400),yp(201:400));
legend('Simulated data','Predicted data');

Alternatively, use compare to substitute the use of predict and plot. For example, use compare(data,sys,K).

See Also

| | | | | | | | | | |

Was this topic helpful?