@@ -348,8 +348,8 @@ DoubleMLPLIV = R6Class("DoubleMLPLIV",
348348 psi_b = psi_b )
349349 } else if (is.function(self $ score )) {
350350 if (self $ data $ n_instr > 1 ) {
351- stop(" Callable score not implemented for DoubleMLPLIV with
352- partialX=TRUE and partialZ=FALSE with several instruments" )
351+ stop(paste( " Callable score not implemented for DoubleMLPLIV with" ,
352+ " partialX=TRUE and partialZ=FALSE with several instruments. " ) )
353353 }
354354 psis = self $ score(y , z , d , g_hat , m_hat , r_hat , smpls )
355355 }
@@ -415,8 +415,8 @@ DoubleMLPLIV = R6Class("DoubleMLPLIV",
415415 psi_a = psi_a ,
416416 psi_b = psi_b )
417417 } else if (is.function(self $ score )) {
418- stop(" Callable score not implemented for DoubleMLPLIV
419- with partialX=TRUE and partialZ=TRUE." )
418+ stop(paste( " Callable score not implemented for DoubleMLPLIV" ,
419+ " with partialX=TRUE and partialZ=TRUE." ) )
420420 # res = self$score(y, d, g_hat, m_hat, m_hat_tilde)
421421 }
422422 res $ preds = list (
@@ -454,8 +454,8 @@ DoubleMLPLIV = R6Class("DoubleMLPLIV",
454454 }
455455 res = list (psi_a = psi_a , psi_b = psi_b )
456456 } else if (is.function(self $ score )) {
457- stop(" Callable score not implemented for DoubleMLPLIV
458- with partialX=FALSE and partialZ=TRUE." )
457+ stop(paste( " Callable score not implemented for DoubleMLPLIV" ,
458+ " with partialX=FALSE and partialZ=TRUE." ) )
459459 # res = self$score(y, z, d, r_hat)
460460 }
461461 res $ preds = list (" ml_r" = r_hat )
@@ -674,6 +674,13 @@ DoubleMLPLIV = R6Class("DoubleMLPLIV",
674674 return ()
675675 },
676676 check_data = function (obj_dml_data ) {
677+ if (obj_dml_data $ n_instr == 0 ) {
678+ stop(paste(
679+ " Incompatible data.\n " ,
680+ " At least one variable must be set as instrumental variable.\n " ,
681+ " To fit a partially linear regression model without instrumental" ,
682+ " variable(s) use DoubleMLPLR instead of DoubleMLPLIV." ))
683+ }
677684 return ()
678685 }
679686 )
0 commit comments