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:
- Log-likelihood values derived from fitting the model on data
- 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.