larch.Model#

class Model(*args, **kwargs)[source]#

Bases: NumbaModel, OptimizeMixin, PanelMixin

__init__(*args, **kwargs)[source]#

Methods

__init__(*args, **kwargs)

add_parameter_array(name, values)

analyze_elasticity(variable[, altid, q, n, ...])

Analyze elasticity of the model.

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

Analyze predictions of the model based on idco attributes.

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

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

apply_random_draws(parameters[, draws])

availability_def([new_def])

Get or set the definition of the availability variable.

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

calculate_parameter_covariance([pvals, robust])

Calculate the parameter covariance matrix.

check_d_loglike([stylize, skip_zeros])

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

check_for_overspecification([pvals])

Check model for possible over-specification.

check_random_draws([engine])

choice_avail_summary()

Generate a summary of choice and availability statistics.

choice_def([new_def])

Get or set the definition of the choice variable.

clear_cache()

Remove all cached log likelihood values and estimation results.

constraint_converge_tolerance([x])

constraint_penalty([x])

constraint_violation([on_violation, ...])

Check if constraints are currently violated.

copy([datatree])

d2_loglike([x, start_case, stop_case, step_case])

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

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

d_logloss([x, start_case, stop_case, step_case])

distribution_on_idca_variable(x[, xlabel, ...])

Generate a figure of observed and modeled choices over a range of variable values.

distribution_on_idco_variable(x[, xlabel, ...])

Generate a figure of variables over a range of variable values.

doctor(**kwargs)

Run diagnostics, checking for common problems and inconsistencies.

dumps()

estimate(*args, **kwargs)

Maximize loglike, and then calculate parameter covariance.

estimation_statistics([compute_loglike_null])

Create an XHTML summary of estimation statistics.

estimation_statistics_raw([compute_loglike_null])

Compile estimation statistics as a pandas Series.

fit_bhhh(*args, **kwargs)

from_dict(content)

get_param_loc(name)

Get the position of a named parameter.

get_value(name, *[, default, kind])

histogram_on_idca_variable(x, **kwargs)

initialize_graph([alternative_codes, ...])

Write a nesting tree graph for a MNL model.

is_mnl()

Check if this model is a MNL model.

jax_maximize_loglike([method, stderr, ...])

jax_neg_d_loglike(*args, **kwargs)

jax_neg_loglike(params)

jax_param_cov(params)

jumpstart_bhhh([steplen, jumpstart, ...])

Jump start optimization.

load_data(*args, **kwargs)

No-op.

lock_value([name, value])

Set a fixed value for a model parameter.

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

Compute the log likelihood of the model.

loglike2([x, start_case, stop_case, ...])

loglike2_bhhh([x, return_series, ...])

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

loglike_null([use_cache])

Compute the log likelihood at null values.

loglike_problems()

Identify cases with log likelihood problems.

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

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

make_random_draws([engine])

mangle([data, structure])

maximize_loglike(*args, **kwargs)

Maximize the log likelihood.

mixture_density(param_name[, limits])

Create a density plot of a mixture parameter.

mixture_summary()

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

neg_d_loglike([x, start_case, stop_case, ...])

neg_loglike([x, start_case, stop_case, ...])

parameter_summary()

Create a tabular summary of parameter values.

plock([values])

Lock the values of one or more parameters.

pretty_table()

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

Compute values for the probability function embodied by the model.

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

reflow_data_arrays()

Reload the internal data_arrays so they are consistent with the datatree.

release_memory()

Release memory-intensive data structures.

remove_unused_parameters([verbose])

Remove parameters that are not used in the model.

required_data()

Report what data is required in DataFrames for this model to be used.

robust_covariance()

Compute the robust covariance matrix of the parameter estimates.

save(filename[, format, overwrite])

set_cap([cap])

Set limiting values for one or more parameters.

set_value(name[, value, initvalue, ...])

Set the value one or more attributes of a single parameter.

set_values([values])

Set the parameter values for one or more parameters.

should_preload_data([should])

swap_datatree(tree[, should_mangle])

Swap the current datatree with a new datatree.

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

Write the estimation results to an Excel file.

total_weight()

Compute the total weight of cases in the loaded data.

unmangle([force, structure_only])

update_parameters(x)

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

Compute values for the utility function contained in the model.

utility_breakdown(altid, *[, caseid, caseindex])

Compute the utility breakdown for a given case and alternative.

utility_functions([subset, resolve_parameters])

Generate an XHTML output of the utility function(s).

Attributes

autoscale_weights

Whether to automatically scale case weights.

availability_any

A flag indicating whether availability should be inferred from the data.

availability_ca_var

An idca variable or expression indicating if alternatives are available.

availability_co_vars

A mapping giving idco expressions that evaluate to availability indicators.

availability_var

choice_any

choice_ca_var

An idca variable giving the choices as indicator values.

choice_co_code

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

choice_co_vars

A mapping giving idco expressions that evaluate to indicator values.

common_draws

compute_engine

constraint_intensity

A simple attribute descriptor.

constraint_sharpness

A simple attribute descriptor.

constraints

dashboard

A simple attribute descriptor.

data

data_as_loaded

data_as_possible

dataflows

A simple attribute descriptor.

dataset

Data arrays as loaded for model computation.

datatree

A source for data for the model.

float_dtype

graph

groupid

ident

Getter method for the ident property.

is_mangled

log_nans

logsum_parameter

mixtures

most_recent_estimation_result

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

n_cases

The number of cases in the attached data.

n_draws

n_params

ordering

A simple attribute descriptor.

parameters

pbounds

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

pf

A DataFrame of the model parameters.

pholdfast

An array indicating which parameters are marked as holdfast.

pinitvals

An array of the initial parameter values.

pmaximum

An array of the current parameter maximum values.

pminimum

An array of the current parameter minimum values.

pnames

An array of the current parameter names.

pnullvals

An array of the current parameter null values.

possible_overspecification

Possible overspecification of the model.

prerolled_draws

pstderr

An array of the current parameter standard errors.

pvals

An array of the current parameter values.

quantity_ca

The portion of the quantity function computed from idca data.

quantity_scale

rename_parameters

A simple attribute descriptor.

seed

streaming

title

A simple attribute descriptor.

use_streaming

utility_ca

The portion of the utility function computed from idca data.

utility_co

The portion of the utility function computed from idco data.

weight_co_var

weight_normalization

work_arrays

A simple attribute descriptor.