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: Computes the partial R^2 of regression model
  
  :param estimator_model: Linear regression model
  :param treatment: treatment name
  
  :returns: partial R^2 value
docstr_tok: ["Computes","the","partial","R^2","of","regression","model",":","param","estimator_model",":","Linear","regression","model",":","param","treatment",":","treatment","name",":","returns",":","partial","R^2","value"]
code: def partial_r2_func(self, estimator_model=None, treatment=None):
      """
      Computes the partial R^2 of regression model
  
      :param estimator_model: Linear regression model
      :param treatment: treatment name
  
      :returns: partial R^2 value
      """
  
      estimate = estimator_model.params[treatment]
      degree_of_freedom = int(estimator_model.df_resid)
  
      if np.isscalar(estimate):  # for single covariate
          t_stats = estimator_model.tvalues[treatment]
          return t_stats**2 / (t_stats**2 + degree_of_freedom)
  
      else:  # compute for a group of covariates
          covariance_matrix = estimator_model.cov_params().loc[
              treatment, :
          ][treatment]
          n = len(estimate)  # number of parameters in model
          f_stat = (
              np.matmul(
                  np.matmul(
                      estimate.values.T,
                      np.linalg.inv(covariance_matrix.values),
                  ),
                  estimate.values,
              )
              / n
          )
          return f_stat * n / (f_stat * n + degree_of_freedom)
  
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 3 for calling the LinearSensitivityAnalyzer obj's underlying member method code with example usage: obj.partial_r2_func(estimator_model, treatment) and returns: unknown, unknown