Sum of square error
Show older comments
Hello,
I'm very new to Matlab. We are attempting to curve fit a biologic response to a sinusoidal input. I'm able to fit the curve using the system identification tool without problems. For this study we need a measured of error. I have been able to get confidence intervals but what I would like to get is the sum of squares error. I have a few questions:
- Is there a way to display the sum of square error in Matlab?
- What is the number displayed on the model output as a measure of best fit?
- When the data is presented following the estimation, it displays the loss function and the FPE. What is the FPE?
Thank you. Michael
Accepted Answer
More Answers (2)
Jarrod Rivituso
on 13 Apr 2011
Are you trying to determine coefficients of a dynamic model, something with derivatives in it such as
dx/dt = A*x + B*u y = C*x + D*u
Or are you trying to determine coefficients of a more basic equation, such as
y = A*sin(u)+B*cos(u)
If the latter is the case, you don't need to use system identification toolbox. You could instead do a linear regression analysis in MATLAB, or there's even a curve fitting toolbox
>> cftool
Generally, it is easy in MATLAB to find the sum of square errors between two vectors. For example:
>> x1 = randn(10,1);
>> x2 = randn(10,1);
>> residuals = x2-x1;
>> sum(residuals.^2)
Rajiv Singh
on 14 Apr 2011
0 votes
FPE represents a norm of the prediction error; it stands for Final Prediction Error (more details in the product documentation). The fit shown on "model output" plot is the one returned by the COMPARE command. It is:
FIT = 100(1-norm(Ymeas-Ysim)/norm(Ymeas-mean(Ymeas))) (in %)
where YMeas is the measured response and Ysim is the output of the model. Type "help compare" for more information on COMPARE.
For obtaining other error measures, you could obtain the prediction or simulation error explicitly and use it to compute your measure of fit. For prediction error use the PE command. For simulation error, you could do e = ymeas - sim(model, u) where ymeas is the measured output signal for input signal u and SIM is the command that can be used on identified models to compute the simulation response.
5 Comments
Mike
on 14 Apr 2011
Rajiv Singh
on 15 Apr 2011
Well, 1-step ahead prediction error is not the same as simulation error. If you are developing a model to fit certain previously recorded data, and the model has a nontrivial noise component the result returned from PE would be different from y-SIM(Dop, u). What type of model is Dop?
Using PE: you can call it as E = pe(model, iddata(y,u,Ts)); then the numerical error vector is E.y. Look up the help on PE for more info.
Mike
on 15 Apr 2011
Rajiv Singh
on 16 Apr 2011
If you are using the process model, idproc, PE can be used. For example:
E = pe(model, data)
e = E.y;
MSE = norm(e)^2/length(e)
Mike
on 18 Apr 2011
Categories
Find more on Analyze Data in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!