Skip to content

Misleading warning for multiple treatments #786

Open
@FlorianNachtigall

Description

@FlorianNachtigall

If multiple treatments are specified, a warning is given if a scalar is provided as treatment value for the effect estimation, e.g. est.effect(X=X, T0=0, T1=1).

if (ndim(T) == 0) and self._d_t_in and self._d_t_in[0] > 1:
warn("A scalar was specified but there are multiple treatments; "
"the same value will be used for each treatment. Consider specifying"
"all treatments, or using the const_marginal_effect method.")

However, since this check currently includes the base treatment T0, for which the default is 0, a warning is emitted even if the base treatment is not specified. As a user, this may be misleading because one suspects the provided target treatment T1 to be of undesired shape. (At least for me, it took me quite a while to figure out that the warning was not related to T1.)

Option 1
I would suggest to suppress the warning if the base treatment has the default value (see PR #784).

Option 2
The alternative that would involve less lines of code would be adding a T != 0 check before emitting the warning (see PR #785), i.e.:

if (ndim(T) == 0) and self._d_t_in and self._d_t_in[0] > 1 and T != 0:

Assuming that there are no reasonable cases where the T1 is 0, this should work as well. Yet, I slightly favor the first approach because the second one is highly implicit.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions