Skip to content

Commit 1fc52ce

Browse files
committed
z was never assigned; then passed on to score_elements; there never used but always overwritten
1 parent 671a4fd commit 1fc52ce

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

R/double_ml_pliv.R

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ DoubleMLPLIV = R6Class("DoubleMLPLIV",
296296
return_train_preds = FALSE,
297297
task_type = private$task_type$ml_m,
298298
fold_specific_params = private$fold_specific_params)
299+
z = self$data$data_model[[self$data$z_cols]]
299300
} else {
300301
m_hat = do.call(
301302
cbind,
@@ -313,6 +314,7 @@ DoubleMLPLIV = R6Class("DoubleMLPLIV",
313314
task_type = private$task_type$ml_m,
314315
fold_specific_params = private$fold_specific_params)
315316
}))
317+
z = self$data$data_model[, self$data$z_cols, with = FALSE]
316318
}
317319

318320
d = self$data$data_model[[self$data$treat_col]]
@@ -328,12 +330,9 @@ DoubleMLPLIV = R6Class("DoubleMLPLIV",
328330
score_elements = function(y, z, d, g_hat, m_hat, r_hat, smpls) {
329331
u_hat = y - g_hat
330332
w_hat = d - r_hat
333+
v_hat = z - m_hat
331334

332-
if (self$data$n_instr == 1) {
333-
z = self$data$data_model[[self$data$z_cols]]
334-
v_hat = z - m_hat
335-
} else {
336-
z = self$data$data_model[, self$data$z_cols, with = FALSE]
335+
if (self$data$n_instr > 1) {
337336
v_hat = z - m_hat
338337

339338
stopifnot(self$apply_cross_fitting)

0 commit comments

Comments
 (0)