groupedpaneldatamodels.grid_search_by_ic

groupedpaneldatamodels.grid_search_by_ic(model_cls: Type[_GroupedPanelModelBase], param_ranges: dict[str, list[Any]], init_params: dict[str, Any], fit_params: dict[str, Any] | None = None, ic_criterion: Literal['BIC', 'AIC', 'HQIC'] = 'BIC') tuple[_GroupedPanelModelBase, dict[str, Any], dict[str, Any]][source]

Perform a grid search over model hyperparameters using information criteria.

This function fits the given model class over all combinations of specified parameters and selects the best model based on the specified information criterion (e.g., BIC, AIC, HQIC).

Parameters:
  • model_cls (Type[_GroupedPanelModelBase]) – The model class to be fitted (e.g., GroupedFixedEffects, GroupedInteractiveEffects).

  • param_ranges (dict[str, list[Any]]) – Dictionary where keys are parameter names and values are lists of candidate values.

  • init_params (dict[str, Any]) – Initial parameters passed to model instantiation.

  • fit_params (dict[str, Any] | None) – Optional parameters passed to the .fit() method of the model.

  • ic_criterion (Literal["BIC", "AIC", "HQIC"]) – Criterion used to select the best model. Defaults to “BIC”.

Returns:

  • The best-fitted model.

  • Dictionary of all parameter combinations with their associated IC values.

  • The parameters corresponding to the best model.

Return type:

tuple[_GroupedPanelModelBase, dict[str, Any], dict[str, Any]]