Skip to content

Commit 8157591

Browse files
committed
update guide
1 parent 1742b18 commit 8157591

File tree

3 files changed

+44
-46
lines changed

3 files changed

+44
-46
lines changed

doc/guide/models/plm/lplr.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
\mathbb{E} [Y | D, X] = \mathbb{P} (Y=1 | D, X) = \text{expit} \{\beta_0 D + r_0 (X) \}
66
77
where :math:`Y` is the binary outcome variable and :math:`D` is the policy variable of interest.
8-
The high-dimensional vector :math:`X = (X_1, \ldots, X_p)` consists of other confounding covariates.
8+
The high-dimensional vector :math:`X = (X_1, \ldots, X_p)` consists of confounding covariates and
99
:math:`\text{expit}` is the logistic link function
1010

1111
.. math::

doc/guide/models/plm/plm_models.inc

Lines changed: 36 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,40 @@ Partially linear regression model (PLR)
6464
dml_plr_obj$fit()
6565
print(dml_plr_obj)
6666

67+
.. _lplr-model:
68+
69+
Logistic partially linear regression model (LPLR)
70+
*************************************************
71+
72+
.. include:: /guide/models/plm/lplr.rst
73+
74+
.. include:: /shared/causal_graphs/plr_irm_causal_graph.rst
75+
76+
``DoubleMLLPLR`` implements LPLR models. Estimation is conducted via its ``fit()`` method.
77+
78+
.. note::
79+
Remark that the treatment effects are not additive in this model. The partial linear term enters the model through a logistic link function.
80+
81+
.. tab-set::
82+
83+
.. tab-item:: Python
84+
:sync: py
85+
86+
.. ipython:: python
87+
88+
import numpy as np
89+
import doubleml as dml
90+
from doubleml.plm.datasets import make_lplr_LZZ2020
91+
from sklearn.ensemble import RandomForestRegressor, RandomForestClassifier
92+
from sklearn.base import clone
93+
np.random.seed(3141)
94+
ml_t = RandomForestRegressor(n_estimators=100, max_features=15, max_depth=15, min_samples_leaf=5)
95+
ml_m = RandomForestRegressor(n_estimators=100, max_features=15, max_depth=15, min_samples_leaf=5)
96+
ml_M = RandomForestClassifier(n_estimators=100, max_features=15, max_depth=15, min_samples_leaf=5)
97+
obj_dml_data = make_lplr_LZZ2020(alpha=0.5, n_obs=1000, dim_x=15)
98+
dml_lplr_obj = dml.DoubleMLLPLR(obj_dml_data, ml_M, ml_t, ml_m)
99+
dml_lplr_obj.fit().summary
100+
67101

68102
.. _pliv-model:
69103

@@ -91,12 +125,12 @@ Estimation is conducted via its ``fit()`` method:
91125
from sklearn.ensemble import RandomForestRegressor
92126
from sklearn.base import clone
93127

