choice.BinaryProbit

Guide & worked example · Source

choice.BinaryProbit(optimizer=None, maxiter=5000, tol=0.0001, device=None)

Binary Probit model for discrete choice analysis.

This model estimates utility-based binary choice using the normal (probit) link function, assuming normally distributed errors. Often used when the choice depends on a latent continuous variable.

Examples: >>> model = BinaryProbit() >>> X = torch.randn(100, 3) >>> y = torch.randint(0, 2, (100,)) >>> model.fit(X, y) >>> probs = model.predict_proba(X)

Attributes

Name Description
device
history
maxiter
optimizer_class
params
tol

Methods

Name Description
counterfactual Compute change in market share for a counterfactual scenario.
fit Fit the model using maximum likelihood estimation.
predict_proba Predict choice probabilities for binary probit model.
simulate Simulate binary choices from the fitted model.
summary Print a formatted summary of model estimation results.
to Move model parameters and fitted data to device.

counterfactual

choice.BinaryProbit.counterfactual(X_new)

Compute change in market share for a counterfactual scenario.

Args: X_new: Counterfactual design matrix of shape (n_samples, n_features).

Returns: Dictionary containing market share comparisons.

Raises: ValueError: If model has not been fitted yet.

fit

choice.BinaryProbit.fit(
    X,
    y,
    init_params=None,
    verbose=False,
    fe=None,
    fe_design=None,
    hdfe_index=None,
    offset=None,
    batch_size=None,
    stderr=True,
)

Fit the model using maximum likelihood estimation.

Optimizes the model parameters to minimize the negative log-likelihood using the specified PyTorch optimizer. After convergence, computes standard errors via the Fisher information matrix.

Args: X: Design matrix of shape (n_samples, n_features). Assumes X includes an intercept column if desired. y: Target vector of shape (n_samples,). init_params: Initial parameter values. For FE-aware GLMs, may be a packed parameter vector or a dict with coef and fe_coef. verbose: If True, prints convergence information. fe: Optional list of 1D fixed-effect ID vectors. fe_design: Optional list of sparse fixed-effect incidence matrices. hdfe_index: Optional index of the FE block to use for fast inference. offset: Optional offset vector added to the linear predictor. batch_size: Optional mini-batch size for first-order optimizers. stderr: Whether to compute standard errors.

Returns: Self (fitted estimator) with populated params dictionary.

Examples: >>> model = LogisticRegression() >>> model.fit(X_train, y_train, verbose=True) >>> print(model.params[“coef”])

predict_proba

choice.BinaryProbit.predict_proba(X)

Predict choice probabilities for binary probit model.

Args: X: Design matrix of shape (n_samples, n_features).

Returns: Predicted probabilities of choosing option 1, shape (n_samples,).

Raises: ValueError: If model has not been fitted yet.

simulate

choice.BinaryProbit.simulate(X)

Simulate binary choices from the fitted model.

Args: X: Design matrix of shape (n_samples, n_features).

Returns: Simulated binary choices of shape (n_samples,).

summary

choice.BinaryProbit.summary(alpha=0.05)

Print a formatted summary of model estimation results.

Displays a comprehensive table including parameter estimates, standard errors, t-statistics, p-values, and confidence intervals (if standard errors are available).

Args: alpha: Significance level for confidence intervals (default: 0.05 for 95% confidence intervals).

Examples: >>> model.fit(X, y) >>> model.summary(alpha=0.01) # 99% confidence intervals

to

choice.BinaryProbit.to(device)

Move model parameters and fitted data to device.