Akaike Information Criterion and Log Likelhood of a call to nlinfit

조회 수: 2 (최근 30일)
Pitch Mandava
Pitch Mandava 2017년 1월 14일
답변: the cyclist 2017년 1월 14일
I fit a model to data using a call below
[pmsf(i).params pmsf(i).resids pmsf(i).jacobian SIGMA mse] = nlinfit(pdatain, pzi, @my_lin_fun, a0);
How can I calculate AIC and Log Likelihood for the fit.

답변 (1개)

the cyclist
the cyclist 2017년 1월 14일
I don't think AIC is an output of nlinfit. While I expect that one could calculate it from the output, it might actually be faster to rewrite your code to use the more modern fitnlm function, which does have AIC as an output.
I've attached a simple example of fitnlm, in case that helps.
rng 'default'
% Here is an example of using fitnlm(). For simplicity, none of
% of the fitted parameters are actually nonlinear!
% Define the data to be fit
x=(0:1:10)'; % Explanatory variable
y = 5 + 3*x + 7*x.^2; % Response variable (if response were perfect)
y = y + 2*randn((size(x)));% Add some noise to response variable
% Tabulate the data
tbl = table(x,y);
% % Fit the model
% Define function that will be used to fit data
% (F is a vector of fitting parameters)
f = @(F,x) F(1) + F(2).*x + F(3).*x.^2;
beta0 = [1 1 1];
mdl = fitnlm(tbl,f,beta0);
% Calculate the model values at the empirical x
y_predicted = predict(mdl,x);
% Plot the data and fit
figure
plot(x,y,'*',x,y_predicted,'g');
legend('data','fit')
% Display AIC
AIC = mdl.ModelCriterion.AIC

카테고리

Help CenterFile Exchange에서 Nonlinear Regression에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by