def run(self, data, *args, **kwargs): self._last_coefficients = None result = bhhh_mnl_estimation.run(self, data, *args, **kwargs) # run a diagnose procedure if self._last_coefficients is not None: utilities_class = linear_utilities_diagnose() utilities_class.run(data, self._last_coefficients, resources=self.resources) return result
def run(self, data, upc_sequence, resources): """ 'data' is of shape (nobservations, nchoices, nvariables). WESML procedure (Weighted endogenous sampling maximum likelihood), Manski, Lerman 1977 data are weighted by correction weights (observation_share/sampled_share) in order to take into account undersampled or oversampled observations. Set the variable name for the correction weights into estimate_config (in choice_model) as "wesml_sampling_correction_variable" entry. """ model = resources.get("_model_") self.wesml_weights = model.get_attribute_for_submodel(resources.get("wesml_sampling_correction_variable"), resources) return bhhh_mnl_estimation.run(self, data, upc_sequence, resources)
def run(self, data, upc_sequence, resources): """ 'data' is of shape (nobservations, nchoices, nvariables). WESML procedure (Weighted endogenous sampling maximum likelihood), Manski, Lerman 1977 data are weighted by correction weights (observation_share/sampled_share) in order to take into account undersampled or oversampled observations. Set the variable name for the correction weights into estimate_config (in choice_model) as "wesml_sampling_correction_variable" entry. """ model = resources.get("_model_") self.wesml_weights = model.get_attribute_for_submodel( resources.get("wesml_sampling_correction_variable"), resources) return bhhh_mnl_estimation.run(self, data, upc_sequence, resources)
def run(self, data, upc_sequence, resources): """ 'data' is of shape (nobservations, nchoices, nvariables). WESML procedure (Weighted endogenous sampling maximum likelihood), Manski, Lerman 1977 data are weighted by correction weights (observation_share/sampled_share) in order to take into account undersampled or oversampled observations. Set the variable name for the correction weights into estimate_config (in choice_model) as "wesml_sampling_correction_variable" entry. """ model = resources.get("_model_") self.wesml_weights = model.choice_set.compute_variables([resources.get("wesml_sampling_correction_variable")], dataset_pool=model.dataset_pool) self.wesml_weights = self.wesml_weights[resources.get("index")] weighted_data = data*reshape(self.wesml_weights, (data.shape[0], data.shape[1], 1)) return bhhh_mnl_estimation.run(self, weighted_data, upc_sequence, resources)