@@ -222,52 +222,26 @@ dml_plr_boot = function(data, y, d, theta, se, all_preds, dml_procedure = "dml2"
222222 D = data [, d ]
223223 Y = data [, y ]
224224
225- # DML 1
226- if (dml_procedure == " dml1" ) {
227- v_hat = u_hat = v_hatd = d_k = matrix (NA , nrow = max(n_k ), ncol = n_iters )
228-
229- for (i in 1 : n_iters ) {
230- test_index = test_ids [[i ]]
231-
232- m_hat = m_hat_list [[i ]]
233- g_hat = g_hat_list [[i ]]
234-
235- d_k [, i ] = D [test_index ]
236- v_hat [, i ] = D [test_index ] - m_hat
237- u_hat [, i ] = Y [test_index ] - g_hat
238- v_hatd [, i ] = v_hat [, i ] * D [test_index ]
239- }
240-
241- boot = bootstrap_plr(
242- theta = theta , d = d_k , u_hat = u_hat , v_hat = v_hat ,
243- v_hatd = v_hatd , score = score , se = se ,
244- weights = weights , nRep = nRep )
245- boot_theta = boot $ boot_theta
225+ v_hat = u_hat = v_hatd = matrix (NA , nrow = n , ncol = 1 )
226+
227+ for (i in 1 : n_iters ) {
228+ test_index = test_ids [[i ]]
229+
230+ m_hat = m_hat_list [[i ]]
231+ g_hat = g_hat_list [[i ]]
232+
233+ v_hat [test_index , 1 ] = D [test_index ] - m_hat
234+ u_hat [test_index , 1 ] = Y [test_index ] - g_hat
235+ v_hatd [test_index , 1 ] = v_hat [test_index ] * D [test_index ]
236+
246237 }
247-
248- if (dml_procedure == " dml2" ) {
249-
250- v_hat = u_hat = v_hatd = matrix (NA , nrow = n , ncol = 1 )
251-
252- for (i in 1 : n_iters ) {
253- test_index = test_ids [[i ]]
254-
255- m_hat = m_hat_list [[i ]]
256- g_hat = g_hat_list [[i ]]
257-
258- v_hat [test_index , 1 ] = D [test_index ] - m_hat
259- u_hat [test_index , 1 ] = Y [test_index ] - g_hat
260- v_hatd [test_index , 1 ] = v_hat [test_index ] * D [test_index ]
261-
262- }
263-
264- boot = bootstrap_plr(
265- theta = theta , d = D , u_hat = u_hat , v_hat = v_hat ,
266- v_hatd = v_hatd , score = score , se = se ,
267- weights = weights , nRep = nRep )
268- boot_theta = boot $ boot_theta
269- }
270-
238+
239+ boot = bootstrap_plr(
240+ theta = theta , d = D , u_hat = u_hat , v_hat = v_hat ,
241+ v_hatd = v_hatd , score = score , se = se ,
242+ weights = weights , nRep = nRep )
243+ boot_theta = boot $ boot_theta
244+
271245 return (boot_theta )
272246}
273247
0 commit comments