Let us say I have a dataset with 2 columns X1 and X2. X1 is dichotomous and has 2 level yes and no. X2 is numeric and is only completed when X1 = yes. Is it possible to keep the numeric column X2 as numeric? Could one impute the median of X2 for X1 = no or some other arbitrary constant? Thanks!
1 Answer
$\begingroup$
$\endgroup$
1
Let $X1 = 1$ if "yes" and $0$ if "no". Then, you can impute the value $X2 = 0$ for the units of observation having $X1=0$, and include in your regression the interaction term $(X1\cdot X2)$ instead of $X2$, so that the effect of $X2$ is conditional on $X1 = 1$.
-
$\begingroup$ guess like an interaction without including X2? Thanks. $\endgroup$– cs0815Commented Aug 6, 2019 at 11:16