class_docstr: Class to perform sensitivity analysis
  See: https://carloscinelli.com/files/Cinelli%20and%20Hazlett%20(2020)%20-%20Making%20Sense%20of%20Sensitivity.pdf
  
  :param estimator: linear estimator of the causal model
  :param data: Pandas dataframe
  :param treatment_name: name of treatment
   :param percent_change_estimate: It is the percentage of reduction of treatment estimate that could alter the results (default = 1)
                                      if percent_change_estimate = 1, the robustness value describes the strength of association of confounders with treatment and outcome in order to reduce the estimate by 100% i.e bring it down to 0.
  :param null_hypothesis_effect: assumed effect under the null hypothesis
  :param confounder_increases_estimate: True implies that confounder increases the absolute value of estimate and vice versa. (Default = True)
  :param benchmark_common_causes: names of variables for bounding strength of confounders
  :param significance_level: confidence interval for statistical inference(default = 0.05)
  :param frac_strength_treatment: strength of association between unobserved confounder and treatment compared to benchmark covariate
  :param frac_strength_outcome: strength of association between unobserved confounder and outcome compared to benchmark covariate
  :param common_causes_order: The order of column names in OLS regression data
class_docstr_tok: ["Class","to","perform","sensitivity","analysis","See",":","https",":","\/\/carloscinelli.com\/files\/Cinelli","%","20and","%","20Hazlett","%","20","(","2020",")","%","20-","%","20Making","%","20Sense","%","20of","%","20Sensitivity.pdf",":","param","estimator",":","linear","estimator","of","the","causal","model",":","param","data",":","Pandas","dataframe",":","param","treatment_name",":","name","of","treatment",":","param","percent_change_estimate",":","It","is","the","percentage","of","reduction","of","treatment","estimate","that","could","alter","the","results","(","default","=","1",")","if","percent_change_estimate","=","1",",","the","robustness","value","describes","the","strength","of","association","of","confounders","with","treatment","and","outcome","in","order","to","reduce","the","estimate","by","100","%","i.e","bring","it","down","to","0.",":","param","null_hypothesis_effect",":","assumed","effect","under","the","null","hypothesis",":","param","confounder_increases_estimate",":","True","implies","that","confounder","increases","the","absolute","value","of","estimate","and","vice","versa",".","(","Default","=","True",")",":","param","benchmark_common_causes",":","names","of","variables","for","bounding","strength","of","confounders",":","param","significance_level",":","confidence","interval","for","statistical","inference","(","default","=","0.05",")",":","param","frac_strength_treatment",":","strength","of","association","between","unobserved","confounder","and","treatment","compared","to","benchmark","covariate",":","param","frac_strength_outcome",":","strength","of","association","between","unobserved","confounder","and","outcome","compared","to","benchmark","covariate",":","param","common_causes_order",":","The","order","of","column","names","in","OLS","regression","data"]
docstr: Plots and summarizes the sensitivity bounds as a contour plot, as they vary with the partial R^2 of the unobserved confounder(s) with the treatment and the outcome
  Two types of plots can be generated, based on adjusted estimates or adjusted t-values
  X-axis: Partial R^2 of treatment and unobserved confounder(s)
  Y-axis: Partial R^2 of outcome and unobserved confounder(s)
  We also plot bounds on the partial R^2 of the unobserved confounders obtained from observed covariates
  
  :param plot_type: "estimate" or "t-value"
  :param critical_value: special reference value of the estimate or t-value that will be highlighted in the plot
  :param x_limit: plot's maximum x_axis value (default = 0.8)
  :param y_limit: plot's minimum y_axis value (default = 0.8)
  :param num_points_per_contour: number of points to calculate and plot each contour line (default = 200)
  :param plot_size: tuple denoting the size of the plot (default = (7,7))
  :param contours_color: color of contour line (default = blue)
                         String or array. If array, lines will be plotted with the specific color in ascending order.
  :param critical_contour_color: color of threshold line (default = red)
  :param label_fontsize: fontsize for labelling contours (default = 9)
  :param contour_linewidths: linewidths for contours (default = 0.75)
  :param contour_linestyles: linestyles for contours (default = "solid")
                             See : https://matplotlib.org/3.5.0/gallery/lines_bars_and_markers/linestyles.html for more examples
  :param contours_label_color: color of contour line label (default = black)
  :param critical_label_color: color of threshold line label (default = red)
  :param unadjusted_estimate_marker: marker type for unadjusted estimate in the plot (default = 'D')
                                     See: https://matplotlib.org/stable/api/markers_api.html
  :parm unadjusted_estimate_color: marker color for unadjusted estimate in the plot (default = "black")
  :param adjusted_estimate_marker: marker type for bias adjusted estimates in the plot (default = '^')
  :parm adjusted_estimate_color: marker color for bias adjusted estimates in the plot (default = "red")
  :param legend_position:tuple denoting the position of the legend (default = (1.6, 0.6))
