Main Content

Validate Online Parameter Estimation at the Command Line

This topic shows how to validate online parameter estimation at the command line. If the validation indicates low confidence in the estimation, then see Troubleshoot Online Parameter Estimation. After you have validated the online estimation results, you can generate C/C++ code or a standalone application using MATLAB® Coder™ or MATLAB Compiler™.

Examine the Estimation Error

The estimation error is the difference between measured output, y, and the estimated output, EstimatedOutput at each time step.

obj = recursiveARX;
[A,B,EstimatedOutput] = step(obj,y,u);
estimationError = y-EstimatedOutput;

Here, u is the input data at that time step.

The estimation errors (residuals) can be large at the beginning of the estimation or when there are large parameter variations. The error should get smaller as the parameter estimates converge. Small errors relative to the size of the outputs increase confidence in the estimated values.

Simulate the Estimated Model

Simulate the estimated model and compare the simulated and measured outputs. To do so, feed the measured input into a model that uses the estimated time-varying parameter values. Then compare the model output with the measured output. A close match between the simulated output and the measured output gives confidence in the estimated values.

Examine Parameter Covariance

Parameter covariance is a measure of estimated uncertainty in the parameters. The covariance is calculated when the forgetting factor or Kalman filter estimation algorithms are used.

Parameter covariance is computed assuming that the residuals are white noise, and the variance of these residuals is 1. You view the parameter covariance matrix using the ParameterCovariance property of your System object™.

P = obj.ParameterCovariance;

The estimated parameters can be considered as random variables with variance equal to the corresponding diagonal of the parameter covariance matrix, scaled by the variance of the residuals (residualVariance) at each time step. You use prior knowledge, or calculate residualVariance from the residuals, e. Where, e is the vector of estimation errors, estimationError.

 residualVariance = var(e);

Scale the parameter covariance to calculate the variance of the estimated parameters.

paramVariance = diag(P)*residualVariance;

A smaller variance value gives confidence in the estimated values.

Use Validation Commands from System Identification Toolbox

You can validate a snapshot of the estimated model using validation commands for offline estimation. This validation only captures the behavior of a time-invariant model. For available offline validation techniques in System Identification Toolbox™, see Model Validation.

To use offline commands, convert your online estimation System object, obj, into an idpoly model object. Also convert your stream of input-output validation data, Output(t) and Input(t), into an iddata object.

sys = idpoly(obj);
sys.Ts = Ts;
z = iddata(Output,Input,Ts)

Here, Ts is the sample time.

Note

This conversion and any subsequent analysis are not supported by MATLAB Coder.

The validation techniques include:

  • Analysis of the residuals using techniques such as the whiteness test and the independence test using offline commands such as resid. For example, use resid(z,sys). For information about these tests, see What Is Residual Analysis?.

  • Comparison of model output and measured output. For example, use compare(z,sys).

  • Comparison of different online estimation System objects.

    You can create multiple versions of a System object with different object properties, convert each of them to idpoly model objects, and use compare to choose the best one.

    If you want to copy an existing System object and then modify properties of the copied object, use the clone command. Do not create additional objects using syntax obj2 = obj. Any changes made to the properties of the new System object created this way (obj2) also change the properties of the original System object (obj).

See Also

| | | | | |

Related Topics