Exemple #1
0
 def _estimate_effect(self):
     upper_limit = self.rd_threshold_value + self.rd_bandwidth
     lower_limit = self.rd_threshold_value - self.rd_bandwidth
     rows_filter = np.s_[(self.rd_variable >= lower_limit)
                         & (self.rd_variable <= upper_limit)]
     local_rd_variable = self.rd_variable[rows_filter]
     local_treatment_variable = self._treatment[rows_filter]
     local_outcome_variable = self._outcome[rows_filter]
     local_df = pd.DataFrame(
         data={
             'local_rd_variable': local_rd_variable,
             'local_treatment': local_treatment_variable,
             'local_outcome': local_outcome_variable
         })
     iv_estimator = InstrumentalVariableEstimator(
         local_df,
         self._target_estimand, ['local_treatment'], ['local_outcome'],
         test_significance=self._significance_test,
         params={'iv_instrument_name': 'local_rd_variable'})
     est = iv_estimator.estimate_effect()
     return est
 def _estimate_effect(self):
     upper_limit = self.rd_threshold_value + self.rd_bandwidth
     lower_limit = self.rd_threshold_value - self.rd_bandwidth
     rows_filter = np.s_[(self.rd_variable >= lower_limit)
                         & (self.rd_variable <= upper_limit)]
     local_rd_variable = self.rd_variable[rows_filter]
     local_treatment_variable = self._treatment[self._treatment_name[0]][
         rows_filter]  # indexing by treatment name again since this method assumes a single-dimensional treatment
     local_outcome_variable = self._outcome[rows_filter]
     local_df = pd.DataFrame(
         data={
             'local_rd_variable': local_rd_variable,
             'local_treatment': local_treatment_variable,
             'local_outcome': local_outcome_variable
         })
     print(local_df)
     iv_estimator = InstrumentalVariableEstimator(
         local_df,
         self._target_estimand, ['local_treatment'], ['local_outcome'],
         test_significance=self._significance_test,
         iv_instrument_name='local_rd_variable')
     est = iv_estimator.estimate_effect()
     return est