  We consider the estimation of the average treatment effect in the treated as
a function of baseline covariates, where there is a valid (conditional)
instrument.
  We describe two doubly robust (DR) estimators: a locally efficient
g-estimator, and a targeted minimum loss-based estimator (TMLE). These two DR
estimators can be viewed as generalisations of the two-stage least squares
(TSLS) method to semi-parametric models that make weaker assumptions. We
exploit recent theoretical results that extend to the g-estimator the use of
data-adaptive fits for the nuisance parameters.
  A simulation study is used to compare standard TSLS with the two DR
estimators' finite-sample performance, (1) when fitted using parametric
nuisance models, and (2) using data-adaptive nuisance fits, obtained from the
Super Learner, an ensemble machine learning method.
  Data-adaptive DR estimators have lower bias and improved coverage, when
compared to incorrectly specified parametric DR estimators and TSLS. When the
parametric model for the treatment effect curve is correctly specified, the
g-estimator outperforms all others, but when this model is misspecified, TMLE
performs best, while TSLS can result in large biases and zero coverage.
  Finally, we illustrate the methods by reanalysing the COPERS (COping with
persistent Pain, Effectiveness Research in Self-management) trial to make
inference about the causal effect of treatment actually received, and the
extent to which this is modified by depression at baseline.
