Model#

Model(*args, **kwargs)

Attributes#

Data Connection#

Model.datatree

A source for data for the model.

Model.dataset

Data arrays as loaded for model computation.

Model.n_cases

The number of cases in the attached data.

Choice Definition#

Model.choice_ca_var

An idca variable giving the choices as indicator values.

Model.choice_co_vars

A mapping giving idco expressions that evaluate to indicator values.

Model.choice_co_code

An idco variable giving the choices as alternative id's.

Alternative Availability#

Model.availability_ca_var

An idca variable or expression indicating if alternatives are available.

Model.availability_co_vars

A mapping giving idco expressions that evaluate to availability indicators.

Utility Definition#

Model.utility_ca

The portion of the utility function computed from idca data.

Model.utility_co

The portion of the utility function computed from idco data.

Model.quantity_ca

The portion of the quantity function computed from idca data.

Parameters#

Model.pf

A DataFrame of the model parameters.

Model.pvals

An array of the current parameter values.

Model.pnames

An array of the current parameter names.

Model.pholdfast

An array indicating which parameters are marked as holdfast.

Model.pnullvals

An array of the current parameter null values.

Model.pmaximum

An array of the current parameter maximum values.

Model.pminimum

An array of the current parameter minimum values.

Model.pbounds

A copy of the current min-max bounds of the parameters.

Model.pstderr

An array of the current parameter standard errors.

Model.mixtures

Estimation Results#

Model.most_recent_estimation_result

A copy of the result dict from most recent likelihood maximization.

Model.possible_overspecification

Possible overspecification of the model.

Methods#

Setting Parameters#

Model.set_values([values])

Set the parameter values for one or more parameters.

Model.lock_value([name, value])

Set a fixed value for a model parameter.

Model.set_cap([cap])

Set limiting values for one or more parameters.

Model.remove_unused_parameters([verbose])

Remove parameters that are not used in the model.

Parameter Estimation#

Model.maximize_loglike(*args, **kwargs)

Maximize the log likelihood.

Model.calculate_parameter_covariance([...])

Calculate the parameter covariance matrix.

Model Fitness#

Model.loglike_null([use_cache])

Compute the log likelihood at null values.

Model Analysis#

Model.analyze_predictions_co([q, n, ...])

Analyze predictions of the model based on idco attributes.

Model.analyze_predictions_co_figure([q, n, ...])

Create an Altair figure of the model's predictions based on idco attributes.

Model.analyze_elasticity(variable[, altid, ...])

Analyze elasticity of the model.

Model.histogram_on_idca_variable(x, **kwargs)

Reporting#

Model.parameter_summary()

Create a tabular summary of parameter values.

Model.estimation_statistics([...])

Create an XHTML summary of estimation statistics.

Model.mixture_summary()

Create a summary of the mixture parameters as a pandas DataFrame.

Model.to_xlsx(filename[, save_now, ...])

Write the estimation results to an Excel file.

Ancillary Computation#

Model.bhhh([x, start_case, stop_case, ...])

Model.check_d_loglike([stylize, skip_zeros])

Check that the analytic and finite-difference gradients are approximately equal.

Model.d_loglike([x, start_case, stop_case, ...])

Model.d_loglike_casewise([x, start_case, ...])

Model.loglike([x, start_case, stop_case, ...])

Compute the log likelihood of the model.

Model.loglike_casewise([x, start_case, ...])

Model.logloss([x, start_case, stop_case, ...])

Model.logsums([x, start_case, stop_case, ...])

Model.probability([x, start_case, ...])

Compute values for the probability function embodied by the model.

Model.quantity([x, start_case, stop_case, ...])

Model.total_weight()

Compute the total weight of cases in the loaded data.

Model.utility([x, start_case, stop_case, ...])

Compute values for the utility function contained in the model.

Troubleshooting#

Model.doctor(**kwargs)

Run diagnostics, checking for common problems and inconsistencies.