G-formula for causal inference via multiple imputation