MixedLogit.parse_formula#

MixedLogit.parse_formula(df, formula, depvar)[source]#

Parse the three-part structure of a mixed logit formula specification.

Splits the formula into target, alternative-specific covariates, fixed covariates, and random covariates. Ensures that the target variable appears in the dependent variable column and that all specified covariates exist in the input dataframe.

Parameters:
dfpd.DataFrame

Input dataframe

formulastr

Formula string in the format: “target ~ alt_covariates | fixed_covariates | random_covariates”

depvarstr

Name of dependent variable column

Returns:
tuple[str, str, str, str]

(target, alt_covariates, fixed_covariates, random_covariates)