class_docstr: Estimate average treatment effect under conditional independence
  
  .. versionadded:: 0.14.0
  
  This class estimates treatment effect and potential outcome using 5
  different methods, ipw, ra, aipw, aipw-wls, ipw-ra.
  Standard errors and inference are based on the joint GMM representation of
  selection or treatment model, outcome model and effect functions.
  
  Parameters
  ----------
  model : instance of a model class
      The model class should contain endog and exog for the outcome model.
  treatment : ndarray
      indicator array for observations with treatment (1) or without (0)
  results_select : results instance
      The results instance for the treatment or selection model.
  _cov_type : "HC0"
      Internal keyword. The keyword oes not affect GMMResults which always
      corresponds to HC0 standard errors.
  kwds : keyword arguments
      currently not used
  
  Notes
  -----
  The outcome model is currently limited to a linear model based on OLS.
  Other outcome models, like Logit and Poisson, will become available in
  future.
  
  See `Treatment Effect notebook
  <../examples/notebooks/generated/treatment_effect.html>`__
  for an overview.
class_docstr_tok: ["Estimate","average","treatment","effect","under","conditional","independence","..","versionadded",":",":","0.14.0","This","class","estimates","treatment","effect","and","potential","outcome","using","5","different","methods",",","ipw",",","ra",",","aipw",",","aipw-wls",",","ipw-ra",".","Standard","errors","and","inference","are","based","on","the","joint","GMM","representation","of","selection","or","treatment","model",",","outcome","model","and","effect","functions",".","Parameters","--","--","--","--","--","model",":","instance","of","a","model","class","The","model","class","should","contain","endog","and","exog","for","the","outcome","model",".","treatment",":","ndarray","indicator","array","for","observations","with","treatment","(","1",")","or","without","(","0",")","results_select",":","results","instance","The","results","instance","for","the","treatment","or","selection","model",".","_cov_type",":","``","HC0","''","Internal","keyword",".","The","keyword","oes","not","affect","GMMResults","which","always","corresponds","to","HC0","standard","errors",".","kwds",":","keyword","arguments","currently","not","used","Notes","--","--","-","The","outcome","model","is","currently","limited","to","a","linear","model","based","on","OLS",".","Other","outcome","models",",","like","Logit","and","Poisson",",","will","become","available","in","future",".","See","`","Treatment","Effect","notebook","<","..","\/examples\/notebooks\/generated\/treatment_effect.html",">","`","__","for","an","overview","."]
docstr: Inverse Probability Weighted treatment effect estimation.
  
  Parameters
  ----------
  return_results : bool
      If True, then a results instance is returned.
      If False, just ATE, POM0 and POM1 are returned.
  effect_group : {"all", 0, 1}
      ``effectgroup`` determines for which population the effects are
      estimated.
      If effect_group is "all", then sample average treatment effect and
      potential outcomes are returned.
      If effect_group is 1 or "treated", then effects on treated are
      returned.
      If effect_group is 0, "treated" or "control", then effects on
      untreated, i.e. control group, are returned.
  disp : bool
      Indicates whether the scipy optimizer should display the
      optimization results
  
  Returns
  -------
  TreatmentEffectsResults instance or tuple (ATE, POM0, POM1)
  
  See Also
  --------
  TreatmentEffectsResults
docstr_tok: ["Inverse","Probability","Weighted","treatment","effect","estimation",".","Parameters","--","--","--","--","--","return_results",":","bool","If","True",",","then","a","results","instance","is","returned",".","If","False",",","just","ATE",",","POM0","and","POM1","are","returned",".","effect_group",":","{","``","all","''",",","0",",","1","}","``","effectgroup","``","determines","for","which","population","the","effects","are","estimated",".","If","effect_group","is","``","all","''",",","then","sample","average","treatment","effect","and","potential","outcomes","are","returned",".","If","effect_group","is","1","or","``","treated","''",",","then","effects","on","treated","are","returned",".","If","effect_group","is","0",",","``","treated","''","or","``","control","''",",","then","effects","on","untreated",",","i.e",".","control","group",",","are","returned",".","disp",":","bool","Indicates","whether","the","scipy","optimizer","should","display","the","optimization","results","Returns","--","--","--","-","TreatmentEffectsResults","instance","or","tuple","(","ATE",",","POM0",",","POM1",")","See","Also","--","--","--","--","TreatmentEffectsResults"]
code: def ipw(self, return_results=True, effect_group="all", disp=False):
      """Inverse Probability Weighted treatment effect estimation.
  
      Parameters
      ----------
      return_results : bool
          If True, then a results instance is returned.
          If False, just ATE, POM0 and POM1 are returned.
      effect_group : {"all", 0, 1}
          ``effectgroup`` determines for which population the effects are
          estimated.
          If effect_group is "all", then sample average treatment effect and
          potential outcomes are returned.
          If effect_group is 1 or "treated", then effects on treated are
          returned.
          If effect_group is 0, "treated" or "control", then effects on
          untreated, i.e. control group, are returned.
      disp : bool
          Indicates whether the scipy optimizer should display the
          optimization results
  
      Returns
      -------
      TreatmentEffectsResults instance or tuple (ATE, POM0, POM1)
  
      See Also
      --------
      TreatmentEffectsResults
      """
      endog = self.model_pool.endog
      tind = self.treatment
      prob = self.prob_select
      if effect_group == "all":
          probt = None
      elif effect_group in [1, "treated"]:
          probt = prob
          effect_group = 1  # standardize effect_group name
      elif effect_group in [0, "untreated", "control"]:
          probt = 1 - prob
          effect_group = 0  # standardize effect_group name
      elif isinstance(effect_group, np.ndarray):
          probt = effect_group
          effect_group = "user"  # standardize effect_group name
      else:
          raise ValueError("incorrect option for effect_group")
  
      res_ipw = ate_ipw(endog, tind, prob, weighted=True, probt=probt)
  
      if not return_results:
          return res_ipw
  
      # gmm = _TEGMMGeneric1(endog, self.results_select, _mom_ols_te,
      #                     probt=probt)
      gmm = _IPWGMM(
          endog,
          self.results_select,
          None,
          teff=self,
          effect_group=effect_group,
      )
      start_params = np.concatenate(
          (res_ipw[:2], self.results_select.params)
      )
      res_gmm = gmm.fit(
          start_params=start_params,
          inv_weights=np.eye(len(start_params)),
          optim_method="nm",
          optim_args={"maxiter": 5000, "disp": disp},
          maxiter=1,
      )
  
      res = TreatmentEffectResults(
          self,
          res_gmm,
          "IPW",
          start_params=start_params,
          effect_group=effect_group,
      )
      return res
  
imports: import numpy
  from statsmodels.compat.pandas import Substitution
  from scipy.linalg import block_diag
  from statsmodels.regression.linear_model import WLS
  from statsmodels.sandbox.regression.gmm import GMM
  from statsmodels.stats.contrast import ContrastResults
  from statsmodels.tools.docstring import indent
label_desc: Use image node_id 3 for calling the TreatmentEffect obj's underlying member method code with example usage: obj.ipw(return_results, effect_group, disp) and returns: res, res_ipw