Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def refute_estimate(self):
num_rows = self._data.shape[0]
if self._placebo_type == "permute":
new_treatment = self._data[self._treatment_name].sample(frac=1).values
else:
new_treatment = np.random.randn(num_rows)
new_data = self._data.assign(placebo=new_treatment)
self.logger.debug(new_data[0:10])
estimator_class = self._estimate.params['estimator_class']
identified_estimand = copy.deepcopy(self._target_estimand)
identified_estimand.treatment_variable = ["placebo"]
new_estimator = self.get_estimator_object(new_data, identified_estimand, self._estimate)
new_effect = new_estimator.estimate_effect()
refute = CausalRefutation(self._estimate.value, new_effect.value,
refutation_type="Refute: Use a Placebo Treatment")
return refute
def refute_estimate(self):
new_data = copy.deepcopy(self._data)
new_data = self.include_confounders_effect(new_data)
new_estimator = self.get_estimator_object(new_data, self._target_estimand, self._estimate)
new_effect = new_estimator.estimate_effect()
refute = CausalRefutation(self._estimate.value, new_effect.value,
refutation_type="Refute: Add an Unobserved Common Cause")
return refute
# Adding a new backdoor variable to the identified estimand
identified_estimand.backdoor_variables = new_backdoor_variables
new_estimator = estimator_class(
new_data,
identified_estimand,
self._treatment_name, self._outcome_name, #names of treatment and outcome
test_significance=None,
evaluate_effect_strength=False,
confidence_intervals = self._estimate.params["confidence_intervals"],
target_units = self._estimate.params["target_units"],
effect_modifiers = self._estimate.params["effect_modifiers"],
params=self._estimate.params["method_params"]
)
new_effect = new_estimator.estimate_effect()
refute = CausalRefutation(self._estimate.value, new_effect.value,
refutation_type="Refute: Add a Random Common Cause")
return refute
def refute_estimate(self):
new_data = self._data.sample(frac=self._subset_fraction)
new_estimator = self.get_estimator_object(new_data, self._target_estimand, self._estimate)
new_effect = new_estimator.estimate_effect()
refute = CausalRefutation(
self._estimate.value,
new_effect.value,
refutation_type="Refute: Use a subset of data"
)
return refute