docstr_tok: ["Plots","and","summarizes","the","sensitivity","bounds","as","a","contour","plot",",","as","they","vary","with","the","partial","R^2","of","the","unobserved","confounder","(","s",")","with","the","treatment","and","the","outcome","Two","types","of","plots","can","be","generated",",","based","on","adjusted","estimates","or","adjusted","t-values","X-axis",":","Partial","R^2","of","treatment","and","unobserved","confounder","(","s",")","Y-axis",":","Partial","R^2","of","outcome","and","unobserved","confounder","(","s",")","We","also","plot","bounds","on","the","partial","R^2","of","the","unobserved","confounders","obtained","from","observed","covariates",":","param","plot_type",":","``","estimate","''","or","``","t-value","''",":","param","critical_value",":","special","reference","value","of","the","estimate","or","t-value","that","will","be","highlighted","in","the","plot",":","param","x_limit",":","plot","'s","maximum","x_axis","value","(","default","=","0.8",")",":","param","y_limit",":","plot","'s","minimum","y_axis","value","(","default","=","0.8",")",":","param","num_points_per_contour",":","number","of","points","to","calculate","and","plot","each","contour","line","(","default","=","200",")",":","param","plot_size",":","tuple","denoting","the","size","of","the","plot","(","default","=","(","7,7",")",")",":","param","contours_color",":","color","of","contour","line","(","default","=","blue",")","String","or","array",".","If","array",",","lines","will","be","plotted","with","the","specific","color","in","ascending","order",".",":","param","critical_contour_color",":","color","of","threshold","line","(","default","=","red",")",":","param","label_fontsize",":","fontsize","for","labelling","contours","(","default","=","9",")",":","param","contour_linewidths",":","linewidths","for","contours","(","default","=","0.75",")",":","param","contour_linestyles",":","linestyles","for","contours","(","default","=","``","solid","''",")","See",":","https",":","\/\/matplotlib.org\/3.5.0\/gallery\/lines_bars_and_markers\/linestyles.html","for","more","examples",":","param","contours_label_color",":","color","of","contour","line","label","(","default","=","black",")",":","param","critical_label_color",":","color","of","threshold","line","label","(","default","=","red",")",":","param","unadjusted_estimate_marker",":","marker","type","for","unadjusted","estimate","in","the","plot","(","default","=","'D","'",")","See",":","https",":","\/\/matplotlib.org\/stable\/api\/markers_api.html",":","parm","unadjusted_estimate_color",":","marker","color","for","unadjusted","estimate","in","the","plot","(","default","=","``","black","''",")",":","param","adjusted_estimate_marker",":","marker","type","for","bias","adjusted","estimates","in","the","plot","(","default","=","'^","'",")",":","parm","adjusted_estimate_color",":","marker","color","for","bias","adjusted","estimates","in","the","plot","(","default","=","``","red","''",")",":","param","legend_position",":","tuple","denoting","the","position","of","the","legend","(","default","=","(","1.6",",","0.6",")",")"]
code: def plot(
      self,
      plot_type="estimate",
      critical_value=None,
      x_limit=0.8,
      y_limit=0.8,
      num_points_per_contour=200,
      plot_size=(7, 7),
      contours_color="blue",
      critical_contour_color="red",
      label_fontsize=9,
      contour_linewidths=0.75,
      contour_linestyles="solid",
      contours_label_color="black",
      critical_label_color="red",
      unadjusted_estimate_marker="D",
      unadjusted_estimate_color="black",
      adjusted_estimate_marker="^",
      adjusted_estimate_color="red",
      legend_position=(1.6, 0.6),
  ):
      """
      Plots and summarizes the sensitivity bounds as a contour plot, as they vary with the partial R^2 of the unobserved confounder(s) with the treatment and the outcome
      Two types of plots can be generated, based on adjusted estimates or adjusted t-values
      X-axis: Partial R^2 of treatment and unobserved confounder(s)
      Y-axis: Partial R^2 of outcome and unobserved confounder(s)
      We also plot bounds on the partial R^2 of the unobserved confounders obtained from observed covariates
  
      :param plot_type: "estimate" or "t-value"
      :param critical_value: special reference value of the estimate or t-value that will be highlighted in the plot
      :param x_limit: plot's maximum x_axis value (default = 0.8)
      :param y_limit: plot's minimum y_axis value (default = 0.8)
      :param num_points_per_contour: number of points to calculate and plot each contour line (default = 200)
      :param plot_size: tuple denoting the size of the plot (default = (7,7))
      :param contours_color: color of contour line (default = blue)
                             String or array. If array, lines will be plotted with the specific color in ascending order.
      :param critical_contour_color: color of threshold line (default = red)
      :param label_fontsize: fontsize for labelling contours (default = 9)
      :param contour_linewidths: linewidths for contours (default = 0.75)
      :param contour_linestyles: linestyles for contours (default = "solid")
                                 See : https://matplotlib.org/3.5.0/gallery/lines_bars_and_markers/linestyles.html for more examples
      :param contours_label_color: color of contour line label (default = black)
      :param critical_label_color: color of threshold line label (default = red)
      :param unadjusted_estimate_marker: marker type for unadjusted estimate in the plot (default = 'D')
                                         See: https://matplotlib.org/stable/api/markers_api.html
      :parm unadjusted_estimate_color: marker color for unadjusted estimate in the plot (default = "black")
      :param adjusted_estimate_marker: marker type for bias adjusted estimates in the plot (default = '^')
      :parm adjusted_estimate_color: marker color for bias adjusted estimates in the plot (default = "red")
      :param legend_position:tuple denoting the position of the legend (default = (1.6, 0.6))
      """
  
      # Plotting the contour plot
      if plot_type == "estimate":
          critical_value = 0  # default value of estimate
      else:
          critical_value = (
              2  # default t-value (usual approx for 95% CI)
          )
  
      fig, ax = plt.subplots(1, 1, figsize=plot_size)
      ax.set_title("Sensitivity contour plot of %s" % plot_type)
      ax.set_xlabel("Partial R^2 of confounder with treatment")
      ax.set_ylabel("Partial R^2 of confounder with outcome")
  
      for i in range(len(self.r2tu_w)):
          x = self.r2tu_w[i]
          y = self.r2yu_tw[i]
          if x > 0.8 or y > 0.8:
              x_limit = 0.99
              y_limit = 0.99
              break
  
      r2tu_w = np.arange(0.0, x_limit, x_limit / num_points_per_contour)
      r2yu_tw = np.arange(
          0.0, y_limit, y_limit / num_points_per_contour
      )
  
      unadjusted_point_estimate = None
  
      if plot_type == "estimate":
          (
              contour_values,
              critical_value,
              bound_values,
          ) = self.plot_estimate(r2tu_w, r2yu_tw)
          unadjusted_estimate = self.estimate
          unadjusted_point_estimate = unadjusted_estimate
      elif plot_type == "t-value":
          contour_values, critical_value, bound_values = self.plot_t(
              r2tu_w, r2yu_tw
          )
          unadjusted_t = self.t_stats
          unadjusted_point_estimate = unadjusted_t
      else:
          raise ValueError(
              "Current plotting method only supports 'estimate' and 't-value' "
          )
  
      # Adding contours
      contour_plot = ax.contour(
          r2tu_w,
          r2yu_tw,
          contour_values,
          colors=contours_color,
          linewidths=contour_linewidths,
          linestyles=contour_linestyles,
      )
      ax.clabel(
          contour_plot,
          inline=1,
          fontsize=label_fontsize,
          colors=contours_label_color,
      )
  
      # Adding threshold contour line
      contour_plot = ax.contour(
          r2tu_w,
          r2yu_tw,
          contour_values,
          colors=critical_contour_color,
          linewidths=contour_linewidths,
          levels=[critical_value],
      )
      ax.clabel(
          contour_plot,
          [critical_value],
          inline=1,
          fontsize=label_fontsize,
          colors=critical_label_color,
      )
  
      # Adding unadjusted point estimate
      ax.scatter(
          [0],
          [0],
          marker=unadjusted_estimate_marker,
          color=unadjusted_estimate_color,
          label="Unadjusted({:1.2f})".format(unadjusted_point_estimate),
      )
  
      # Adding bounds to partial R^2 values for given strength of confounders
      for i in range(len(self.frac_strength_treatment)):
          frac_strength_treatment = self.frac_strength_treatment[i]
          frac_strength_outcome = self.frac_strength_outcome[i]
          if frac_strength_treatment == frac_strength_outcome:
              signs = str(round(frac_strength_treatment, 2))
          else:
              signs = (
                  str(round(frac_strength_treatment, 2))
                  + "/"
                  + str(round(frac_strength_outcome, 2))
              )
          label = (
              str(i + 1)
              + "  "
              + signs
              + " X "
              + str(self.original_benchmark_covariates)
              + " ({:1.2f}) ".format(bound_values[i])
          )
          ax.scatter(
              self.r2tu_w[i],
              self.r2yu_tw[i],
              color=adjusted_estimate_color,
              marker=adjusted_estimate_marker,
              label=label,
          )
          ax.annotate(
              str(i + 1),
              (self.r2tu_w[i] + 0.005, self.r2yu_tw[i] + 0.005),
          )
  
      ax.legend(bbox_to_anchor=legend_position)
      plt.show()
  
file_path: dowhy/dowhy/causal_refuters/linear_sensitivity_analyzer.py
imports: import logging
  import matplotlib.pyplot
  import numpy
  import pandas
  import statsmodels.api
  from scipy.stats import t
  from dowhy.utils.api import parse_state
label_desc: Use image node_id 9 for calling the LinearSensitivityAnalyzer obj's underlying member method code with example usage: obj.plot(plot_type, critical_value, x_limit, y_limit, num_points_per_contour, plot_size, contours_color, critical_contour_color, label_fontsize, contour_linewidths, contour_linestyles, contours_label_color, critical_label_color, unadjusted_estimate_marker, unadjusted_estimate_color, adjusted_estimate_marker, adjusted_estimate_color, legend_position) without return types