MATLAB: What is the difference between RESID, COMPARE and PE functions in System Identification Toolbox 7.2.1 (R2008b)

System Identification Toolbox

I would like to know the difference between RESID, COMPARE and PE functions in System Identification Toolbox.

Best Answer

RESID and PE functions compute 1-step ahead prediction errors (M=1). For errors
corresponding to arbitrary horizons, you may compute prediction results
yp = predict(model, data, M),
where M is prediction horizon. You could also use COMPARE function too whose first output argument returns the predicted output:
Y = compare(data,model,M)
yp = Y{1};
Note that calling "COMPARE(data, model)" means prediction horizon M is Inf. You can also compute prediction error as difference between measured and predicted outputs as follows:
e = data;
e.y = data.y - yp.y;