cleverly.longitudinal.LearnedRegimen#

class cleverly.longitudinal.LearnedRegimen(label: str = 'learned regimen')[source]#

Declare the two-node regimen whose fold-size-weighted value an LTMLE fit estimates.

Each outer training fold learns its own pair of rules by backward plug-in Q-learning on its training rows: the second-node rule treats where the fold’s outcome regression at the second node predicts a higher outcome under treatment, given the first-node arm, and the first-node rule treats where the first-node regression of that learned value predicts a higher one. A tie assigns the lower arm code. Every row then follows the rule pair of the fold that held it out.

The fit reports one parameter, ey_regimen[<label>], the value of those rules weighted by each fold’s share of the rows. The target depends on the data, because the rules do (van der Laan and Luedtke 2015, Section 7). result.learned_regimen records the rules.

Pass it as LTMLE(regimens=LearnedRegimen()), alone. The fit needs two treatment nodes, each binary, an end-of-study outcome, at least two outer folds and explicit learners. A SuperLearner or a cross-validated selector as the first node’s regression is refused, because its internal risk would read a second-node rule trained on its own validation rows.

Parameters:
labelstr

The label that the reported parameter carries, as in ey_regimen[learned regimen].

Raises:
DataError

If label is not a non-empty string.

See also

cleverly.longitudinal.LTMLE

The estimator that fits it.

cleverly.longitudinal.DynamicRegimen

A regimen of known rules, fixed before the fit.

Examples

>>> from cleverly.longitudinal import LearnedRegimen
>>> LearnedRegimen().label
'learned regimen'

Methods#

LearnedRegimen.is_mtp(time: int) → bool[source]#

Return False: no node holds a modified treatment policy.

Parameters:
timeint

The treatment node, counted from one.

Returns:
bool

False.

LearnedRegimen.is_policy(time: int) → bool[source]#

Return False: no node of a learned regimen draws its arm.

Parameters:
timeint

The treatment node, counted from one.

Returns:
bool

False.

LearnedRegimen.is_rule(time: int) → bool[source]#

Return True: node time holds a rule.

Parameters:
timeint

The treatment node, counted from one.

Returns:
bool

True.

LearnedRegimen.is_tilt(time: int) → bool[source]#

Return False: no node holds an odds tilt.

Parameters:
timeint

The treatment node, counted from one.

Returns:
bool

False.

Attributes#

LearnedRegimen.has_mtp#

Return False: a learned regimen holds no modified treatment policy.

LearnedRegimen.has_policy#

Return False: every node of a learned regimen assigns its arm by a rule.

LearnedRegimen.has_rule#

Return True: every node holds a rule, learned in each training fold.

LearnedRegimen.has_tilt#

Return False: a learned regimen holds no odds tilt.

LearnedRegimen.label: str = 'learned regimen'#
LearnedRegimen.learned: ClassVar[bool] = True#

Read by cleverly._support.regimen_kinds(), which keys the regimen kind learned.