larch.numba.Model.probability

larch.numba.Model.probability

Model.probability(self, x=None, start_case=0, stop_case=- 1, step_case=1, return_dataframe=False, include_nests=False)

Compute probability values.

Parameters
  • x ({'null', 'init', 'best', array-like, dict, scalar}, optional) – Values for the parameters. See set_values for details.

  • start_case (int, default 0) – The first case to include in the log likelihood computation. To include all cases, start from 0 (the default).

  • stop_case (int, default -1) – One past the last case to include in the log likelihood computation. This is processed as usual for Python slicing and iterating, and negative values count backward from the end. To include all cases, end at -1 (the default).

  • step_case (int, default 1) – The step size of the case iterator to use in likelihood calculation. This is processed as usual for Python slicing and iterating. To include all cases, step by 1 (the default).

  • return_dataframe ({'names', True, False, 'idco', 'idca', 'idce'}, default False) – Format for the results. If True or ‘idco’, a pandas.DataFrame is returned, with case indexes and alternative code columns. If ‘names’, the alternative names are used for the columns. If set to False, the results are returned as a numpy array. If ‘idca’, the resulting dataframe is stacked, such that a single column is included and there is a two-level MultiIndex with caseids and alternative codes, respectively. If ‘idce’, the resulting dataframe is stacked and unavailable alternatives are removed.

  • include_nests (bool, default False) – Whether to include the nests section in a nested model. This argument is ignored for MNL models as the probability array is naturally limited to only the elemental alternatives.

Returns

array or DataFrame