diff --git a/choicemodels/mnl.py b/choicemodels/mnl.py index 552d42b..d3cc346 100644 --- a/choicemodels/mnl.py +++ b/choicemodels/mnl.py @@ -586,7 +586,7 @@ def mnl_loglik(beta, data, chosen, numalts, weights=None, lcgrad=False, return -1 * loglik, -1 * gradarr -def mnl_estimate(data, chosen, numalts, GPU=False, coeffrange=(-1000, 1000), +def mnl_estimate(data, chosen, numalts, GPU=False, coeffrange=(None, None), weights=None, lcgrad=False, beta=None): """ Calculate coefficients of the MNL model. @@ -689,7 +689,7 @@ def mnl_estimate(data, chosen, numalts, GPU=False, coeffrange=(-1000, 1000), beta, args=args, fprime=None, - factr=10, + factr=10e9, approx_grad=False, bounds=bounds) logger.debug('finish: scipy optimization for MNL fit') @@ -715,6 +715,7 @@ def mnl_estimate(data, chosen, numalts, GPU=False, coeffrange=(-1000, 1000), aic = -2 * ll + 2 * len(beta) log_likelihood = { + "model_converged": bfgs_result[2]['warnflag'] == 0, 'null': float(l0[0][0]), 'convergence': float(l1[0][0]), 'ratio': float((1 - (l1 / l0))[0][0]), diff --git a/choicemodels/tools/simulation.py b/choicemodels/tools/simulation.py index 3040167..1652ed3 100644 --- a/choicemodels/tools/simulation.py +++ b/choicemodels/tools/simulation.py @@ -176,7 +176,7 @@ def iterative_lottery_choices( capacity, size = (alt_capacity, chooser_size) len_choosers = len(choosers) - valid_choices = pd.Series() + valid_choices = pd.Series(dtype='float64') iter = 0 while (len(valid_choices) < len_choosers):