class_docstr: Compute effect of treatment using the instrumental variables method.
  
  This is also a superclass that can be inherited by other specific methods.
  
  Supports additional parameters as listed below.
class_docstr_tok: ["Compute","effect","of","treatment","using","the","instrumental","variables","method",".","This","is","also","a","superclass","that","can","be","inherited","by","other","specific","methods",".","Supports","additional","parameters","as","listed","below","."]
docstr: Fits the estimator with data for effect estimation
  :param data: data frame containing the data
  :param treatment: name of the treatment variable
  :param outcome: name of the outcome variable
  :param effect_modifiers: Variables on which to compute separate
              effects, or return a heterogeneous effect function. Not all
              methods support this currently.
docstr_tok: ["Fits","the","estimator","with","data","for","effect","estimation",":","param","data",":","data","frame","containing","the","data",":","param","treatment",":","name","of","the","treatment","variable",":","param","outcome",":","name","of","the","outcome","variable",":","param","effect_modifiers",":","Variables","on","which","to","compute","separate","effects",",","or","return","a","heterogeneous","effect","function",".","Not","all","methods","support","this","currently","."]
code: def fit(
      self,
      data: pd.DataFrame,
      effect_modifier_names: Optional[List[str]] = None,
  ):
      """
      Fits the estimator with data for effect estimation
      :param data: data frame containing the data
      :param treatment: name of the treatment variable
      :param outcome: name of the outcome variable
      :param effect_modifiers: Variables on which to compute separate
                  effects, or return a heterogeneous effect function. Not all
                  methods support this currently.
      """
      self._set_effect_modifiers(data, effect_modifier_names)
  
      self.estimating_instrument_names = (
          self._target_estimand.instrumental_variables
      )
      if self.iv_instrument_name is not None:
          self.estimating_instrument_names = parse_state(
              self.iv_instrument_name
          )
      self.logger.debug(
          "Instrumental Variables used:"
          + ",".join(self.estimating_instrument_names)
      )
      if not self.estimating_instrument_names:
          raise ValueError(
              "No valid instruments found. IV Method not applicable"
          )
      if len(self.estimating_instrument_names) < len(
          self._target_estimand.treatment_variable
      ):
          # TODO move this to the identification step
          raise ValueError(
              "Number of instruments fewer than number of treatments. 2SLS requires at least as many instruments as treatments."
          )
      self._estimating_instruments = data[
          self.estimating_instrument_names
      ]
  
      self.symbolic_estimator = self.construct_symbolic_estimator(
          self._target_estimand
      )
      self.logger.info(self.symbolic_estimator)
  
      return self
  
file_path: dowhy/dowhy/causal_estimators/instrumental_variable_estimator.py
imports: from typing import Any, Dict, List, Optional, Union
  import numpy
  import pandas
  import sympy
  import sympy.stats
  from statsmodels.sandbox.regression.gmm import IV2SLS
  from dowhy.causal_estimator import CausalEstimate, CausalEstimator, RealizedEstimand
  from dowhy.causal_identifier import IdentifiedEstimand
  from dowhy.utils.api import parse_state
label_desc: Use image node_id 2 for calling the InstrumentalVariableEstimator obj's underlying member method code with example usage: obj.fit(data, effect_modifier_names) and returns: self