System Identification Loss Function

E
ews · Aug 24, 2021 · 2K views
Question
Hi guys ! I have successfully estimated several linear Models for my system including ARX, SS and OE Models. For Model Evaluation and a little bit of presentation I would like to plot the Loss Function Progress. However, searching through the Matlab Doc and the extensive System Identification Toolbox Guide did not help. I can solely extract the last Loss Function Value via loss_fcn_value = estimated_model.Report.Fit.LossFcn; % Analogously for AIC, BIC and other measures What I would like to see is a Loss Function Progress similar to the Neural Network Toolbox where I can see a distinct decline.
Expert Answer
Profile picture of John Williams
John Williams PhD Expert
Answered Sep 12, 2026






System Identification Loss Function Selection


Selecting the correct loss function in MATLAB System Identification Toolbox aligns the estimated model with your operational goal, such as feedback control, short-term forecasting, or noise rejection.

1. Primary Loss Functions and Selection Criteria













Loss FunctionBest ForMATLAB Option / Setting
Prediction Error (1-Step Ahead)Kalman filtering, real-time tracking, adaptive controlopt.Focus = 'prediction'
Simulation Error (Infinite Horizon)Model predictive control (MPC), digital twins, open-loop simulationopt.Focus = 'simulation'
Robust Loss (Huber / Bisquare)Datasets with measurement outliers or sensor spikesopt.RobustCost = 'Huber'
Frequency-Weighted LossTargeting specific bandwidths or resonance frequenciesopt.Focus = [f_low, f_high]
Regularized Loss (L2 / Ridge)High-order models with ill-conditioned matricesopt.Regularization.Lambda = 0.01

2. Simulation vs. Prediction Focus


Prediction error minimizes error one step ahead using past measured outputs. Simulation error evaluates full multi-step trajectory rollout without feeding back true measured states.

% Load identification dataset
load iddata1 z1;

% 1. Simulation Focus: Ideal for open-loop simulation & MPC
opt_sim = ssestOptions;
opt_sim.Focus = 'simulation';
model_sim = ssest(z1, 2, opt_sim);

% 2. Prediction Focus: Ideal for state estimation & filtering
opt_pred = ssestOptions;
opt_pred.Focus = 'prediction';
model_pred = ssest(z1, 2, opt_pred);

% Compare both models against validation data
figure('Color', 'w');
compare(z1, model_sim, model_pred);
legend('Measured', 'Simulation Focus', 'Prediction Focus');

3. Robust Loss for Outlier Suppression


Standard quadratic error squares outliers, which distorts estimated poles and zeros. Huber and Bisquare loss functions linearize error penalties above a specified threshold.

% Configure robust optimization options
opt_robust = tfestOptions;
opt_robust.RobustCost = 'Huber'; % Options: 'Huber', 'Bisquare', 'Cauchy'
opt_robust.Display = 'on';

% Estimate transfer function from noisy data with spikes
np = 2; % Number of poles
nz = 1; % Number of zeros
sys_tf = tfest(z1, np, nz, opt_robust);

4. Frequency-Weighted Loss for Control Design


When you need high model fidelity only around your controller crossover frequency (e.g., 0.1 to 10 rad/s), filter the loss function focus:

opt_freq = oeOptions;
opt_freq.Focus = [0.1, 10]; % Passband range in rad/s

% Estimate Output-Error (OE) model focusing on specified frequency band
model_oe = oe(z1, [2 2 1], opt_freq);

% Check frequency response fit
figure('Color', 'w');
bode(model_oe);
grid on;

5. Regularization to Prevent Over-Parameterization


Add a penalty term (lambda) on parameter magnitudes when identifying high-order transfer functions or state-space models to prevent overfitting.

opt_reg = armaxOptions;
opt_reg.Regularization.Lambda = 1e-3; % Ridge penalty weight
opt_reg.Regularization.R = eye(5);   % Metric weighting matrix

model_armax = armax(z1, [2 2 2 1], opt_reg);


Decision Rule:

  • If you use the model in Simulink for full open-loop runs or MPC: Choose Focus = 'simulation'.

  • If you use the model in a Kalman Filter or for 1-step forecasting: Choose Focus = 'prediction'.

  • If your sensors have occasional glitches or dropouts: Enable RobustCost = 'Huber'.





100% Run Guarantee 3-Hour Fast-Track Delivery

Need a Custom Version or Complete Simulation for This Problem?

Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.

Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here

Get a Free Consultation or a Sample Assignment Review!