calc_AICc#
- mufasa.UltraCube.calc_AICc(ucube, compID, mask, planemask=None, return_NSamp=True, expand=20)[source]#
Calculate the corrected Akaike Information Criterion (AICc) for a spectral cube model.
This function computes the AICc for a given model component by evaluating the residual sum of squares (RSS) and the effective sample size. The AICc values help compare the goodness-of-fit for models with varying complexities.
- Parameters:
ucube (UltraCube) – An instance of the UltraCube class containing the spectral data, fitted models, and associated parameters.
compID (int or str) – The component ID or number of components in the model. If an integer, it is used to calculate the number of parameters as n_parameters = compID * 4.
mask (numpy.ndarray) – A 3D boolean array specifying which voxels (volume pixels) to include in the AICc calculation.
planemask (numpy.ndarray, optional) – A 2D spatial boolean array specifying which pixels to calculate AICc for. If provided, calculations are restricted to these pixels. Default is None.
return_NSamp (bool, optional) – If True, return the effective sample size along with the AICc values. Default is True.
expand (int, optional) – Number of spectral channels to expand the region where the RSS is calculated. Default is 20.
- Returns:
AICc_map (numpy.ndarray) – A 2D array containing the computed AICc values for the specified regions.
NSamp_map (numpy.ndarray, optional) – A 2D array containing the effective sample size for each spatial pixel. Only returned if return_NSamp is True.
Notes
The corrected Akaike Information Criterion (AICc) is a modification of the AIC that accounts for finite sample sizes. It is given by:
AICc = AIC + (2k(k + 1)) / (N - k - 1)
where k is the number of parameters and N is the sample size.
- Raises:
ValueError – If the input ucube does not contain valid models or residuals for the specified compID.