94-
learner = RandomForestRegressor(n_estimators=100, max_features=20, max_depth=5, min_samples_leaf=2)
128+
learner = RandomForestRegressor(n_estimators=100, max_features=5, max_depth=5, min_samples_leaf=5)
95129
ml_l = clone(learner)
96130
ml_m = clone(learner)
97131
ml_r = clone(learner)
98132
np.random.seed(2222)
99-
data = make_pliv_CHS2015(alpha=0.5, n_obs=500, dim_x=20, dim_z=1, return_type='DataFrame')
133+
data = make_pliv_CHS2015(alpha=0.5, n_obs=500, dim_x=5, dim_z=1, return_type='DataFrame')
100134
obj_dml_data = dml.DoubleMLData(data, 'y', 'd', z_cols='Z1')
101135
dml_pliv_obj = dml.DoubleMLPLIV(obj_dml_data, ml_l, ml_m, ml_r)
102136
print(dml_pliv_obj.fit())
@@ -121,39 +155,3 @@ Estimation is conducted via its ``fit()`` method:
121155
dml_pliv_obj = DoubleMLPLIV$new(obj_dml_data, ml_l, ml_m, ml_r)
122156
dml_pliv_obj$fit()
123157
print(dml_pliv_obj)
124-
125-
Logistic partially linear regression model (LPLR)
126-
*************************************************
127-
128-
.. include:: /guide/models/plm/lplr.rst
129-
130-
.. include:: /shared/causal_graphs/plr_irm_causal_graph.rst
131-
132-
``DoubleMLLPLR`` implements LPLR models. Estimation is conducted via its ``fit()`` method.
133-
134-
.. note::
135-
Remark that the treatment effects are not additive in this model. The partial linear term enters the model through a logistic link function.
136-
137-
.. tab-set::
138-
139-
.. tab-item:: Python
140-
:sync: py
141-
142-
.. ipython:: python
143-
:okwarning:
144-
145-
import numpy as np
146-
import doubleml as dml
147-
from doubleml.plm.datasets import make_lplr_LZZ2020
148-
from sklearn.ensemble import RandomForestRegressor, RandomForestClassifier
149-
from sklearn.base import clone
150-
np.random.seed(3141)
151-
ml_t = RandomForestRegressor(n_estimators=100, max_features=20, max_depth=5, min_samples_leaf=2)
152-
ml_m = RandomForestRegressor(n_estimators=100, max_features=20, max_depth=5, min_samples_leaf=2)
153-
ml_M = RandomForestClassifier(n_estimators=100, max_features=20, max_depth=5, min_samples_leaf=2)
154-
obj_dml_data = make_lplr_LZZ2020(alpha=0.5, n_obs=500, dim_x=20)
155-
dml_lplr_obj = dml.DoubleMLPLR(obj_dml_data, ml_M, ml_t, ml_m)
156-
dml_lplr_obj.fit().summary
157-
158-
159-

doc/guide/scores/plm/lplr_score.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
For the LPLR model implemented in ``DoubleMLLPLR`` one can choose between
2-
``score='nuisance_space'`` and ``score='instrument'``. For the LPLR model let ``treatment=d`` and :math:`Y\in\{0,1\}`
2+
``score='nuisance_space'`` and ``score='instrument'``.
33

44
``score='nuisance_space'`` implements the score function:
55

66
.. math::
77
88
\psi(W, \beta, \eta) := \psi(X) \{Y e^{\beta D} -(1-Y)e^{r_0(X)} \} \{ D - m_0(X)\}
99
10-
with :math:`\eta = { r(\cdot), m(\cdot), \psi(\cdot) }`, where
10+
with nuisance elements :math:`\eta = { r(\cdot), m(\cdot), \psi(\cdot) }`, where
1111

1212
.. math::
1313
14-
\r_0(X) = t_0(X) - \breve \beta a_0(X),
14+
r_0(X) = t_0(X) - \breve \beta a_0(X),
1515
1616
m_0(X) = \mathbb{E} [D | X, Y=0],
1717
1818
\psi(X) = \text{expit} (-r_0(X)).
1919
2020
For the estimation of :math:`r_0(X)`, we further need to obtain the following estimates as well as a preliminary estimate
21-
:math:`\breve \beta` as described in `Liu et al. (2021) <https://academic.oup.com/ectj/article/24/3/559/6296639>`_
21+
:math:`\breve \beta` as described in `Liu et al. (2021) <https://doi.org/10.1093/ectj/utab019>`_
2222

2323
.. math::
2424
25-
t_0(X) = \mathbb{E} [\text{logit} M (D, X) | X],
25+
t_0(X) = \mathbb{E} [\text{logit}(M (D, X)) | X],
2626
2727
a_0(X) = \mathbb{E} [D | X].
2828
@@ -32,14 +32,14 @@ For the estimation of :math:`r_0(X)`, we further need to obtain the following es
3232

3333
.. math::
3434
35-
\psi(W; \beta, \eta) &:= \mathbb E [ \{Y - \text{expit} (\beta_0 D + r_0(X )) \} Z_0 ]
35+
\psi(W; \beta, \eta) := \mathbb E [ \{Y - \text{expit} (\beta_0 D + r_0(X )) \} Z_0 ]
3636
3737
3838
with :math:`Z_0=D-m(X)` and :math:`\eta = { r(\cdot), m(\cdot), \psi(\cdot) }`, where
3939

4040
.. math::
4141
42-
\r_0(X) = t_0(X) - \breve \beta a_0(X),
42+
r_0(X) = t_0(X) - \breve \beta a_0(X),
4343
4444
m_0(X) = \mathbb{E} [D | X].
4545

0 commit comments

Comments
 (0)