필터 지우기
필터 지우기

how to use aic in matlab

조회 수: 27 (최근 30일)
JING QIAO
JING QIAO 2022년 6월 23일
편집: Moksh 2023년 9월 7일
May I ask how can I use aicbic in matlab for user defined functions? I tried to fit a set of data using different combinations of functions (sine, polynomial), I wanted to use aic/bic to test which one is a better function to model the data. From https://jp.mathworks.com/help/econ/aicbic.html, I need to provide the log-likelihood of the models. How can we calculate the log-likelihood?
Refer to https://jp.mathworks.com/help/ident/ref/idgrey.aic.html#buy65_c-model, it seems that the models are the ones defined by the matlab, such as
Is there a way to use aic/bic for the models defined by the user (e.g,, y1= ax+bx^2+c, y2=ax+dx^3+sin(x))? Many thanks in advance!

답변 (1개)

Moksh
Moksh 2023년 9월 7일
편집: Moksh 2023년 9월 7일
Hi Jing,
As per my understanding, you are trying to calculate aic/bic scores for custom-designed functions. It is accurate that theaic’ function in MATLAB restricts the input to a specific set of models, so it cannot be used for every case.
You can use the ‘aicbic’ function on any model if you have the following data:
  1. Log-likelihood values derived from fitting the model on data
  2. Corresponding number of estimated model parameters
You can try using the ‘fitdist’ function in MATLAB, which creates a ‘pdf’ of the specified distribution for input data. Log-likelihood then can be calculated using this pdf distribution.
Here is an example code using Rayleigh distribution:
% Generating random data through Rayleigh distribution
x = raylrnd(2, 20, 1);
% Fitting the data on Rayleigh distribution and getting the log-likelihood
pd = fitdist(x, 'Rayleigh');
logL = pd.NLogL;
% Computing aic and bic scores from the log-likelihood values and number of
% estimated parameters (Assuming 39 model parameters)
[aic_score, bic_score] = aicbic(logL, 39);
Given that you have not provided the specific model, it is recommended to attempt fitting the data to various distributions based on your model and obtain the corresponding Log-likelihood values.
Refer to the following documents for further understanding of the specified functions.

Community Treasure Hunt

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

Start Hunting!

Translated by