Sum of square error

10 次查看(过去 30 天)
Mike
Mike 2011-4-13
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:
  1. Is there a way to display the sum of square error in Matlab?
  2. What is the number displayed on the model output as a measure of best fit?
  3. When the data is presented following the estimation, it displays the loss function and the FPE. What is the FPE?
Thank you. Michael

采纳的回答

Rajiv Singh
Rajiv Singh 2011-4-18
What type of model is model1 (what does class(model1) return)? PE is a System Identification Toolbox function that would work only on models recognized by it. You can create either IDPROC or IDPOLY structure for your model.
model = idproc('p1d'); model.Kp = K; model.Td = Td; model.Tp1 = Tp1;
model = idpoly(1,K/Tp1,1,1,[1 1/Tp1],'Ts',0,'noise',0);
  5 个评论
Rajiv Singh
Rajiv Singh 2011-4-18
SID files are GUI session files. You must load them into GUI to view their contents. Suppose you have a file called foo.sid, then type ident(foo) in MATLAB command window. This will launch the GUI with the session contents loaded from foo.sid. If you see any models in the modal board of the GUI, you may export them by dragging their icons onto the "To workspace" box. HTH.
Mike
Mike 2011-4-19
Hi Rajiv. That really helped. Thank you. After exported the data i am able to define the iddata and use E=pe(model,data) and the e=E,y. When I try the line you posted for MSE i get "undefined function or method norm for input arguements of type iddata". Thanks.

请先登录,再进行评论。

更多回答(2 个)

Jarrod Rivituso
Jarrod Rivituso 2011-4-13
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)
  1 个评论
Mike
Mike 2011-4-14
Thank you for your answer. It is the former. We are testing a 1st order system and trying to determine the time constant by fitting to a sinusoidal chirp function. I'm using the system identification tool to fit the sinusoidal output and determine the time constant. What I need to get is the sum of square error. Is there a way to do that? Thanks.

请先登录,再进行评论。


Rajiv Singh
Rajiv Singh 2011-4-14
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 个评论
Rajiv Singh
Rajiv Singh 2011-4-16
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
Mike 2011-4-18
Thanks again for the answer. I am trying to use PE. My problem is that the model I create in the system identification tool is not recognized by PE. Do I need to use idmodel? The model transfer function is (Kexp(-Tds))/(1+Tp1s). The model name is model1. Thanks Rajiv. Mike.

请先登录,再进行评论。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by