- Log-likelihood values derived from fitting the model on data
- Corresponding number of estimated model parameters
how to use aic in matlab
조회 수: 27 (최근 30일)
이전 댓글 표시
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!
댓글 수: 0
답변 (1개)
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 the ‘aic’ 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:
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.
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!