class_docstr: Compute treatment effect whenever the effect is fully mediated by
  another variable (front-door) or when there is an instrument available.
  
  Currently only supports a linear model for the effects.
  
  Supports additional parameters as listed below.
class_docstr_tok: ["Compute","treatment","effect","whenever","the","effect","is","fully","mediated","by","another","variable","(","front-door",")","or","when","there","is","an","instrument","available",".","Currently","only","supports","a","linear","model","for","the","effects",".","Supports","additional","parameters","as","listed","below","."]
code: def estimate_effect(
      self,
      data: pd.DataFrame,
      treatment_value: Any = 1,
      control_value: Any = 0,
      target_units=None,
      **_,
  ):
      self._target_units = target_units
      self._treatment_value = treatment_value
      self._control_value = control_value
  
      estimate_value = None
      # First stage
      first_stage_estimate = self._first_stage_model.estimate_effect(
          data,
          control_value=control_value,
          treatment_value=treatment_value,
          target_units=target_units,
      )
  
      # Second Stage
      second_stage_estimate = self._second_stage_model.estimate_effect(
          data,
          control_value=control_value,
          treatment_value=treatment_value,
          target_units=target_units,
      )
      # Combining the two estimates
      natural_indirect_effect = (
          first_stage_estimate.value * second_stage_estimate.value
      )
      # This same estimate is valid for frontdoor as well as mediation (NIE)
      estimate_value = natural_indirect_effect
      self.symbolic_estimator = self.construct_symbolic_estimator(
          first_stage_estimate.realized_estimand_expr,
          second_stage_estimate.realized_estimand_expr,
          estimand_type=EstimandType.NONPARAMETRIC_NIE,
      )
      if (
          self._target_estimand.estimand_type
          == EstimandType.NONPARAMETRIC_NDE
      ):
          total_effect_estimate = (
              self._second_stage_model_nde.estimate_effect(
                  data,
                  control_value=control_value,
                  treatment_value=treatment_value,
                  target_units=target_units,
              )
          )
          natural_direct_effect = (
              total_effect_estimate.value - natural_indirect_effect
          )
          estimate_value = natural_direct_effect
          self.symbolic_estimator = self.construct_symbolic_estimator(
              first_stage_estimate.realized_estimand_expr,
              second_stage_estimate.realized_estimand_expr,
              total_effect_estimate.realized_estimand_expr,
              estimand_type=self._target_estimand.estimand_type,
          )
      estimate = CausalEstimate(
          data=data,
          treatment_name=self._target_estimand.treatment_variable,
          outcome_name=self._target_estimand.outcome_variable,
          estimate=estimate_value,
          control_value=control_value,
          treatment_value=treatment_value,
          target_estimand=self._target_estimand,
          realized_estimand_expr=self.symbolic_estimator,
      )
  
      estimate.add_estimator(self)
      return estimate
  
file_path: dowhy/dowhy/causal_estimators/two_stage_regression_estimator.py
imports: import copy
  from typing import Any, List, Optional, Type, Union
  import numpy
  import pandas
  from dowhy.causal_estimator import CausalEstimate, CausalEstimator
  from dowhy.causal_estimators.linear_regression_estimator import LinearRegressionEstimator
  from dowhy.causal_identifier import EstimandType, IdentifiedEstimand
  from dowhy.utils.api import parse_state
label_desc: Use image node_id 3 for calling the TwoStageRegressionEstimator obj's underlying member method code with example usage: obj.estimate_effect(data, treatment_value, control_value, target_units) and returns: estimate