Running ‘test-all.R’ [119s/141s]
Running the tests in ‘tests/test-all.R’ failed.
Complete output:
  > suppressPackageStartupMessages(library("testthat"))
  > options(Ncpus = 2)
  > data.table::setDTthreads(2)
  > test_check("polle")
  Loading required package: polle
  Loading required package: SuperLearner
  Loading required package: nnls
  Loading required package: gam
  Loading required package: splines
  Loading required package: foreach
  Loaded gam 1.22-7
  
  Super Learner
  Version: 2.0-29
  Package created on 2024-02-06
  
  Saving _problems/test-c_cox-92.R
  Saving _problems/test-fit_c_functions-133.R
  Saving _problems/test-fit_c_functions-141.R
  Saving _problems/test-fit_c_functions-146.R
  Saving _problems/test-fit_c_functions-159.R
  Saving _problems/test-fit_c_functions-167.R
  Saving _problems/test-fit_c_functions-172.R
  Saving _problems/test-fit_c_functions-180.R
  Saving _problems/test-fit_c_functions-240.R
  Saving _problems/test-fit_c_functions-257.R
  Saving _problems/test-fit_functions-27.R
  Saving _problems/test-fit_functions-29.R
  Saving _problems/test-fit_functions-63.R
  Saving _problems/test-fit_m_function-44.R
  Saving _problems/test-fit_m_function-181.R
  Saving _problems/test-g_empir-36.R
  Saving _problems/test-g_empir-117.R
  Saving _problems/test-g_models-43.R
  Saving _problems/test-g_models-58.R
  Saving _problems/test-g_models-64.R
  Saving _problems/test-g_models-102.R
  Saving _problems/test-g_models-106.R
  Saving _problems/test-g_models-111.R
  Saving _problems/test-g_models-115.R
  Saving _problems/test-g_models-132.R
  Saving _problems/test-g_models-157.R
  Saving _problems/test-g_models-161.R
  Saving _problems/test-g_models-260.R
  Saving _problems/test-g_models-262.R
  Saving _problems/test-g_models-286.R
  Saving _problems/test-g_models-365.R
  Saving _problems/test-g_models-394.R
  Saving _problems/test-g_models-402.R
  Saving _problems/test-g_models-409.R
  Saving _problems/test-g_models-453.R
  Saving _problems/test-g_models-460.R
  Saving _problems/test-g_xgboost-27.R
  Saving _problems/test-policy_data-functions-24.R
  Saving _problems/test-policy_data-functions-49.R
  Saving _problems/test-policy_data-functions-49.R
  Saving _problems/test-policy_data-functions-86.R
  Saving _problems/test-policy_data-functions-177.R
  Saving _problems/test-policy_data-functions-331.R
  Saving _problems/test-policy_data-functions-483.R
  Saving _problems/test-policy_data-functions-573.R
  Saving _problems/test-policy_data-functions-722.R
  Saving _problems/test-policy_data-functions-1211.R
  Saving _problems/test-policy_data-functions-1268.R
  Saving _problems/test-policy_def-14.R
  Saving _problems/test-policy_def-42.R
  Saving _problems/test-policy_def-122.R
  Saving _problems/test-policy_def-171.R
  Saving _problems/test-policy_def-240.R
  Saving _problems/test-policy_def-311.R
  Saving _problems/test-policy_eval-censoring-132.R
  Saving _problems/test-policy_eval-censoring-244.R
  Saving _problems/test-policy_eval-censoring-684.R
  Saving _problems/test-policy_eval-censoring-723.R
  Saving _problems/test-policy_eval-censoring-1062.R
  Saving _problems/test-policy_eval-censoring-1139.R
  Saving _problems/test-policy_eval-censoring-1288.R
  Saving _problems/test-policy_eval-subgroup-27.R
  Saving _problems/test-policy_eval-subgroup-46.R
  Saving _problems/test-policy_eval-subgroup-71.R
  Saving _problems/test-policy_eval-subgroup-191.R
  Saving _problems/test-policy_eval-subgroup-140.R
  Saving _problems/test-policy_eval-subgroup-289.R
  Saving _problems/test-policy_eval-subgroup-366.R
  Saving _problems/test-policy_eval-subgroup-483.R
  Saving _problems/test-policy_eval-subgroup-639.R
  Saving _problems/test-policy_eval-subgroup-735.R
  Saving _problems/test-policy_eval-6.R
  Saving _problems/test-policy_eval-52.R
  Saving _problems/test-policy_eval-156.R
  Saving _problems/test-policy_eval-164.R
  Saving _problems/test-policy_eval-175.R
  Saving _problems/test-policy_eval-278.R
  Saving _problems/test-policy_eval-283.R
  Saving _problems/test-policy_eval-354.R
  Saving _problems/test-policy_eval-363.R
  Saving _problems/test-policy_eval-367.R
  Saving _problems/test-policy_eval-416.R
  Saving _problems/test-policy_eval-428.R
  Saving _problems/test-policy_eval-445.R
  Saving _problems/test-policy_eval-449.R
  Saving _problems/test-policy_eval-523.R
  Saving _problems/test-policy_eval-569.R
  Saving _problems/test-policy_eval-713.R
  Saving _problems/test-policy_eval-714.R
  Saving _problems/test-policy_eval-791.R
  Saving _problems/test-policy_eval-865.R
  Saving _problems/test-policy_eval-917.R
  Saving _problems/test-policy_eval-1081.R
  Saving _problems/test-policy_eval-1085.R
  Saving _problems/test-policy_eval-1231.R
  Saving _problems/test-policy_eval-1300.R
  Saving _problems/test-policy_eval-1305.R
  Saving _problems/test-policy_eval-1387.R
  Saving _problems/test-policy_eval-1395.R
  Saving _problems/test-policy_eval_online-27.R
  Saving _problems/test-policy_eval_online-78.R
  Saving _problems/test-policy_eval_online-236.R
  Saving _problems/test-policy_g_functions-16.R
  Saving _problems/test-policy_learn-blip-censoring-37.R
  Saving _problems/test-policy_learn-blip-21.R
  Saving _problems/test-policy_learn-blip-92.R
  Saving _problems/test-policy_learn-blip-169.R
  Saving _problems/test-policy_learn-blip-235.R
  Saving _problems/test-policy_learn-blip-275.R
  Saving _problems/test-policy_learn-blip-309.R
  Saving _problems/test-policy_learn-blip-370.R
  Saving _problems/test-policy_learn-blip-410.R
  Saving _problems/test-policy_learn-blip-458.R
  Saving _problems/test-policy_learn-blip-513.R
  Saving _problems/test-policy_learn-blip-576.R
  Saving _problems/test-policy_learn-blip-758.R
  Saving _problems/test-policy_learn-drql-15.R
  Saving _problems/test-policy_learn-drql-18.R
  Saving _problems/test-policy_learn-drql-54.R
  Saving _problems/test-policy_learn-drql-99.R
  Saving _problems/test-policy_learn-drql-192.R
  Saving _problems/test-policy_learn-drql-196.R
  Saving _problems/test-policy_learn-drql-201.R
  Saving _problems/test-policy_learn-drql-202.R
  Saving _problems/test-policy_learn-drql-364.R
  Saving _problems/test-policy_learn-drql-404.R
  Saving _problems/test-policy_learn-drql-461.R
  Saving _problems/test-policy_learn-owl-26.R
  Saving _problems/test-policy_learn-owl-70.R
  Saving _problems/test-policy_learn-owl-137.R
  Saving _problems/test-policy_learn-ptl-13.R
  Saving _problems/test-policy_learn-ptl-17.R
  Saving _problems/test-policy_learn-ptl-54.R
  Saving _problems/test-policy_learn-ptl-59.R
  Saving _problems/test-policy_learn-ptl-113.R
  Saving _problems/test-policy_learn-ptl-117.R
  Saving _problems/test-policy_learn-ptl-125.R
  Saving _problems/test-policy_learn-ptl-150.R
  Saving _problems/test-policy_learn-ptl-154.R
  Saving _problems/test-policy_learn-ptl-161.R
  Saving _problems/test-policy_learn-ptl-166.R
  Saving _problems/test-policy_learn-ptl-167.R
  Saving _problems/test-policy_learn-ptl-214.R
  Saving _problems/test-policy_learn-ptl-218.R
  Saving _problems/test-policy_learn-ptl-223.R
  Saving _problems/test-policy_learn-ptl-228.R
  Saving _problems/test-policy_learn-ptl-232.R
  Saving _problems/test-policy_learn-ptl-237.R
  Saving _problems/test-policy_learn-ptl-263.R
  Saving _problems/test-policy_learn-ql-15.R
  Saving _problems/test-policy_learn-ql-18.R
  Saving _problems/test-policy_learn-ql-36.R
  Saving _problems/test-policy_learn-ql-113.R
  Saving _problems/test-policy_learn-ql-186.R
  Saving _problems/test-policy_learn-ql-255.R
  Saving _problems/test-policy_learn-ql-327.R
  Saving _problems/test-policy_learn-ql-372.R
  Saving _problems/test-policy_learn-ql-376.R
  Saving _problems/test-policy_learn-ql-389.R
  Saving _problems/test-policy_learn-ql-393.R
  Saving _problems/test-policy_learn-ql-395.R
  Saving _problems/test-policy_learn-ql-415.R
  Saving _problems/test-policy_learn-ql-419.R
  Saving _problems/test-policy_learn-ql-426.R
  Saving _problems/test-policy_learn-44.R
  Saving _problems/test-policy_learn-50.R
  Saving _problems/test-policy_learn-58.R
  Saving _problems/test-policy_learn-64.R
  Saving _problems/test-policy_learn-303.R
  Saving _problems/test-policy_learn-314.R
  Saving _problems/test-policy_learn-325.R
  Saving _problems/test-policy_learn-336.R
  Saving _problems/test-policy_learn-347.R
  Saving _problems/test-policy_learn-358.R
  Saving _problems/test-q_glmnet-9.R
  Saving _problems/test-q_glmnet-40.R
  Saving _problems/test-q_glmnet-78.R
  Saving _problems/test-q_glmnet-87.R
  Saving _problems/test-q_glmnet-160.R
  Saving _problems/test-q_models-21.R
  Saving _problems/test-q_models-25.R
  Saving _problems/test-q_models-28.R
  Saving _problems/test-q_models-58.R
  Saving _problems/test-q_models-61.R
  Saving _problems/test-q_models-67.R
  Saving _problems/test-q_models-87.R
  Saving _problems/test-q_models-99.R
  Saving _problems/test-q_models-120.R
  Saving _problems/test-q_models-140.R
  Saving _problems/test-q_models-179.R
  Saving _problems/test-q_models-208.R
  Saving _problems/test-q_models-247.R
  Saving _problems/test-q_models-254.R
  Saving _problems/test-q_sl-15.R
  Saving _problems/test-q_xgboost-15.R
  Saving _problems/test-q_xgboost-54.R
  [ FAIL 196 | WARN 8 | SKIP 0 | PASS 220 ]
  
  ══ Failed tests ════════════════════════════════════════════════════════════════
  ── Error ('test-c_cox.R:92:3'): c_cox returns the expected output ──────────────
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 12/12 in VECTOR_ELT
  Backtrace:
      ▆
   1. ├─polle::get_history(pd, event_set = c(0, 1, 2), stage = 2) at test-c_cox.R:92:3
   2. └─polle:::get_history.policy_data(pd, event_set = c(0, 1, 2), stage = 2)
   3.   └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   4.     ├─...[]
   5.     └─data.table:::`[.data.table`(...)
  ── Failure ('test-fit_c_functions.R:123:3'): fit_c_functions return the expected output ──
  `... <- NULL` threw an error.
  Message: attempt access index 12/12 in VECTOR_ELT
  Class:   simpleError/error/condition
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-fit_c_functions.R:123:3
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat (local) .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─polle::fit_c_functions(...)
    7.   └─base::lapply(...)
    8.     └─polle (local) FUN(X[[i]], ...)
    9.       ├─polle::get_history(...)
   10.       └─polle:::get_history.policy_data(...)
   11.         └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   12.           ├─...[]
   13.           └─data.table:::`[.data.table`(...)
  ── Failure ('test-fit_c_functions.R:138:3'): fit_c_functions return the expected output ──
  Expected `coef(ref_model1)` to equal `coef(fcf$stage_1$c_model$model)`.
  Differences:
  Types not compatible: double is not NULL
  ── Failure ('test-fit_c_functions.R:143:3'): fit_c_functions return the expected output ──
  Expected `coef(ref_model2)` to equal `coef(fcf$stage_2$c_model$model)`.
  Differences:
  Types not compatible: double is not NULL
  ── Failure ('test-fit_c_functions.R:149:3'): fit_c_functions return the expected output ──
  `... <- NULL` threw an error.
  Message: attempt access index 12/12 in VECTOR_ELT
  Class:   simpleError/error/condition
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-fit_c_functions.R:149:3
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat (local) .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─polle::fit_c_functions(...)
    7.   └─base::lapply(...)
    8.     └─polle (local) FUN(X[[i]], ...)
    9.       ├─polle::get_history(...)
   10.       └─polle:::get_history.policy_data(...)
   11.         └─polle:::full_history(object, stage = stage, event_set = event_set)
   12.           ├─...[]
   13.           └─data.table:::`[.data.table`(...)
  ── Failure ('test-fit_c_functions.R:164:3'): fit_c_functions return the expected output ──
  Expected `unname(coef(ref_model1))` to equal `unname(coef(fcf$stage_1$c_model$model))`.
  Differences:
  Types not compatible: double is not NULL
  ── Failure ('test-fit_c_functions.R:169:3'): fit_c_functions return the expected output ──
  Expected `unname(coef(ref_model2))` to equal `unname(coef(fcf$stage_2$c_model$model))`.
  Differences:
  Types not compatible: double is not NULL
  ── Error ('test-fit_c_functions.R:180:3'): fit_c_functions(): g_model's passed as the argument c_models are fitted and predicted correctly for discrete right-censoring: ──
  Error in ``[.data.table`(ld, , `:=`(tmp, cumsum(delta == 0)), by = id)`: attempt access index 12/12 in VECTOR_ELT
  Backtrace:
      ▆
   1. └─polle (local) sim_two_stage_right_cens(n = 500) at test-fit_c_functions.R:180:3
   2.   ├─ld[, `:=`(tmp, cumsum(delta == 0)), by = id] at test-fit_c_functions.R:87:3
   3.   └─data.table:::`[.data.table`(...) at test-fit_c_functions.R:87:3
  ── Error ('test-fit_c_functions.R:240:3'): fit_c_functions() related errors to fitting the c-model. ──
  Error in ``[.data.table`(ld, , `:=`(tmp, cumsum(delta == 0)), by = id)`: attempt access index 12/12 in VECTOR_ELT
  Backtrace:
      ▆
   1. └─polle (local) sim_two_stage_right_cens(n = 500) at test-fit_c_functions.R:240:3
   2.   ├─ld[, `:=`(tmp, cumsum(delta == 0)), by = id] at test-fit_c_functions.R:87:3
   3.   └─data.table:::`[.data.table`(...) at test-fit_c_functions.R:87:3
  ── Error ('test-fit_c_functions.R:257:3'): fit_c_functions(): returns default right-censoring model for stages where no right-censoring occur, ──
  Error in ``[.data.table`(ld, , `:=`(tmp, cumsum(delta == 0)), by = id)`: attempt access index 12/12 in VECTOR_ELT
  Backtrace:
      ▆
   1. └─polle (local) sim_two_stage_right_cens(...) at test-fit_c_functions.R:257:3
   2.   ├─ld[, `:=`(tmp, cumsum(delta == 0)), by = id] at test-fit_c_functions.R:87:3
   3.   └─data.table:::`[.data.table`(...) at test-fit_c_functions.R:87:3
  ── Failure ('test-fit_functions.R:15:5'): fit_functions handle multiple thresholds ──
  Expected `... <- NULL` not to throw any errors.
  Actually got a <simpleError> with message:
    attempt access index 12/12 in VECTOR_ELT
  ── Error ('test-fit_functions.R:29:5'): fit_functions handle multiple thresholds ──
  Error in `eval(code, test_env)`: object 'ff' not found
  Backtrace:
      ▆
   1. └─testthat::expect_is(ff$policy_object, class = "policy_object") at test-fit_functions.R:29:5
   2.   └─testthat::quasi_label(enquo(object), label)
   3.     └─rlang::eval_bare(expr, quo_get_env(quo))
  ── Error ('test-fit_functions.R:63:5'): crossfit_functions has the expected outcome ──
  Error in ``[.data.table`(ld, , `:=`(tmp, cumsum(delta == 0)), by = id)`: attempt access index 12/12 in VECTOR_ELT
  Backtrace:
      ▆
   1. └─polle (local) sim_two_stage_right_cens(n = 100) at test-fit_functions.R:75:3
   2.   ├─ld[, `:=`(tmp, cumsum(delta == 0)), by = id] at test-fit_functions.R:63:5
   3.   └─data.table:::`[.data.table`(...) at test-fit_functions.R:63:5
  ── Error ('test-fit_m_function.R:44:3'): fit_m_function has the expected output. ──
  Error in ``[.data.table`(ld, , `:=`(tmp, cumsum(delta == 0)), by = id)`: attempt access index 14/14 in VECTOR_ELT
  Backtrace:
      ▆
   1. ├─ld[, `:=`(tmp, cumsum(delta == 0)), by = id] at test-fit_m_function.R:44:3
   2. └─data.table:::`[.data.table`(...) at test-fit_m_function.R:44:3
  ── Error ('test-fit_m_function.R:181:3'): fit_m_function handles missing covariates (throws and error message that is related to the m-model) ──
  Error in ``[.data.table`(ld, , `:=`(tmp, cumsum(delta == 0)), by = id)`: attempt access index 14/14 in VECTOR_ELT
  Backtrace:
      ▆
   1. ├─ld[, `:=`(tmp, cumsum(delta == 0)), by = id] at test-fit_m_function.R:181:3
   2. └─data.table:::`[.data.table`(...) at test-fit_m_function.R:181:3
  ── Error ('test-g_empir.R:36:3'): g_empir predictions in a single stage setting ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 14/14 in VECTOR_ELT
  Backtrace:
      ▆
   1. ├─stats::predict(g_functions, new_policy_data = pd) at test-g_empir.R:36:3
   2. └─polle:::predict.nuisance_functions(g_functions, new_policy_data = pd)
   3.   └─base::lapply(...)
   4.     └─polle (local) FUN(X[[i]], ...)
   5.       ├─polle::get_history(...)
   6.       └─polle:::get_history.policy_data(...)
   7.         └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   8.           ├─...[]
   9.           └─data.table:::`[.data.table`(...)
  ── Error ('test-g_empir.R:115:3'): g_empir predictions in a two stage setting ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 12/12 in VECTOR_ELT
  Backtrace:
      ▆
   1. └─polle::fit_g_functions(...) at test-g_empir.R:115:3
   2.   └─base::lapply(...)
   3.     └─polle (local) FUN(X[[i]], ...)
   4.       ├─polle::get_history(policy_data, stage = s, full_history = full_history)
   5.       └─polle:::get_history.policy_data(policy_data, stage = s, full_history = full_history)
   6.         └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   7.           ├─...[]
   8.           └─data.table:::`[.data.table`(...)
  ── Failure ('test-g_models.R:40:3'): predict.g_functions checks the action set ──
  `... <- NULL` threw an error.
  Message: attempt access index 12/12 in VECTOR_ELT
  Class:   simpleError/error/condition
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-g_models.R:40:3
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat (local) .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─polle::fit_g_functions(...)
    7.   └─base::lapply(...)
    8.     └─polle (local) FUN(X[[i]], ...)
    9.       ├─polle::get_history(policy_data, stage = s, full_history = full_history)
   10.       └─polle:::get_history.policy_data(policy_data, stage = s, full_history = full_history)
   11.         └─polle:::full_history(object, stage = stage, event_set = event_set)
   12.           ├─...[]
   13.           └─data.table:::`[.data.table`(...)
  ── Failure ('test-g_models.R:55:3'): predict.g_functions checks the action set ──
  `predict(gfit, pd2)` threw an error with unexpected message.
  Expected match: "factor A_1 has new levels maybe"
  Actual message: "object 'gfit' not found"
  Backtrace:
      ▆
   1. ├─testthat::expect_error(predict(gfit, pd2), "factor A_1 has new levels maybe") at test-g_models.R:55:3
   2. │ └─testthat:::quasi_capture(...)
   3. │   ├─testthat (local) .capture(...)
   4. │   │ └─base::withCallingHandlers(...)
   5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
   6. └─stats::predict(gfit, pd2)
  ── Error ('test-g_models.R:62:7'): predict.g_functions checks the action set ───
  Error in `eval(code, test_env)`: object 'gfit' not found
  Backtrace:
      ▆
   1. ├─testthat::expect_equal(...) at test-g_models.R:60:3
   2. │ └─testthat::quasi_label(enquo(object), label)
   3. │   └─rlang::eval_bare(expr, quo_get_env(quo))
   4. └─polle:::predict.g_function(...) at test-g_models.R:62:7
   5.   └─base::getElement(object, "g_model")
  ── Failure ('test-g_models.R:99:3'): fit_g_functions handles varying stage-action sets ──
  `... <- NULL` threw an error.
  Message: attempt access index 12/12 in VECTOR_ELT
  Class:   simpleError/error/condition
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-g_models.R:99:3
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat (local) .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─polle::fit_g_functions(...)
    7.   └─base::lapply(...)
    8.     └─polle (local) FUN(X[[i]], ...)
    9.       ├─polle::get_history(policy_data, stage = s, full_history = full_history)
   10.       └─polle:::get_history.policy_data(policy_data, stage = s, full_history = full_history)
   11.         └─polle:::full_history(object, stage = stage, event_set = event_set)
   12.           ├─...[]
   13.           └─data.table:::`[.data.table`(...)
  ── Failure ('test-g_models.R:103:3'): fit_g_functions handles varying stage-action sets ──
  `predict(gfit, pd)` threw an error.
  Message: object 'gfit' not found
  Class:   simpleError/error/condition
  Backtrace:
      ▆
   1. ├─testthat::expect_error(predict(gfit, pd), NA) at test-g_models.R:103:3
   2. │ └─testthat:::quasi_capture(...)
   3. │   ├─testthat (local) .capture(...)
   4. │   │ └─base::withCallingHandlers(...)
   5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
   6. └─stats::predict(gfit, pd)
  ── Failure ('test-g_models.R:108:3'): fit_g_functions handles varying stage-action sets ──
  `... <- NULL` threw an error.
  Message: attempt access index 12/12 in VECTOR_ELT
  Class:   simpleError/error/condition
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-g_models.R:108:3
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat (local) .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─polle::fit_g_functions(...)
    7.   └─base::lapply(...)
    8.     └─polle (local) FUN(X[[i]], ...)
    9.       ├─polle::get_history(policy_data, stage = s, full_history = full_history)
   10.       └─polle:::get_history.policy_data(policy_data, stage = s, full_history = full_history)
   11.         └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   12.           ├─...[]
   13.           └─data.table:::`[.data.table`(...)
  ── Failure ('test-g_models.R:112:3'): fit_g_functions handles varying stage-action sets ──
  `predict(gfit, pd)` threw an error.
  Message: object 'gfit' not found
  Class:   simpleError/error/condition
  Backtrace:
      ▆
   1. ├─testthat::expect_error(predict(gfit, pd), NA) at test-g_models.R:112:3
   2. │ └─testthat:::quasi_capture(...)
   3. │   ├─testthat (local) .capture(...)
   4. │   │ └─base::withCallingHandlers(...)
   5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
   6. └─stats::predict(gfit, pd)
  ── Failure ('test-g_models.R:124:3'): fit_g_functions handles varying stage-action sets ──
  `... <- NULL` threw an error.
  Message: attempt access index 12/12 in VECTOR_ELT
  Class:   simpleError/error/condition
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-g_models.R:124:3
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat (local) .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─polle:::crossfit_function(...)
    7.   ├─base::do.call(what = future.apply::future_lapply, future_args)
    8.   └─future.apply (local) `<fn>`(future.seed = TRUE, X = `<list>`, FUN = `<fn>`)
    9.     └─future.apply:::future_xapply(...)
   10.       └─base::tryCatch(...)
   11.         └─base (local) tryCatchList(expr, classes, parentenv, handlers)
   12.           └─base (local) tryCatchOne(...)
   13.             └─value[[3L]](cond)
   14.               └─future.apply:::onError(e, futures = fs, debug = debug)
  ── Failure ('test-g_models.R:149:3'): fit_g_function_cf saves the cross-fitted models ──
  `... <- NULL` threw an error.
  Message: attempt access index 12/12 in VECTOR_ELT
  Class:   simpleError/error/condition
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-g_models.R:149:3
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat (local) .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─polle:::crossfit_function(...)
    7.   ├─base::do.call(what = future.apply::future_lapply, future_args)
    8.   └─future.apply (local) `<fn>`(future.seed = TRUE, X = `<list>`, FUN = `<fn>`)
    9.     └─future.apply:::future_xapply(...)
   10.       └─base::tryCatch(...)
   11.         └─base (local) tryCatchList(expr, classes, parentenv, handlers)
   12.           └─base (local) tryCatchOne(...)
   13.             └─value[[3L]](cond)
   14.               └─future.apply:::onError(e, futures = fs, debug = debug)
  ── Error ('test-g_models.R:159:3'): fit_g_function_cf saves the cross-fitted models ──
  Error in `eval(code, test_env)`: object 'gfit' not found
  Backtrace:
      ▆
   1. ├─testthat::expect_true(all(!unlist(lapply(gfit$functions, is.null)))) at test-g_models.R:159:3
   2. │ └─testthat::quasi_label(enquo(object), label)
   3. │   └─rlang::eval_bare(expr, quo_get_env(quo))
   4. ├─base::unlist(lapply(gfit$functions, is.null))
   5. └─base::lapply(gfit$functions, is.null)
  ── Failure ('test-g_models.R:252:3'): g_rf runs: ───────────────────────────────
  Expected `... <- NULL` not to throw any errors.
  Actually got a <simpleError> with message:
    attempt access index 13/13 in VECTOR_ELT
  ── Error ('test-g_models.R:262:3'): g_rf runs: ─────────────────────────────────
  Error in `eval(code, test_env)`: object 'pe' not found
  Backtrace:
      ▆
   1. └─testthat::expect_is(pe, class = "policy_eval") at test-g_models.R:262:3
   2.   └─testthat::quasi_label(enquo(object), label)
   3.     └─rlang::eval_bare(expr, quo_get_env(quo))
  ── Failure ('test-g_models.R:277:3'): g_sl formats data correctly via the formula ──
  `policy_eval(...)` threw an error.
  Message: attempt access index 13/13 in VECTOR_ELT
  Class:   simpleError/error/condition
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-g_models.R:277:3
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat (local) .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─polle::policy_eval(...)
    7.   ├─base::do.call(what = policy_eval_type, args = args)
    8.   └─polle (local) `<fn>`(...)
    9.     └─polle:::fit_functions(...)
   10.       └─polle::policy_learn(...)
   11.         ├─base::do.call(what = call, args)
   12.         └─polle:::rql(...)
   13.           ├─stats::predict(g_functions, policy_data)
   14.           └─polle:::predict.nuisance_functions(g_functions, policy_data)
   15.             └─base::lapply(...)
   16.               └─polle (local) FUN(X[[i]], ...)
   17.                 ├─polle::get_history(...)
   18.                 └─polle:::get_history.policy_data(...)
   19.                   └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   20.                     ├─...[]
   21.                     └─data.table:::`[.data.table`(...)
  ── Failure ('test-g_models.R:356:3'): g_glmnet formats data correctly via the formula ──
  `... <- NULL` threw an error.
  Message: attempt access index 13/13 in VECTOR_ELT
  Class:   simpleError/error/condition
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-g_models.R:356:3
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat (local) .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─polle::policy_eval(...)
    7.   ├─base::do.call(what = policy_eval_type, args = args)
    8.   └─polle (local) `<fn>`(...)
    9.     └─polle:::fit_functions(...)
   10.       └─polle::policy_learn(...)
   11.         ├─base::do.call(what = call, args)
   12.         └─polle:::rql(...)
   13.           ├─stats::predict(g_functions, policy_data)
   14.           └─polle:::predict.nuisance_functions(g_functions, policy_data)
   15.             └─base::lapply(...)
   16.               └─polle (local) FUN(X[[i]], ...)
   17.                 ├─polle::get_history(...)
   18.                 └─polle:::get_history.policy_data(...)
   19.                   └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   20.                     ├─...[]
   21.                     └─data.table:::`[.data.table`(...)
  ── Failure ('test-g_models.R:388:3'): g_glm handles missing covariates ─────────
  `policy_eval(...)` threw an error with unexpected message.
  Expected match: "NA/NaN/Inf in 'x'"
  Actual message: "attempt access index 11/11 in VECTOR_ELT"
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-g_models.R:388:3
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat (local) .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─polle::policy_eval(...)
    7.   ├─base::do.call(what = policy_eval_type, args = args)
    8.   └─polle (local) `<fn>`(...)
    9.     └─polle:::fit_functions(...)
   10.       └─polle::fit_g_functions(policy_data, g_models = g_models, full_history = g_full_history)
   11.         └─base::lapply(...)
   12.           └─polle (local) FUN(X[[i]], ...)
   13.             ├─polle::get_history(policy_data, stage = s, full_history = full_history)
   14.             └─polle:::get_history.policy_data(policy_data, stage = s, full_history = full_history)
   15.               └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   16.                 ├─...[]
   17.                 └─data.table:::`[.data.table`(...)
  ── Failure ('test-g_models.R:396:3'): g_glm handles missing covariates ─────────
  `policy_eval(...)` threw an error.
  Message: attempt access index 11/11 in VECTOR_ELT
  Class:   simpleError/error/condition
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-g_models.R:396:3
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat (local) .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─polle::policy_eval(...)
    7.   ├─base::do.call(what = policy_eval_type, args = args)
    8.   └─polle (local) `<fn>`(...)
    9.     └─polle:::fit_functions(...)
   10.       └─polle (local) policy(policy_data = policy_data)
   11.         └─base::lapply(...)
   12.           └─polle (local) FUN(X[[i]], ...)
   13.             ├─polle::get_history(...)
   14.             └─polle:::get_history.policy_data(...)
   15.               └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   16.                 ├─...[]
   17.                 └─data.table:::`[.data.table`(...)
  ── Failure ('test-g_models.R:403:3'): g_glm handles missing covariates ─────────
  `... <- NULL` threw an error.
  Message: attempt access index 11/11 in VECTOR_ELT
  Class:   simpleError/error/condition
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-g_models.R:403:3
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat (local) .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─polle::policy_eval(...)
    7.   ├─base::do.call(what = policy_eval_type, args = args)
    8.   └─polle (local) `<fn>`(...)
    9.     └─polle:::fit_functions(...)
   10.       └─polle::fit_g_functions(policy_data, g_models = g_models, full_history = g_full_history)
   11.         └─base::lapply(...)
   12.           └─polle (local) FUN(X[[i]], ...)
   13.             ├─polle::get_history(policy_data, stage = s, full_history = full_history)
   14.             └─polle:::get_history.policy_data(policy_data, stage = s, full_history = full_history)
   15.               └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   16.                 ├─...[]
   17.                 └─data.table:::`[.data.table`(...)
  ── Failure ('test-g_models.R:447:3'): g_glmnet handles missing covariates ──────
  `policy_eval(...)` threw an error.
  Message: attempt access index 11/11 in VECTOR_ELT
  Class:   simpleError/error/condition
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-g_models.R:447:3
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat (local) .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─polle::policy_eval(...)
    7.   ├─base::do.call(what = policy_eval_type, args = args)
    8.   └─polle (local) `<fn>`(...)
    9.     └─polle:::fit_functions(...)
   10.       └─polle (local) policy(policy_data = policy_data)
   11.         └─base::lapply(...)
   12.           └─polle (local) FUN(X[[i]], ...)
   13.             ├─polle::get_history(...)
   14.             └─polle:::get_history.policy_data(...)
   15.               └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   16.                 ├─...[]
   17.                 └─data.table:::`[.data.table`(...)
  ── Failure ('test-g_models.R:454:3'): g_glmnet handles missing covariates ──────
  `policy_eval(...)` threw an error.
  Message: attempt access index 11/11 in VECTOR_ELT
  Class:   simpleError/error/condition
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-g_models.R:454:3
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat (local) .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─polle::policy_eval(...)
    7.   ├─base::do.call(what = policy_eval_type, args = args)
    8.   └─polle (local) `<fn>`(...)
    9.     └─polle:::fit_functions(...)
   10.       └─polle::fit_g_functions(policy_data, g_models = g_models, full_history = g_full_history)
   11.         └─base::lapply(...)
   12.           └─polle (local) FUN(X[[i]], ...)
   13.             ├─polle::get_history(policy_data, stage = s, full_history = full_history)
   14.             └─polle:::get_history.policy_data(policy_data, stage = s, full_history = full_history)
   15.               └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   16.                 ├─...[]
   17.                 └─data.table:::`[.data.table`(...)
  ── Error ('test-g_xgboost.R:27:3'): g_xgboost gives the same result as plain xgboost ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 12/12 in VECTOR_ELT
  Backtrace:
      ▆
   1. ├─stats::predict(g_fun, pd) at test-g_xgboost.R:27:3
   2. └─polle:::predict.nuisance_functions(g_fun, pd)
   3.   └─base::lapply(...)
   4.     └─polle (local) FUN(X[[i]], ...)
   5.       ├─polle::get_history(...)
   6.       └─polle:::get_history.policy_data(...)
   7.         └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   8.           ├─...[]
   9.           └─data.table:::`[.data.table`(...)
  ── Failure ('test-policy_data-functions.R:20:5'): get_history() checks input ───
  `get_history(pd, stage = ss)` threw an error.
  Message: attempt access index 12/12 in VECTOR_ELT
  Class:   simpleError/error/condition
  Backtrace:
       ▆
    1. └─base::lapply(...) at test-policy_data-functions.R:19:3
    2.   └─polle (local) FUN(X[[i]], ...)
    3.     ├─testthat::expect_error(get_history(pd, stage = ss), NA) at test-policy_data-functions.R:20:5
    4.     │ └─testthat:::quasi_capture(...)
    5.     │   ├─testthat (local) .capture(...)
    6.     │   │ └─base::withCallingHandlers(...)
    7.     │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    8.     ├─polle::get_history(pd, stage = ss)
    9.     └─polle:::get_history.policy_data(pd, stage = ss)
   10.       └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   11.         ├─...[]
   12.         └─data.table:::`[.data.table`(...)
  ── Failure ('test-policy_data-functions.R:44:5'): get_history() checks input ───
  `get_history(pd, stage = 1, full_history = fh)` threw an error.
  Message: attempt access index 12/12 in VECTOR_ELT
  Class:   simpleError/error/condition
  Backtrace:
       ▆
    1. └─base::lapply(...) at test-policy_data-functions.R:43:3
    2.   └─polle (local) FUN(X[[i]], ...)
    3.     ├─testthat::expect_error(...) at test-policy_data-functions.R:44:5
    4.     │ └─testthat:::quasi_capture(...)
    5.     │   ├─testthat (local) .capture(...)
    6.     │   │ └─base::withCallingHandlers(...)
    7.     │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    8.     ├─polle::get_history(pd, stage = 1, full_history = fh)
    9.     └─polle:::get_history.policy_data(pd, stage = 1, full_history = fh)
   10.       └─polle:::full_history(object, stage = stage, event_set = event_set)
   11.         ├─...[]
   12.         └─data.table:::`[.data.table`(...)
  ── Failure ('test-policy_data-functions.R:44:5'): get_history() checks input ───
  `get_history(pd, stage = 1, full_history = fh)` threw an error.
  Message: attempt access index 12/12 in VECTOR_ELT
  Class:   simpleError/error/condition
  Backtrace:
       ▆
    1. └─base::lapply(...) at test-policy_data-functions.R:43:3
    2.   └─polle (local) FUN(X[[i]], ...)
    3.     ├─testthat::expect_error(...) at test-policy_data-functions.R:44:5
    4.     │ └─testthat:::quasi_capture(...)
    5.     │   ├─testthat (local) .capture(...)
    6.     │   │ └─base::withCallingHandlers(...)
    7.     │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    8.     ├─polle::get_history(pd, stage = 1, full_history = fh)
    9.     └─polle:::get_history.policy_data(pd, stage = 1, full_history = fh)
   10.       └─polle:::full_history(object, stage = stage, event_set = event_set)
   11.         ├─...[]
   12.         └─data.table:::`[.data.table`(...)
  ── Error ('test-policy_data-functions.R:86:3'): full_history() returns the history associated with the action process when event_set = c(0). ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), id)`: attempt access index 12/12 in VECTOR_ELT
  Backtrace:
      ▆
   1. └─polle:::full_history(pd, stage = 1, event_set = c(0)) at test-policy_data-functions.R:86:3
   2.   ├─...[]
   3.   └─data.table:::`[.data.table`(...)
  ── Error ('test-policy_data-functions.R:177:3'): full_history() returns the history associated with the event process when event_set = c(0,2). ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), id)`: attempt access index 12/12 in VECTOR_ELT
  Backtrace:
      ▆
   1. └─polle:::full_history(pd, stage = 1, event_set = c(0, 2)) at test-policy_data-functions.R:177:3
   2.   ├─...[]
   3.   └─data.table:::`[.data.table`(...)
  ── Error ('test-policy_data-functions.R:331:3'): full_history() returns the history associated with the event process when event_set = c(0,1,2) ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), id)`: attempt access index 12/12 in VECTOR_ELT
  Backtrace:
      ▆
   1. └─polle:::full_history(pd, stage = 1, event_set = c(0, 1, 2)) at test-policy_data-functions.R:331:3
   2.   ├─...[]
   3.   └─data.table:::`[.data.table`(...)
  ── Error ('test-policy_data-functions.R:483:3'): stage_state_history() returns the history associated with the action process when event_set = c(0) ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 12/12 in VECTOR_ELT
  Backtrace:
      ▆
   1. └─polle:::stage_state_history(pd, stage = 1, event_set = c(0)) at test-policy_data-functions.R:483:3
   2.   ├─...[]
   3.   └─data.table:::`[.data.table`(...)
  ── Error ('test-policy_data-functions.R:573:3'): stage_state_history() returns the history associated with the event process when event_set = c(0,2) ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 12/12 in VECTOR_ELT
  Backtrace:
      ▆
   1. └─polle:::stage_state_history(pd, stage = 1, event_set = c(0, 2)) at test-policy_data-functions.R:573:3
   2.   ├─...[]
   3.   └─data.table:::`[.data.table`(...)
  ── Error ('test-policy_data-functions.R:722:3'): stage_state_history() returns the history associated with the event process when event_set = c(0,1,2) ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 12/12 in VECTOR_ELT
  Backtrace:
      ▆
   1. └─polle:::stage_state_history(...) at test-policy_data-functions.R:722:3
   2.   ├─...[]
   3.   └─data.table:::`[.data.table`(...)
  ── Error ('test-policy_data-functions.R:1211:5'): plot.policy_data() does not fail for right-censored data ──
  Error in ``[.data.table`(ld, , `:=`(tmp, cumsum(delta == 0)), by = id)`: attempt access index 12/12 in VECTOR_ELT
  Backtrace:
      ▆
   1. └─polle (local) sim_two_stage_right_cens() at test-policy_data-functions.R:1222:3
   2.   ├─ld[, `:=`(tmp, cumsum(delta == 0)), by = id] at test-policy_data-functions.R:1211:5
   3.   └─data.table:::`[.data.table`(...) at test-policy_data-functions.R:1211:5
  ── Error ('test-policy_data-functions.R:1268:5'): partial.policy_data() handles right-censoring ──
  Error in ``[.data.table`(ld, , `:=`(tmp, cumsum(delta == 0)), by = id)`: attempt access index 12/12 in VECTOR_ELT
  Backtrace:
      ▆
   1. └─polle (local) sim_two_stage_right_cens() at test-policy_data-functions.R:1279:3
   2.   ├─ld[, `:=`(tmp, cumsum(delta == 0)), by = id] at test-policy_data-functions.R:1268:5
   3.   └─data.table:::`[.data.table`(...) at test-policy_data-functions.R:1268:5
  ── Error ('test-policy_def.R:11:3'): policy_def checks the action set ──────────
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 12/12 in VECTOR_ELT
  Backtrace:
       ▆
    1. ├─testthat::expect_warning(p(pd), "The policy actions does not comply with the action set of the policy data object.") at test-policy_def.R:11:3
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat (local) .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─polle (local) p(pd)
    7.   └─base::lapply(...)
    8.     └─polle (local) FUN(X[[i]], ...)
    9.       ├─polle::get_history(...)
   10.       └─polle:::get_history.policy_data(...)
   11.         └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   12.           ├─...[]
   13.           └─data.table:::`[.data.table`(...)
  ── Error ('test-policy_def.R:39:3'): policy_def handles static policies (single stage). ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 12/12 in VECTOR_ELT
  Backtrace:
       ▆
    1. ├─testthat::expect_equal(p(pd)[["d"]], rep("1", get_n(pd))) at test-policy_def.R:39:3
    2. │ └─testthat::quasi_label(enquo(object), label)
    3. │   └─rlang::eval_bare(expr, quo_get_env(quo))
    4. └─polle (local) p(pd)
    5.   └─base::lapply(...)
    6.     └─polle (local) FUN(X[[i]], ...)
    7.       ├─polle::get_history(...)
    8.       └─polle:::get_history.policy_data(...)
    9.         └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   10.           ├─...[]
   11.           └─data.table:::`[.data.table`(...)
  ── Error ('test-policy_def.R:119:3'): policy_def handles dynamic policies (single stage). ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 12/12 in VECTOR_ELT
  Backtrace:
       ▆
    1. ├─testthat::expect_equal(p(pd)[["d"]], res) at test-policy_def.R:119:3
    2. │ └─testthat::quasi_label(enquo(object), label)
    3. │   └─rlang::eval_bare(expr, quo_get_env(quo))
    4. └─polle (local) p(pd)
    5.   └─base::lapply(...)
    6.     └─polle (local) FUN(X[[i]], ...)
    7.       ├─polle::get_history(...)
    8.       └─polle:::get_history.policy_data(...)
    9.         └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   10.           ├─...[]
   11.           └─data.table:::`[.data.table`(...)
  ── Error ('test-policy_def.R:170:7'): policy_def handles static policies (two stages). ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 11/11 in VECTOR_ELT
  Backtrace:
       ▆
    1. └─base::lapply(...) at test-policy_def.R:166:3
    2.   └─polle (local) FUN(X[[i]], ...)
    3.     ├─testthat::expect_equal(p(pd)[["d"]], rep("1", get_n(pd) * get_K(pd))) at test-policy_def.R:170:7
    4.     │ └─testthat::quasi_label(enquo(object), label)
    5.     │   └─rlang::eval_bare(expr, quo_get_env(quo))
    6.     └─polle (local) p(pd)
    7.       └─base::lapply(...)
    8.         └─polle (local) FUN(X[[i]], ...)
    9.           ├─polle::get_history(...)
   10.           └─polle:::get_history.policy_data(...)
   11.             └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   12.               ├─...[]
   13.               └─data.table:::`[.data.table`(...)
  ── Error ('test-policy_def.R:237:3'): policy_def handles dynamic policies (two stages). ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 11/11 in VECTOR_ELT
  Backtrace:
       ▆
    1. ├─testthat::expect_equal(p(pd)[["d"]], res) at test-policy_def.R:237:3
    2. │ └─testthat::quasi_label(enquo(object), label)
    3. │   └─rlang::eval_bare(expr, quo_get_env(quo))
    4. └─polle (local) p(pd)
    5.   └─base::lapply(...)
    6.     └─polle (local) FUN(X[[i]], ...)
    7.       ├─polle::get_history(...)
    8.       └─polle:::get_history.policy_data(...)
    9.         └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   10.           ├─...[]
   11.           └─data.table:::`[.data.table`(...)
  ── Error ('test-policy_def.R:308:3'): policy_def handles a stochastic number of stages ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 12/12 in VECTOR_ELT
  Backtrace:
       ▆
    1. ├─testthat::expect_equal(p(pd)[["d"]], res) at test-policy_def.R:308:3
    2. │ └─testthat::quasi_label(enquo(object), label)
    3. │   └─rlang::eval_bare(expr, quo_get_env(quo))
    4. └─polle (local) p(pd)
    5.   └─base::lapply(...)
    6.     └─polle (local) FUN(X[[i]], ...)
    7.       ├─polle::get_history(...)
    8.       └─polle:::get_history.policy_data(...)
    9.         └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   10.           ├─...[]
   11.           └─data.table:::`[.data.table`(...)
  ── Error ('test-policy_eval-censoring.R:132:3'): policy_eval checks input under right-censoring ──
  Error in ``[.data.table`(ld, , `:=`(tmp, cumsum(delta == 0)), by = id)`: attempt access index 14/14 in VECTOR_ELT
  Backtrace:
      ▆
   1. ├─ld[, `:=`(tmp, cumsum(delta == 0)), by = id] at test-policy_eval-censoring.R:132:3
   2. └─data.table:::`[.data.table`(...) at test-policy_eval-censoring.R:132:3
  ── Error ('test-policy_eval-censoring.R:244:3'): policy_eval with target 'value' has the expected output for the fixed two-stage case under right-censoring and single final utility outcome. ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 13/13 in VECTOR_ELT
  Backtrace:
      ▆
   1. └─polle::fit_g_functions(pd, g_models = list(g_glm(~1), g_glm(~1))) at test-policy_eval-censoring.R:244:3
   2.   └─base::lapply(...)
   3.     └─polle (local) FUN(X[[i]], ...)
   4.       ├─polle::get_history(policy_data, stage = s, full_history = full_history)
   5.       └─polle:::get_history.policy_data(policy_data, stage = s, full_history = full_history)
   6.         └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   7.           ├─...[]
   8.           └─data.table:::`[.data.table`(...)
  ── Error ('test-policy_eval-censoring.R:678:3'): policy_eval returns the expected c_functions output when using c-models. ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 12/12 in VECTOR_ELT
  Backtrace:
       ▆
    1. └─polle::policy_eval(...) at test-policy_eval-censoring.R:678:3
    2.   ├─base::do.call(what = policy_eval_type, args = args)
    3.   └─polle (local) `<fn>`(...)
    4.     └─polle:::fit_functions(...)
    5.       └─polle:::fit_m_function(policy_data, m_model = m_model, full_history = m_full_history)
    6.         ├─polle::get_history(...)
    7.         └─polle:::get_history.policy_data(...)
    8.           └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
    9.             ├─...[]
   10.             └─data.table:::`[.data.table`(...)
  ── Error ('test-policy_eval-censoring.R:723:3'): policy_eval with target 'subgroup' has the correct output under right-censoring. ──
  Error in ``[.data.table`(ld, , `:=`(tmp, cumsum(delta == 0)), by = id)`: attempt access index 12/12 in VECTOR_ELT
  Backtrace:
      ▆
   1. ├─ld[, `:=`(tmp, cumsum(delta == 0)), by = id] at test-policy_eval-censoring.R:723:3
   2. └─data.table:::`[.data.table`(...) at test-policy_eval-censoring.R:723:3
  ── Error ('test-policy_eval-censoring.R:1062:3'): policy_eval() handles sparse censoring. ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 13/13 in VECTOR_ELT
  Backtrace:
      ▆
   1. └─polle::fit_g_functions(pd, g_models = list(g_glm(~1), g_glm(~1))) at test-policy_eval-censoring.R:1062:3
   2.   └─base::lapply(...)
   3.     └─polle (local) FUN(X[[i]], ...)
   4.       ├─polle::get_history(policy_data, stage = s, full_history = full_history)
   5.       └─polle:::get_history.policy_data(policy_data, stage = s, full_history = full_history)
   6.         └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   7.           ├─...[]
   8.           └─data.table:::`[.data.table`(...)
  ── Error ('test-policy_eval-censoring.R:1139:3'): policy_eval() handles abundant censoring. ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 13/13 in VECTOR_ELT
  Backtrace:
      ▆
   1. └─polle::fit_g_functions(pd, g_models = list(g_glm(~1), g_glm(~1))) at test-policy_eval-censoring.R:1139:3
   2.   └─base::lapply(...)
   3.     └─polle (local) FUN(X[[i]], ...)
   4.       ├─polle::get_history(policy_data, stage = s, full_history = full_history)
   5.       └─polle:::get_history.policy_data(policy_data, stage = s, full_history = full_history)
   6.         └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   7.           ├─...[]
   8.           └─data.table:::`[.data.table`(...)
  ── Error ('test-policy_eval-censoring.R:1288:3'): policy_eval with target 'value' has the expected output
  for the two-stage case under right-censoring and terminal events. ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 13/13 in VECTOR_ELT
  Backtrace:
      ▆
   1. └─polle::fit_g_functions(pd, g_models = list(g_glm(~1), g_glm(~1))) at test-policy_eval-censoring.R:1288:3
   2.   └─base::lapply(...)
   3.     └─polle (local) FUN(X[[i]], ...)
   4.       ├─polle::get_history(policy_data, stage = s, full_history = full_history)
   5.       └─polle:::get_history.policy_data(policy_data, stage = s, full_history = full_history)
   6.         └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   7.           ├─...[]
   8.           └─data.table:::`[.data.table`(...)
  ── Failure ('test-policy_eval-subgroup.R:19:5'): policy_eval with target = 'subgroup' checks inputs. ──
  `policy_eval(...)` threw an error with unexpected message.
  Expected match: "subgroup average treatment effect evaluation is not implemented for more than two actions."
  Actual message: "attempt access index 11/11 in VECTOR_ELT"
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-policy_eval-subgroup.R:19:5
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat (local) .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─polle::policy_eval(...)
    7.   ├─base::do.call(what = policy_eval_type, args = args)
    8.   └─polle (local) `<fn>`(...)
    9.     └─polle:::fit_functions(...)
   10.       └─polle (local) policy(policy_data = policy_data)
   11.         └─base::lapply(...)
   12.           └─polle (local) FUN(X[[i]], ...)
   13.             ├─polle::get_history(...)
   14.             └─polle:::get_history.policy_data(...)
   15.               └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   16.                 ├─...[]
   17.                 └─data.table:::`[.data.table`(...)
  ── Failure ('test-policy_eval-subgroup.R:38:5'): policy_eval with target = 'subgroup' checks inputs. ──
  `policy_eval(...)` threw an error with unexpected message.
  Expected match: "subgroup average treatment effect evaluation is not implemeted for multiple stages."
  Actual message: "attempt access index 10/10 in VECTOR_ELT"
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-policy_eval-subgroup.R:38:5
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat (local) .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─polle::policy_eval(...)
    7.   ├─base::do.call(what = policy_eval_type, args = args)
    8.   └─polle (local) `<fn>`(...)
    9.     └─polle:::fit_functions(...)
   10.       └─polle (local) policy(policy_data = policy_data)
   11.         └─base::lapply(...)
   12.           └─polle (local) FUN(X[[i]], ...)
   13.             ├─polle::get_history(...)
   14.             └─polle:::get_history.policy_data(...)
   15.               └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   16.                 ├─...[]
   17.                 └─data.table:::`[.data.table`(...)
  ── Error ('test-policy_eval-subgroup.R:64:5'): policy_eval with target 'subgroup' agrees with targeted::cate. ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 10/10 in VECTOR_ELT
  Backtrace:
       ▆
    1. └─polle::policy_eval(...) at test-policy_eval-subgroup.R:64:5
    2.   ├─base::do.call(what = policy_eval_type, args = args)
    3.   └─polle (local) `<fn>`(...)
    4.     └─polle:::fit_functions(...)
    5.       └─polle (local) policy(policy_data = policy_data)
    6.         └─base::lapply(...)
    7.           └─polle (local) FUN(X[[i]], ...)
    8.             ├─polle::get_history(...)
    9.             └─polle:::get_history.policy_data(...)
   10.               └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   11.                 ├─...[]
   12.                 └─data.table:::`[.data.table`(...)
  ── Failure ('test-policy_eval-subgroup.R:185:3'): policy_eval with target 'sub_effect' has the correct outputs: test1. ──
  Expected `pe <- policy_eval(policy_data = pd, policy = p, target = "subgroup")` not to throw any errors.
  Actually got a <simpleError> with message:
    attempt access index 10/10 in VECTOR_ELT
  ── Error ('test-policy_eval-subgroup.R:138:5'): policy_eval with target 'sub_effect' has the correct outputs: test1. ──
  Error in `eval(code, test_env)`: object 'pe' not found
  Backtrace:
      ▆
   1. └─polle (local) test_output(pe) at test-policy_eval-subgroup.R:192:3
   2.   ├─testthat::expect_true(!is.null(coef(pe)) && is.numeric(coef(pe))) at test-policy_eval-subgroup.R:138:5
   3.   │ └─testthat::quasi_label(enquo(object), label)
   4.   │   └─rlang::eval_bare(expr, quo_get_env(quo))
   5.   └─stats::coef(pe)
  ── Error ('test-policy_eval-subgroup.R:283:5'): policy_eval with target 'subgroup' has the correct outputs: test2. ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 11/11 in VECTOR_ELT
  Backtrace:
       ▆
    1. └─polle::policy_eval(...) at test-policy_eval-subgroup.R:283:5
    2.   ├─base::do.call(what = policy_eval_type, args = args)
    3.   └─polle (local) `<fn>`(...)
    4.     └─polle:::fit_functions(...)
    5.       └─polle (local) policy(policy_data = policy_data)
    6.         └─base::lapply(...)
    7.           └─polle (local) FUN(X[[i]], ...)
    8.             ├─polle::get_history(...)
    9.             └─polle:::get_history.policy_data(...)
   10.               └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   11.                 ├─...[]
   12.                 └─data.table:::`[.data.table`(...)
  ── Error ('test-policy_eval-subgroup.R:360:3'): policy_eval with target 'subgroup' returns NA when no subjects are in the subgroup. ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 12/12 in VECTOR_ELT
  Backtrace:
       ▆
    1. └─polle::policy_eval(...) at test-policy_eval-subgroup.R:360:3
    2.   ├─base::do.call(what = policy_eval_type, args = args)
    3.   └─polle (local) `<fn>`(...)
    4.     └─polle:::fit_functions(...)
    5.       └─polle (local) policy(policy_data = policy_data)
    6.         └─base::lapply(...)
    7.           └─polle (local) FUN(X[[i]], ...)
    8.             ├─polle::get_history(...)
    9.             └─polle:::get_history.policy_data(...)
   10.               └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   11.                 ├─...[]
   12.                 └─data.table:::`[.data.table`(...)
  ── Error ('test-policy_eval-subgroup.R:477:3'): policy_eval with target 'subgroup' works with policy_learning with multiple thresholds. ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 12/12 in VECTOR_ELT
  Backtrace:
       ▆
    1. └─polle::policy_eval(...) at test-policy_eval-subgroup.R:477:3
    2.   ├─base::do.call(what = policy_eval_type, args = args)
    3.   └─polle (local) `<fn>`(...)
    4.     └─polle:::fit_functions(...)
    5.       └─polle::policy_learn(...)
    6.         ├─base::do.call(what = call, args)
    7.         └─polle:::blip(...)
    8.           ├─stats::predict(g_functions, policy_data)
    9.           └─polle:::predict.nuisance_functions(g_functions, policy_data)
   10.             └─base::lapply(...)
   11.               └─polle (local) FUN(X[[i]], ...)
   12.                 ├─polle::get_history(...)
   13.                 └─polle:::get_history.policy_data(...)
   14.                   └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   15.                     ├─...[]
   16.                     └─data.table:::`[.data.table`(...)
  ── Error ('test-policy_eval-subgroup.R:633:3'): policy_eval with target 'subgroup' returns NA when the subgroup count is below the minimum. ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 12/12 in VECTOR_ELT
  Backtrace:
       ▆
    1. └─polle::policy_eval(...) at test-policy_eval-subgroup.R:633:3
    2.   ├─base::do.call(what = policy_eval_type, args = args)
    3.   └─polle (local) `<fn>`(...)
    4.     └─polle:::fit_functions(...)
    5.       └─polle (local) policy(policy_data = policy_data)
    6.         └─base::lapply(...)
    7.           └─polle (local) FUN(X[[i]], ...)
    8.             ├─polle::get_history(...)
    9.             └─polle:::get_history.policy_data(...)
   10.               └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   11.                 ├─...[]
   12.                 └─data.table:::`[.data.table`(...)
  ── Failure ('test-policy_eval-subgroup.R:725:3'): policy_eval runs with policy_learn using quantile_prob_thres  ──
  `... <- NULL` threw an error.
  Message: attempt access index 10/10 in VECTOR_ELT
  Class:   simpleError/error/condition
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-policy_eval-subgroup.R:725:3
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat (local) .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─polle::policy_eval(...)
    7.   └─polle:::policy_eval_cross(...)
    8.     ├─base::do.call(what = future.apply::future_lapply, cross_args)
    9.     └─future.apply (local) `<fn>`(...)
   10.       └─future.apply:::future_xapply(...)
   11.         └─base::tryCatch(...)
   12.           └─base (local) tryCatchList(expr, classes, parentenv, handlers)
   13.             └─base (local) tryCatchOne(...)
   14.               └─value[[3L]](cond)
   15.                 └─future.apply:::onError(e, futures = fs, debug = debug)
  ── Error ('test-policy_eval.R:6:3'): policy_eval returns g and Q-function values. ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 10/10 in VECTOR_ELT
  Backtrace:
       ▆
    1. └─polle::policy_eval(pd, policy = p) at test-policy_eval.R:6:3
    2.   ├─base::do.call(what = policy_eval_type, args = args)
    3.   └─polle (local) `<fn>`(...)
    4.     └─polle:::fit_functions(...)
    5.       └─polle (local) policy(policy_data = policy_data)
    6.         └─base::lapply(...)
    7.           └─polle (local) FUN(X[[i]], ...)
    8.             ├─polle::get_history(...)
    9.             └─polle:::get_history.policy_data(...)
   10.               └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   11.                 ├─...[]
   12.                 └─data.table:::`[.data.table`(...)
  ── Error ('test-policy_eval.R:52:5'): policy_eval do not save g and Q-functions when
  save_g_functions = FALSE and save_q_functions = FALSE. ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 10/10 in VECTOR_ELT
  Backtrace:
       ▆
    1. └─polle::policy_eval(pd, policy = p) at test-policy_eval.R:52:5
    2.   ├─base::do.call(what = policy_eval_type, args = args)
    3.   └─polle (local) `<fn>`(...)
    4.     └─polle:::fit_functions(...)
    5.       └─polle (local) policy(policy_data = policy_data)
    6.         └─base::lapply(...)
    7.           └─polle (local) FUN(X[[i]], ...)
    8.             ├─polle::get_history(...)
    9.             └─polle:::get_history.policy_data(...)
   10.               └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   11.                 ├─...[]
   12.                 └─data.table:::`[.data.table`(...)
  ── Failure ('test-policy_eval.R:149:3'): policy_eval checks inputs. ────────────
  `policy_eval(policy_data = pd, policy = p, g_model = g_glm())` threw an error.
  Message: attempt access index 10/10 in VECTOR_ELT
  Class:   simpleError/error/condition
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-policy_eval.R:149:3
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat (local) .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─polle::policy_eval(policy_data = pd, policy = p, g_model = g_glm())
    7.   ├─base::do.call(what = policy_eval_type, args = args)
    8.   └─polle (local) `<fn>`(...)
    9.     └─polle:::fit_functions(...)
   10.       └─polle (local) policy(policy_data = policy_data)
   11.         └─base::lapply(...)
   12.           └─polle (local) FUN(X[[i]], ...)
   13.             ├─polle::get_history(...)
   14.             └─polle:::get_history.policy_data(...)
   15.               └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   16.                 ├─...[]
   17.                 └─data.table:::`[.data.table`(...)
  ── Failure ('test-policy_eval.R:157:3'): policy_eval checks inputs. ────────────
  `policy_eval(policy_data = pd, policy = p, g_models = list(g_glm()))` threw an error.
  Message: attempt access index 10/10 in VECTOR_ELT
  Class:   simpleError/error/condition
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-policy_eval.R:157:3
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat (local) .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─polle::policy_eval(policy_data = pd, policy = p, g_models = list(g_glm()))
    7.   ├─base::do.call(what = policy_eval_type, args = args)
    8.   └─polle (local) `<fn>`(...)
    9.     └─polle:::fit_functions(...)
   10.       └─polle::fit_g_functions(policy_data, g_models = g_models, full_history = g_full_history)
   11.         └─base::lapply(...)
   12.           └─polle (local) FUN(X[[i]], ...)
   13.             ├─polle::get_history(policy_data, stage = s, full_history = full_history)
   14.             └─polle:::get_history.policy_data(policy_data, stage = s, full_history = full_history)
   15.               └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   16.                 ├─...[]
   17.                 └─data.table:::`[.data.table`(...)
  ── Error ('test-policy_eval.R:175:3'): policy_eval checks inputs. ──────────────
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 10/10 in VECTOR_ELT
  Backtrace:
      ▆
   1. └─polle:::fit_Q_functions(...) at test-policy_eval.R:175:3
   2.   └─polle:::q_step(...)
   3.     ├─polle::get_history(policy_data, stage = k, full_history = full_history)
   4.     └─polle:::get_history.policy_data(policy_data, stage = k, full_history = full_history)
   5.       └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   6.         ├─...[]
   7.         └─data.table:::`[.data.table`(...)
  ── Failure ('test-policy_eval.R:276:3'): policy_eval handles combinations of nuisance models and functions correctly. ──
  Expected `pe <- policy_eval(pd, policy = p, g_functions = gf, g_models = g_glm(~Z))` not to throw any errors.
  Actually got a <simpleError> with message:
    attempt access index 10/10 in VECTOR_ELT
  ── Error ('test-policy_eval.R:280:3'): policy_eval handles combinations of nuisance models and functions correctly. ──
  Error in `eval(code, test_env)`: object 'pe' not found
  Backtrace:
      ▆
   1. ├─testthat::expect_equal(get_g_functions(pe), gf) at test-policy_eval.R:280:3
   2. │ └─testthat::quasi_label(enquo(object), label)
   3. │   └─rlang::eval_bare(expr, quo_get_env(quo))
   4. └─polle::get_g_functions(pe)
  ── Failure ('test-policy_eval.R:351:3'): policy_eval runs on a subset of the data with missing actions from the action set. ──
  `pe1_ipw <- policy_eval(pd1, policy = policy_def(1), type = "ipw")` threw an error.
  Message: attempt access index 10/10 in VECTOR_ELT
  Class:   simpleError/error/condition
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-policy_eval.R:351:3
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat (local) .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─polle::policy_eval(pd1, policy = policy_def(1), type = "ipw")
    7.   ├─base::do.call(what = policy_eval_type, args = args)
    8.   └─polle (local) `<fn>`(...)
    9.     └─polle:::fit_functions(...)
   10.       └─polle (local) policy(policy_data = policy_data)
   11.         └─base::lapply(...)
   12.           └─polle (local) FUN(X[[i]], ...)
   13.             ├─polle::get_history(...)
   14.             └─polle:::get_history.policy_data(...)
   15.               └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   16.                 ├─...[]
   17.                 └─data.table:::`[.data.table`(...)
  ── Failure ('test-policy_eval.R:355:3'): policy_eval runs on a subset of the data with missing actions from the action set. ──
  `... <- NULL` threw an error.
  Message: object 'pe1_ipw' not found
  Class:   simpleError/error/condition
  Backtrace:
      ▆
   1. ├─testthat::expect_error(...) at test-policy_eval.R:355:3
   2. │ └─testthat:::quasi_capture(...)
   3. │   ├─testthat (local) .capture(...)
   4. │   │ └─base::withCallingHandlers(...)
   5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
   6. ├─polle::policy_eval(...)
   7. │ ├─base::as.list(environment())
   8. │ └─base::as.list.environment(environment())
   9. └─polle::get_g_functions(pe1_ipw)
  ── Error ('test-policy_eval.R:364:3'): policy_eval runs on a subset of the data with missing actions from the action set. ──
  Error in `eval(code, test_env)`: object 'pe2_ipw' not found
  Backtrace:
      ▆
   1. ├─testthat::expect_equal(unname(coef(pe2_ipw)), 0) at test-policy_eval.R:364:3
   2. │ └─testthat::quasi_label(enquo(object), label)
   3. │   └─rlang::eval_bare(expr, quo_get_env(quo))
   4. ├─base::unname(coef(pe2_ipw))
   5. └─stats::coef(pe2_ipw)
  ── Failure ('test-policy_eval.R:409:3'): policy_eval handles varying stage action sets. ──
  `... <- NULL` threw an error.
  Message: attempt access index 12/12 in VECTOR_ELT
  Class:   simpleError/error/condition
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-policy_eval.R:409:3
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat (local) .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─polle::policy_eval(...)
    7.   ├─base::do.call(what = policy_eval_type, args = args)
    8.   └─polle (local) `<fn>`(...)
    9.     └─polle:::fit_functions(...)
   10.       └─polle::fit_g_functions(policy_data, g_models = g_models, full_history = g_full_history)
   11.         └─base::lapply(...)
   12.           └─polle (local) FUN(X[[i]], ...)
   13.             ├─polle::get_history(policy_data, stage = s, full_history = full_history)
   14.             └─polle:::get_history.policy_data(policy_data, stage = s, full_history = full_history)
   15.               └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   16.                 ├─...[]
   17.                 └─data.table:::`[.data.table`(...)
  ── Failure ('test-policy_eval.R:421:3'): policy_eval handles varying stage action sets. ──
  `policy_eval(...)` threw an error with unexpected message.
  Expected match: "The policy actions does not comply with the stage action sets of the policy data object."
  Actual message: "attempt access index 12/12 in VECTOR_ELT"
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-policy_eval.R:421:3
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat (local) .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─polle::policy_eval(...)
    7.   ├─base::do.call(what = policy_eval_type, args = args)
    8.   └─polle (local) `<fn>`(...)
    9.     └─polle:::fit_functions(...)
   10.       └─polle::fit_g_functions(policy_data, g_models = g_models, full_history = g_full_history)
   11.         └─base::lapply(...)
   12.           └─polle (local) FUN(X[[i]], ...)
   13.             ├─polle::get_history(policy_data, stage = s, full_history = full_history)
   14.             └─polle:::get_history.policy_data(policy_data, stage = s, full_history = full_history)
   15.               └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   16.                 ├─...[]
   17.                 └─data.table:::`[.data.table`(...)
  ── Failure ('test-policy_eval.R:438:3'): policy_eval with target = 'value' runs when cross-fitting. ──
  Expected `... <- NULL` not to throw any errors.
  Actually got a <simpleError> with message:
    attempt access index 10/10 in VECTOR_ELT
  ── Error ('test-policy_eval.R:447:3'): policy_eval with target = 'value' runs when cross-fitting. ──
  Error in `eval(code, test_env)`: object 'pe_pooled' not found
  Backtrace:
      ▆
   1. ├─testthat::expect_true(is.numeric(coef(pe_pooled))) at test-policy_eval.R:447:3
   2. │ └─testthat::quasi_label(enquo(object), label)
   3. │   └─rlang::eval_bare(expr, quo_get_env(quo))
   4. └─stats::coef(pe_pooled)
  ── Error ('test-policy_eval.R:518:3'): policy_eval with target = 'value' agrees with targeted::cate in the single-stage case. ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 10/10 in VECTOR_ELT
  Backtrace:
       ▆
    1. └─polle::policy_eval(...) at test-policy_eval.R:518:3
    2.   └─polle:::policy_eval_cross(...)
    3.     ├─base::do.call(what = future.apply::future_lapply, cross_args)
    4.     └─future.apply (local) `<fn>`(...)
    5.       └─future.apply:::future_xapply(...)
    6.         └─base::tryCatch(...)
    7.           └─base (local) tryCatchList(expr, classes, parentenv, handlers)
    8.             └─base (local) tryCatchOne(...)
    9.               └─value[[3L]](cond)
   10.                 └─future.apply:::onError(e, futures = fs, debug = debug)
  ── Error ('test-policy_eval.R:564:3'): policy_eval with target 'value' has the correct outputs in the single-stage case. ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 11/11 in VECTOR_ELT
  Backtrace:
       ▆
    1. └─polle::policy_eval(...) at test-policy_eval.R:564:3
    2.   ├─base::do.call(what = policy_eval_type, args = args)
    3.   └─polle (local) `<fn>`(...)
    4.     └─polle:::fit_functions(...)
    5.       └─polle (local) policy(policy_data = policy_data)
    6.         └─base::lapply(...)
    7.           └─polle (local) FUN(X[[i]], ...)
    8.             ├─polle::get_history(...)
    9.             └─polle:::get_history.policy_data(...)
   10.               └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   11.                 ├─...[]
   12.                 └─data.table:::`[.data.table`(...)
  ── Failure ('test-policy_eval.R:708:3'): policy_eval passes nuisance models to policy_learn correctly ──
  Expected `pe <- policy_eval(pd, policy_learn = pl, g_functions = gf, g_models = g_glm(~Z))` not to throw any errors.
  Actually got a <simpleError> with message:
    attempt access index 10/10 in VECTOR_ELT
  ── Error ('test-policy_eval.R:714:3'): policy_eval passes nuisance models to policy_learn correctly ──
  Error in `eval(code, test_env)`: object 'pe' not found
  Backtrace:
      ▆
   1. └─polle::get_policy_object(pe) at test-policy_eval.R:714:3
  ── Error ('test-policy_eval.R:786:3'): policy_eval() using policy_learn() has the correct output ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 11/11 in VECTOR_ELT
  Backtrace:
       ▆
    1. └─polle::policy_eval(...) at test-policy_eval.R:786:3
    2.   ├─base::do.call(what = policy_eval_type, args = args)
    3.   └─polle (local) `<fn>`(...)
    4.     └─polle:::fit_functions(...)
    5.       └─polle::policy_learn(...)
    6.         ├─base::do.call(what = call, args)
    7.         └─polle:::blip(...)
    8.           ├─stats::predict(g_functions, policy_data)
    9.           └─polle:::predict.nuisance_functions(g_functions, policy_data)
   10.             └─base::lapply(...)
   11.               └─polle (local) FUN(X[[i]], ...)
   12.                 ├─polle::get_history(...)
   13.                 └─polle:::get_history.policy_data(...)
   14.                   └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   15.                     ├─...[]
   16.                     └─data.table:::`[.data.table`(...)
  ── Error ('test-policy_eval.R:860:3'): policy_eval with target 'value' has the correct outputs for the fixed two-stage case and a single final utility outcome. ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 13/13 in VECTOR_ELT
  Backtrace:
       ▆
    1. └─polle::policy_eval(...) at test-policy_eval.R:860:3
    2.   ├─base::do.call(what = policy_eval_type, args = args)
    3.   └─polle (local) `<fn>`(...)
    4.     └─polle:::fit_functions(...)
    5.       └─polle::fit_g_functions(policy_data, g_models = g_models, full_history = g_full_history)
    6.         └─base::lapply(...)
    7.           └─polle (local) FUN(X[[i]], ...)
    8.             ├─polle::get_history(policy_data, stage = s, full_history = full_history)
    9.             └─polle:::get_history.policy_data(policy_data, stage = s, full_history = full_history)
   10.               └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   11.                 ├─...[]
   12.                 └─data.table:::`[.data.table`(...)
  ── Error ('test-policy_eval.R:917:3'): policy_eval with target 'value' has the correct outputs for the stochastic two-stage case and a single final utility outcome. ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 13/13 in VECTOR_ELT
  Backtrace:
      ▆
   1. └─polle::fit_g_functions(pd, g_models = list(g_glm(~1), g_glm(~1))) at test-policy_eval.R:917:3
   2.   └─base::lapply(...)
   3.     └─polle (local) FUN(X[[i]], ...)
   4.       ├─polle::get_history(policy_data, stage = s, full_history = full_history)
   5.       └─polle:::get_history.policy_data(policy_data, stage = s, full_history = full_history)
   6.         └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   7.           ├─...[]
   8.           └─data.table:::`[.data.table`(...)
  ── Failure ('test-policy_eval.R:1074:3'): policy_eval() return estimates for multiple policies associated with multiple thresholds. ──
  Expected `{ ... }` not to throw any errors.
  Actually got a <simpleError> with message:
    attempt access index 10/10 in VECTOR_ELT
  ── Error ('test-policy_eval.R:1082:3'): policy_eval() return estimates for multiple policies associated with multiple thresholds. ──
  Error in `eval(code, test_env)`: object 'pe' not found
  Backtrace:
      ▆
   1. ├─testthat::expect_equal(unname(coef(pe)), ref_pe) at test-policy_eval.R:1082:3
   2. │ └─testthat::quasi_label(enquo(object), label)
   3. │   └─rlang::eval_bare(expr, quo_get_env(quo))
   4. ├─base::unname(coef(pe))
   5. └─stats::coef(pe)
  ── Error ('test-policy_eval.R:1224:3'): conditional.policy_eval agrees with targeted::cate ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 10/10 in VECTOR_ELT
  Backtrace:
       ▆
    1. └─polle::policy_eval(...) at test-policy_eval.R:1224:3
    2.   ├─base::do.call(what = policy_eval_type, args = args)
    3.   └─polle (local) `<fn>`(...)
    4.     └─polle:::fit_functions(...)
    5.       └─polle (local) policy(policy_data = policy_data)
    6.         └─base::lapply(...)
    7.           └─polle (local) FUN(X[[i]], ...)
    8.             ├─polle::get_history(...)
    9.             └─polle:::get_history.policy_data(...)
   10.               └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   11.                 ├─...[]
   12.                 └─data.table:::`[.data.table`(...)
  ── Failure ('test-policy_eval.R:1291:3'): policy_eval with target = 'value' runs when performing repeated cross-fitting. ──
  Expected `... <- NULL` not to throw any errors.
  Actually got a <simpleError> with message:
    attempt access index 11/11 in VECTOR_ELT
  ── Error ('test-policy_eval.R:1302:3'): policy_eval with target = 'value' runs when performing repeated cross-fitting. ──
  Error in `eval(code, test_env)`: object 'pe' not found
  Backtrace:
      ▆
   1. ├─testthat::expect_equal(unname(coef(pe)), ref_pe) at test-policy_eval.R:1302:3
   2. │ └─testthat::quasi_label(enquo(object), label)
   3. │   └─rlang::eval_bare(expr, quo_get_env(quo))
   4. ├─base::unname(coef(pe))
   5. └─stats::coef(pe)
  ── Failure ('test-policy_eval.R:1380:3'): policy_eval() runs without covariates. ──
  Expected `... <- NULL` not to throw any errors.
  Actually got a <simpleError> with message:
    attempt access index 9/9 in VECTOR_ELT
  ── Error ('test-policy_eval.R:1392:3'): policy_eval() runs without covariates. ──
  Error in `eval(code, test_env)`: object 'pe' not found
  Backtrace:
      ▆
   1. ├─testthat::expect_equal(unname(coef(pe)), ref_pe) at test-policy_eval.R:1392:3
   2. │ └─testthat::quasi_label(enquo(object), label)
   3. │   └─rlang::eval_bare(expr, quo_get_env(quo))
   4. ├─base::unname(coef(pe))
   5. └─stats::coef(pe)
  ── Error ('test-policy_eval_online.R:19:3'): policy_eval_online() uses valid indexes for training and validation: ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 11/11 in VECTOR_ELT
  Backtrace:
       ▆
    1. └─polle::policy_eval_online(...) at test-policy_eval_online.R:19:3
    2.   └─polle:::policy_eval_on(...)
    3.     └─base::lapply(...)
    4.       └─polle (local) FUN(X[[i]], ...)
    5.         ├─base::do.call(what = "policy_eval_type", args = eval_args)
    6.         └─polle:::policy_eval_type(...)
    7.           └─polle:::fit_functions(...)
    8.             └─polle (local) policy(policy_data = policy_data)
    9.               └─base::lapply(...)
   10.                 └─polle (local) FUN(X[[i]], ...)
   11.                   ├─polle::get_history(...)
   12.                   └─polle:::get_history.policy_data(...)
   13.                     └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   14.                       ├─...[]
   15.                       └─data.table:::`[.data.table`(...)
  ── Error ('test-policy_eval_online.R:70:3'): policy_eval_online has the expected output for target = 'value' in the single stage case: ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 11/11 in VECTOR_ELT
  Backtrace:
       ▆
    1. └─polle::policy_eval_online(...) at test-policy_eval_online.R:70:3
    2.   └─polle:::policy_eval_on(...)
    3.     └─base::lapply(...)
    4.       └─polle (local) FUN(X[[i]], ...)
    5.         ├─base::do.call(what = "policy_eval_type", args = eval_args)
    6.         └─polle:::policy_eval_type(...)
    7.           └─polle:::fit_functions(...)
    8.             └─polle (local) policy(policy_data = policy_data)
    9.               └─base::lapply(...)
   10.                 └─polle (local) FUN(X[[i]], ...)
   11.                   ├─polle::get_history(...)
   12.                   └─polle:::get_history.policy_data(...)
   13.                     └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   14.                       ├─...[]
   15.                       └─data.table:::`[.data.table`(...)
  ── Error ('test-policy_eval_online.R:228:3'): policy_eval_sequential has the expected output in the single stage case for target = 'subgroup' ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 11/11 in VECTOR_ELT
  Backtrace:
       ▆
    1. └─polle::policy_eval_online(...) at test-policy_eval_online.R:228:3
    2.   └─polle:::policy_eval_on(...)
    3.     └─base::lapply(...)
    4.       └─polle (local) FUN(X[[i]], ...)
    5.         ├─base::do.call(what = "policy_eval_type", args = eval_args)
    6.         └─polle:::policy_eval_type(...)
    7.           └─polle:::fit_functions(...)
    8.             └─polle (local) policy(policy_data = policy_data)
    9.               └─base::lapply(...)
   10.                 └─polle (local) FUN(X[[i]], ...)
   11.                   ├─polle::get_history(...)
   12.                   └─polle:::get_history.policy_data(...)
   13.                     └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   14.                       ├─...[]
   15.                       └─data.table:::`[.data.table`(...)
  ── Error ('test-policy_g_functions.R:16:3'): policy_g_functions returns a policy which selects the most probable action. ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 12/12 in VECTOR_ELT
  Backtrace:
      ▆
   1. ├─stats::predict(g_functions, pd) at test-policy_g_functions.R:16:3
   2. └─polle:::predict.nuisance_functions(g_functions, pd)
   3.   └─base::lapply(...)
   4.     └─polle (local) FUN(X[[i]], ...)
   5.       ├─polle::get_history(...)
   6.       └─polle:::get_history.policy_data(...)
   7.         └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   8.           ├─...[]
   9.           └─data.table:::`[.data.table`(...)
  ── Error ('test-policy_learn-blip-censoring.R:37:3'): policy_learn with type 'blip' has the expected output for the fixed two-stage case under right-censoring and single final utility outcome. ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 13/13 in VECTOR_ELT
  Backtrace:
      ▆
   1. └─polle::fit_g_functions(pd, g_models = list(g_glm(~1), g_glm(~1))) at test-policy_learn-blip-censoring.R:37:3
   2.   └─base::lapply(...)
   3.     └─polle (local) FUN(X[[i]], ...)
   4.       ├─polle::get_history(policy_data, stage = s, full_history = full_history)
   5.       └─polle:::get_history.policy_data(policy_data, stage = s, full_history = full_history)
   6.         └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   7.           ├─...[]
   8.           └─data.table:::`[.data.table`(...)
  ── Error ('test-policy_learn-blip.R:17:5'): policy_learn with type blip works as intended ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 11/11 in VECTOR_ELT
  Backtrace:
       ▆
    1. ├─testthat::expect_true(...) at test-policy_learn-blip.R:16:3
    2. │ └─testthat::quasi_label(enquo(object), label)
    3. │   └─rlang::eval_bare(expr, quo_get_env(quo))
    4. └─polle:::pl(policy_data = pd, g_models = g_glm(), q_models = q_glm()) at test-policy_learn-blip.R:17:5
    5.   ├─base::do.call(what = call, args)
    6.   └─polle:::blip(...)
    7.     └─polle:::q_step(...)
    8.       ├─polle::get_history(policy_data, stage = k, full_history = full_history)
    9.       └─polle:::get_history.policy_data(policy_data, stage = k, full_history = full_history)
   10.         └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   11.           ├─...[]
   12.           └─data.table:::`[.data.table`(...)
  ── Error ('test-policy_learn-blip.R:88:3'): get_policy_functions.blip returns a list of policy functions ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 13/13 in VECTOR_ELT
  Backtrace:
       ▆
    1. └─polle:::pl(...) at test-policy_learn-blip.R:88:3
    2.   ├─base::do.call(what = call, args)
    3.   └─polle:::blip(...)
    4.     └─polle::fit_g_functions(policy_data, g_models = g_models, full_history = g_full_history)
    5.       └─base::lapply(...)
    6.         └─polle (local) FUN(X[[i]], ...)
    7.           ├─polle::get_history(policy_data, stage = s, full_history = full_history)
    8.           └─polle:::get_history.policy_data(policy_data, stage = s, full_history = full_history)
    9.             └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   10.               ├─...[]
   11.               └─data.table:::`[.data.table`(...)
  ── Error ('test-policy_learn-blip.R:165:3'): get_policy.blip returns a policy ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 13/13 in VECTOR_ELT
  Backtrace:
       ▆
    1. └─polle:::pl(...) at test-policy_learn-blip.R:165:3
    2.   ├─base::do.call(what = call, args)
    3.   └─polle:::blip(...)
    4.     └─polle::fit_g_functions(policy_data, g_models = g_models, full_history = g_full_history)
    5.       └─base::lapply(...)
    6.         └─polle (local) FUN(X[[i]], ...)
    7.           ├─polle::get_history(policy_data, stage = s, full_history = full_history)
    8.           └─polle:::get_history.policy_data(policy_data, stage = s, full_history = full_history)
    9.             └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   10.               ├─...[]
   11.               └─data.table:::`[.data.table`(...)
  ── Error ('test-policy_learn-blip.R:235:3'): policy_learn with type blip is persistent in the single stage case. ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 12/12 in VECTOR_ELT
  Backtrace:
       ▆
    1. └─polle:::pl(pd, q_models = q_glm(), g_models = g_glm()) at test-policy_learn-blip.R:235:3
    2.   ├─base::do.call(what = call, args)
    3.   └─polle:::blip(...)
    4.     ├─stats::predict(g_functions, policy_data)
    5.     └─polle:::predict.nuisance_functions(g_functions, policy_data)
    6.       └─base::lapply(...)
    7.         └─polle (local) FUN(X[[i]], ...)
    8.           ├─polle::get_history(...)
    9.           └─polle:::get_history.policy_data(...)
   10.             └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   11.               ├─...[]
   12.               └─data.table:::`[.data.table`(...)
  ── Error ('test-policy_learn-blip.R:275:3'): policy_learn with type blip passes the threshold argument in the single-stage case, ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 12/12 in VECTOR_ELT
  Backtrace:
       ▆
    1. └─polle:::pl(pd, q_models = q_glm(), g_models = g_glm()) at test-policy_learn-blip.R:275:3
    2.   ├─base::do.call(what = call, args)
    3.   └─polle:::blip(...)
    4.     ├─stats::predict(g_functions, policy_data)
    5.     └─polle:::predict.nuisance_functions(g_functions, policy_data)
    6.       └─base::lapply(...)
    7.         └─polle (local) FUN(X[[i]], ...)
    8.           ├─polle::get_history(...)
    9.           └─polle:::get_history.policy_data(...)
   10.             └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   11.               ├─...[]
   12.               └─data.table:::`[.data.table`(...)
  ── Error ('test-policy_learn-blip.R:309:3'): get_policy.blip uses the threshold argument ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 12/12 in VECTOR_ELT
  Backtrace:
       ▆
    1. └─polle:::pl(pd, q_models = q_glm(), g_models = g_glm()) at test-policy_learn-blip.R:309:3
    2.   ├─base::do.call(what = call, args)
    3.   └─polle:::blip(...)
    4.     ├─stats::predict(g_functions, policy_data)
    5.     └─polle:::predict.nuisance_functions(g_functions, policy_data)
    6.       └─base::lapply(...)
    7.         └─polle (local) FUN(X[[i]], ...)
    8.           ├─polle::get_history(...)
    9.           └─polle:::get_history.policy_data(...)
   10.             └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   11.               ├─...[]
   12.               └─data.table:::`[.data.table`(...)
  ── Error ('test-policy_learn-blip.R:370:3'): policy_learn with type blip uses the threshold argument in the two-stage case, ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 11/11 in VECTOR_ELT
  Backtrace:
      ▆
   1. └─polle:::pl(pd, q_models = q_glm(), g_models = g_glm()) at test-policy_learn-blip.R:370:3
   2.   ├─base::do.call(what = call, args)
   3.   └─polle:::blip(...)
   4.     └─polle:::q_step(...)
   5.       ├─polle::get_history(policy_data, stage = k, full_history = full_history)
   6.       └─polle:::get_history.policy_data(policy_data, stage = k, full_history = full_history)
   7.         └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   8.           ├─...[]
   9.           └─data.table:::`[.data.table`(...)
  ── Error ('test-policy_learn-blip.R:410:3'): get_policy and get_policy_functions agree with type blip and a non-zero threshold argument, ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 12/12 in VECTOR_ELT
  Backtrace:
       ▆
    1. └─polle:::pl(pd, q_models = q_glm(), g_models = g_glm()) at test-policy_learn-blip.R:410:3
    2.   ├─base::do.call(what = call, args)
    3.   └─polle:::blip(...)
    4.     ├─stats::predict(g_functions, policy_data)
    5.     └─polle:::predict.nuisance_functions(g_functions, policy_data)
    6.       └─base::lapply(...)
    7.         └─polle (local) FUN(X[[i]], ...)
    8.           ├─polle::get_history(...)
    9.           └─polle:::get_history.policy_data(...)
   10.             └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   11.               ├─...[]
   12.               └─data.table:::`[.data.table`(...)
  ── Error ('test-policy_learn-blip.R:458:3'): get_policy.blip() returns multiple policies when given multiple thresholds. ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 12/12 in VECTOR_ELT
  Backtrace:
       ▆
    1. └─polle:::pl(pd, q_models = q_glm(), g_models = g_glm()) at test-policy_learn-blip.R:458:3
    2.   ├─base::do.call(what = call, args)
    3.   └─polle:::blip(...)
    4.     ├─stats::predict(g_functions, policy_data)
    5.     └─polle:::predict.nuisance_functions(g_functions, policy_data)
    6.       └─base::lapply(...)
    7.         └─polle (local) FUN(X[[i]], ...)
    8.           ├─polle::get_history(...)
    9.           └─polle:::get_history.policy_data(...)
   10.             └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   11.               ├─...[]
   12.               └─data.table:::`[.data.table`(...)
  ── Error ('test-policy_learn-blip.R:513:3'): policy_learn with type blip uses the quantile_threshold argument. ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 12/12 in VECTOR_ELT
  Backtrace:
       ▆
    1. └─polle:::pl(pd, q_models = q_glm(), g_models = g_glm()) at test-policy_learn-blip.R:513:3
    2.   ├─base::do.call(what = call, args)
    3.   └─polle:::blip(...)
    4.     ├─stats::predict(g_functions, policy_data)
    5.     └─polle:::predict.nuisance_functions(g_functions, policy_data)
    6.       └─base::lapply(...)
    7.         └─polle (local) FUN(X[[i]], ...)
    8.           ├─polle::get_history(...)
    9.           └─polle:::get_history.policy_data(...)
   10.             └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   11.               ├─...[]
   12.               └─data.table:::`[.data.table`(...)
  ── Error ('test-policy_learn-blip.R:576:3'): policy_learn with type 'blip' has the expected output for a fixed two-stage case with a single final utility outcome. ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 13/13 in VECTOR_ELT
  Backtrace:
      ▆
   1. └─polle::fit_g_functions(pd, g_models = list(g_glm(~1), g_glm(~1))) at test-policy_learn-blip.R:576:3
   2.   └─base::lapply(...)
   3.     └─polle (local) FUN(X[[i]], ...)
   4.       ├─polle::get_history(policy_data, stage = s, full_history = full_history)
   5.       └─polle:::get_history.policy_data(policy_data, stage = s, full_history = full_history)
   6.         └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   7.           ├─...[]
   8.           └─data.table:::`[.data.table`(...)
  ── Error ('test-policy_learn-blip.R:758:3'): policy_learn with type 'blip' has the correct outputs for the stochastic two-stage case and a single final utility outcome. ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 13/13 in VECTOR_ELT
  Backtrace:
      ▆
   1. └─polle::fit_g_functions(pd, g_models = list(g_glm(~1), g_glm(~1))) at test-policy_learn-blip.R:758:3
   2.   └─base::lapply(...)
   3.     └─polle (local) FUN(X[[i]], ...)
   4.       ├─polle::get_history(policy_data, stage = s, full_history = full_history)
   5.       └─polle:::get_history.policy_data(policy_data, stage = s, full_history = full_history)
   6.         └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   7.           ├─...[]
   8.           └─data.table:::`[.data.table`(...)
  ── Failure ('test-policy_learn-drql.R:11:3'): get_policy.drql returns a policy ──
  `{ ... }` threw an error.
  Message: attempt access index 12/12 in VECTOR_ELT
  Class:   simpleError/error/condition
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-policy_learn-drql.R:11:3
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat (local) .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. ├─polle::get_policy(pl(pd, q_models = q_glm(), g_models = g_glm())) at test-policy_learn-drql.R:12:5
    7. └─polle:::pl(pd, q_models = q_glm(), g_models = g_glm())
    8.   ├─base::do.call(what = call, args)
    9.   └─polle:::drql(...)
   10.     ├─stats::predict(g_functions, policy_data)
   11.     └─polle:::predict.nuisance_functions(g_functions, policy_data)
   12.       └─base::lapply(...)
   13.         └─polle (local) FUN(X[[i]], ...)
   14.           ├─polle::get_history(...)
   15.           └─polle:::get_history.policy_data(...)
   16.             └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   17.               ├─...[]
   18.               └─data.table:::`[.data.table`(...)
  ── Error ('test-policy_learn-drql.R:16:3'): get_policy.drql returns a policy ───
  Error in `eval(code, test_env)`: object 'p' not found
  Backtrace:
      ▆
   1. ├─testthat::expect_true(inherits(p, what = "policy")) at test-policy_learn-drql.R:16:3
   2. │ └─testthat::quasi_label(enquo(object), label)
   3. │   └─rlang::eval_bare(expr, quo_get_env(quo))
   4. └─base::inherits(p, what = "policy")
  ── Error ('test-policy_learn-drql.R:54:3'): policy_learn with type = 'drql' checks input ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 11/11 in VECTOR_ELT
  Backtrace:
      ▆
   1. └─polle::fit_g_functions(...) at test-policy_learn-drql.R:54:3
   2.   └─base::lapply(...)
   3.     └─polle (local) FUN(X[[i]], ...)
   4.       ├─polle::get_history(policy_data, stage = s, full_history = full_history)
   5.       └─polle:::get_history.policy_data(policy_data, stage = s, full_history = full_history)
   6.         └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   7.           ├─...[]
   8.           └─data.table:::`[.data.table`(...)
  ── Error ('test-policy_learn-drql.R:95:3'): policy_learn with type drql works as intended ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 11/11 in VECTOR_ELT
  Backtrace:
      ▆
   1. └─polle::fit_g_functions(...) at test-policy_learn-drql.R:95:3
   2.   └─base::lapply(...)
   3.     └─polle (local) FUN(X[[i]], ...)
   4.       ├─polle::get_history(policy_data, stage = s, full_history = full_history)
   5.       └─polle:::get_history.policy_data(policy_data, stage = s, full_history = full_history)
   6.         └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   7.           ├─...[]
   8.           └─data.table:::`[.data.table`(...)
  ── Failure ('test-policy_learn-drql.R:189:3'): policy_learn with type drql handles varying action sets ──
  `po <- pl(pd, q_models = q_glm(), g_models = list(g_glm(), g_rf()))` threw an error.
  Message: attempt access index 12/12 in VECTOR_ELT
  Class:   simpleError/error/condition
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-policy_learn-drql.R:189:3
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat (local) .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─polle:::pl(pd, q_models = q_glm(), g_models = list(g_glm(), g_rf()))
    7.   ├─base::do.call(what = call, args)
    8.   └─polle:::drql(...)
    9.     └─polle::fit_g_functions(policy_data, g_models = g_models, full_history = g_full_history)
   10.       └─base::lapply(...)
   11.         └─polle (local) FUN(X[[i]], ...)
   12.           ├─polle::get_history(policy_data, stage = s, full_history = full_history)
   13.           └─polle:::get_history.policy_data(policy_data, stage = s, full_history = full_history)
   14.             └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   15.               ├─...[]
   16.               └─data.table:::`[.data.table`(...)
  ── Failure ('test-policy_learn-drql.R:193:3'): policy_learn with type drql handles varying action sets ──
  `pa <- get_policy(po)(pd)` threw an error.
  Message: object 'po' not found
  Class:   simpleError/error/condition
  Backtrace:
      ▆
   1. ├─testthat::expect_error(pa <- get_policy(po)(pd), NA) at test-policy_learn-drql.R:193:3
   2. │ └─testthat:::quasi_capture(...)
   3. │   ├─testthat (local) .capture(...)
   4. │   │ └─base::withCallingHandlers(...)
   5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
   6. └─polle::get_policy(po)
  ── Failure ('test-policy_learn-drql.R:198:3'): policy_learn with type drql handles varying action sets ──
  `pf1 <- get_policy_functions(po, stage = 1)` threw an error.
  Message: object 'po' not found
  Class:   simpleError/error/condition
  Backtrace:
      ▆
   1. ├─testthat::expect_error(...) at test-policy_learn-drql.R:198:3
   2. │ └─testthat:::quasi_capture(...)
   3. │   ├─testthat (local) .capture(...)
   4. │   │ └─base::withCallingHandlers(...)
   5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
   6. └─polle::get_policy_functions(po, stage = 1)
  ── Error ('test-policy_learn-drql.R:202:3'): policy_learn with type drql handles varying action sets ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 12/12 in VECTOR_ELT
  Backtrace:
      ▆
   1. ├─polle::get_history(pd, stage = 1, full_history = FALSE) at test-policy_learn-drql.R:202:3
   2. └─polle:::get_history.policy_data(pd, stage = 1, full_history = FALSE)
   3.   └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   4.     ├─...[]
   5.     └─data.table:::`[.data.table`(...)
  ── Error ('test-policy_learn-drql.R:361:3'): policy_learn with type = 'drql' uses the cross_fit_g_models argument ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 12/12 in VECTOR_ELT
  Backtrace:
      ▆
   1. └─polle::fit_g_functions(pd, list(g_empir(), g_empir()), full_history = FALSE) at test-policy_learn-drql.R:361:3
   2.   └─base::lapply(...)
   3.     └─polle (local) FUN(X[[i]], ...)
   4.       ├─polle::get_history(policy_data, stage = s, full_history = full_history)
   5.       └─polle:::get_history.policy_data(policy_data, stage = s, full_history = full_history)
   6.         └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   7.           ├─...[]
   8.           └─data.table:::`[.data.table`(...)
  ── Error ('test-policy_learn-drql.R:401:3'): policy_learn with type = 'drql' saves cross-fitted models. ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 11/11 in VECTOR_ELT
  Backtrace:
       ▆
    1. └─polle:::pl(pd, g_models = list(g_empir(), g_empir()), q_models = q_glm()) at test-policy_learn-drql.R:401:3
    2.   ├─base::do.call(what = call, args)
    3.   └─polle:::drql(...)
    4.     └─polle::fit_g_functions(policy_data, g_models = g_models, full_history = g_full_history)
    5.       └─base::lapply(...)
    6.         └─polle (local) FUN(X[[i]], ...)
    7.           ├─polle::get_history(policy_data, stage = s, full_history = full_history)
    8.           └─polle:::get_history.policy_data(policy_data, stage = s, full_history = full_history)
    9.             └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   10.               ├─...[]
   11.               └─data.table:::`[.data.table`(...)
  ── Error ('test-policy_learn-drql.R:457:3'): policy_learn with type drql handles multiple stages with varying stage action sets ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 12/12 in VECTOR_ELT
  Backtrace:
       ▆
    1. ├─base::suppressWarnings(...) at test-policy_learn-drql.R:457:3
    2. │ └─base::withCallingHandlers(...)
    3. └─polle::policy_eval(...)
    4.   ├─base::do.call(what = policy_eval_type, args = args)
    5.   └─polle (local) `<fn>`(...)
    6.     └─polle:::fit_functions(...)
    7.       └─polle::fit_g_functions(policy_data, g_models = g_models, full_history = g_full_history)
    8.         └─base::lapply(...)
    9.           └─polle (local) FUN(X[[i]], ...)
   10.             ├─polle::get_history(policy_data, stage = s, full_history = full_history)
   11.             └─polle:::get_history.policy_data(policy_data, stage = s, full_history = full_history)
   12.               └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   13.                 ├─...[]
   14.                 └─data.table:::`[.data.table`(...)
  ── Error ('test-policy_learn-owl.R:26:3'): the implementation of owl agrees with direct application of DTRlearn2::owl in the single stage case. ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 12/12 in VECTOR_ELT
  Backtrace:
       ▆
    1. └─polle:::pl(policy_data = pd1, g_models = g_glm()) at test-policy_learn-owl.R:26:3
    2.   ├─base::do.call(what = call, args)
    3.   └─polle:::dtrlearn2_owl(...)
    4.     ├─stats::predict(g_functions, policy_data)
    5.     └─polle:::predict.nuisance_functions(g_functions, policy_data)
    6.       └─base::lapply(...)
    7.         └─polle (local) FUN(X[[i]], ...)
    8.           ├─polle::get_history(...)
    9.           └─polle:::get_history.policy_data(...)
   10.             └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   11.               ├─...[]
   12.               └─data.table:::`[.data.table`(...)
  ── Error ('test-policy_learn-owl.R:69:3'): the implementation of owl agrees with direct application of DTRlearn2::owl in the two stage case. ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 11/11 in VECTOR_ELT
  Backtrace:
       ▆
    1. └─polle:::pl(...) at test-policy_learn-owl.R:69:3
    2.   ├─base::do.call(what = call, args)
    3.   └─polle:::dtrlearn2_owl(...)
    4.     └─polle::fit_g_functions(policy_data, g_models = g_models, full_history = g_full_history)
    5.       └─base::lapply(...)
    6.         └─polle (local) FUN(X[[i]], ...)
    7.           ├─polle::get_history(policy_data, stage = s, full_history = full_history)
    8.           └─polle:::get_history.policy_data(policy_data, stage = s, full_history = full_history)
    9.             └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   10.               ├─...[]
   11.               └─data.table:::`[.data.table`(...)
  ── Error ('test-policy_learn-owl.R:135:3'): policy_learn with type owl runs as intended ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 11/11 in VECTOR_ELT
  Backtrace:
      ▆
   1. └─polle:::pl(pd, g_models = g_glm(), q_models = q_glm()) at test-policy_learn-owl.R:135:3
   2.   ├─base::do.call(what = call, args)
   3.   └─polle:::dtrlearn2_owl(...)
   4.     ├─polle::get_history(policy_data, stage = k, full_history = full_history)
   5.     └─polle:::get_history.policy_data(policy_data, stage = k, full_history = full_history)
   6.       └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   7.         ├─...[]
   8.         └─data.table:::`[.data.table`(...)
  ── Failure ('test-policy_learn-ptl.R:9:3'): get_policy.ptl returns a policy ────
  `{ ... }` threw an error.
  Message: attempt access index 12/12 in VECTOR_ELT
  Class:   simpleError/error/condition
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-policy_learn-ptl.R:9:3
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat (local) .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. ├─polle::get_policy(pl(pd, q_models = q_glm(), g_models = g_glm())) at test-policy_learn-ptl.R:10:5
    7. └─polle:::pl(pd, q_models = q_glm(), g_models = g_glm())
    8.   ├─base::do.call(what = call, args)
    9.   └─polle:::ptl(...)
   10.     ├─stats::predict(g_functions, policy_data)
   11.     └─polle:::predict.nuisance_functions(g_functions, policy_data)
   12.       └─base::lapply(...)
   13.         └─polle (local) FUN(X[[i]], ...)
   14.           ├─polle::get_history(...)
   15.           └─polle:::get_history.policy_data(...)
   16.             └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   17.               ├─...[]
   18.               └─data.table:::`[.data.table`(...)
  ── Error ('test-policy_learn-ptl.R:15:3'): get_policy.ptl returns a policy ─────
  Error in `eval(code, test_env)`: object 'p' not found
  Backtrace:
      ▆
   1. ├─testthat::expect_true(inherits(p, what = "policy")) at test-policy_learn-ptl.R:15:3
   2. │ └─testthat::quasi_label(enquo(object), label)
   3. │   └─rlang::eval_bare(expr, quo_get_env(quo))
   4. └─base::inherits(p, what = "policy")
  ── Failure ('test-policy_learn-ptl.R:45:3'): policy_learn with type ptl works as intended ──
  `{ ... }` threw an error.
  Message: attempt access index 11/11 in VECTOR_ELT
  Class:   simpleError/error/condition
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-policy_learn-ptl.R:45:3
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat (local) .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─polle:::pl(policy_data = pd, g_models = g_glm(), q_models = q_glm()) at test-policy_learn-ptl.R:47:7
    7.   ├─base::do.call(what = call, args)
    8.   └─polle:::ptl(...)
    9.     └─polle:::q_step(...)
   10.       ├─polle::get_history(policy_data, stage = k, full_history = full_history)
   11.       └─polle:::get_history.policy_data(policy_data, stage = k, full_history = full_history)
   12.         └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   13.           ├─...[]
   14.           └─data.table:::`[.data.table`(...)
  ── Error ('test-policy_learn-ptl.R:56:3'): policy_learn with type ptl works as intended ──
  Error in `eval(code, test_env)`: object 'po' not found
  Backtrace:
      ▆
   1. ├─testthat::expect_s3_class(get_policy(po)(pd), "data.table") at test-policy_learn-ptl.R:56:3
   2. │ └─testthat::quasi_label(enquo(object))
   3. │   └─rlang::eval_bare(expr, quo_get_env(quo))
   4. └─polle::get_policy(po)
  ── Failure ('test-policy_learn-ptl.R:110:3'): policy_learn with type ptl handles varying action sets ──
  `po <- pl(pd, q_models = q_glm(), g_models = list(g_glm(), g_rf()))` threw an error.
  Message: attempt access index 12/12 in VECTOR_ELT
  Class:   simpleError/error/condition
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-policy_learn-ptl.R:110:3
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat (local) .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─polle:::pl(pd, q_models = q_glm(), g_models = list(g_glm(), g_rf()))
    7.   ├─base::do.call(what = call, args)
    8.   └─polle:::ptl(...)
    9.     └─polle::fit_g_functions(policy_data, g_models = g_models, full_history = g_full_history)
   10.       └─base::lapply(...)
   11.         └─polle (local) FUN(X[[i]], ...)
   12.           ├─polle::get_history(policy_data, stage = s, full_history = full_history)
   13.           └─polle:::get_history.policy_data(policy_data, stage = s, full_history = full_history)
   14.             └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   15.               ├─...[]
   16.               └─data.table:::`[.data.table`(...)
  ── Failure ('test-policy_learn-ptl.R:114:3'): policy_learn with type ptl handles varying action sets ──
  `pa <- get_policy(po)(pd)` threw an error.
  Message: object 'po' not found
  Class:   simpleError/error/condition
  Backtrace:
      ▆
   1. ├─testthat::expect_error(pa <- get_policy(po)(pd), NA) at test-policy_learn-ptl.R:114:3
   2. │ └─testthat:::quasi_capture(...)
   3. │   ├─testthat (local) .capture(...)
   4. │   │ └─base::withCallingHandlers(...)
   5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
   6. └─polle::get_policy(po)
  ── Failure ('test-policy_learn-ptl.R:119:3'): policy_learn with type ptl handles varying action sets ──
  `... <- NULL` threw an error.
  Message: object 'po' not found
  Class:   simpleError/error/condition
  Backtrace:
      ▆
   1. ├─testthat::expect_error(...) at test-policy_learn-ptl.R:119:3
   2. │ └─testthat:::quasi_capture(...)
   3. │   ├─testthat (local) .capture(...)
   4. │   │ └─base::withCallingHandlers(...)
   5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
   6. ├─polle::policy_eval(...)
   7. │ ├─base::as.list(environment())
   8. │ └─base::as.list.environment(environment())
   9. └─polle::get_policy(po)
  ── Failure ('test-policy_learn-ptl.R:147:3'): policy_learn with type ptl handles varying action sets ──
  `... <- NULL` threw an error.
  Message: attempt access index 12/12 in VECTOR_ELT
  Class:   simpleError/error/condition
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-policy_learn-ptl.R:147:3
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat (local) .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─polle (local) pl2(pd2, q_models = q_glm(), g_models = list(g_glm(), g_rf()))
    7.   ├─base::do.call(what = call, args)
    8.   └─polle:::ptl(...)
    9.     └─polle:::crossfit_function(...)
   10.       ├─base::do.call(what = future.apply::future_lapply, future_args)
   11.       └─future.apply (local) `<fn>`(future.seed = TRUE, X = `<named list>`, FUN = `<fn>`)
   12.         └─future.apply:::future_xapply(...)
   13.           └─base::tryCatch(...)
   14.             └─base (local) tryCatchList(expr, classes, parentenv, handlers)
   15.               └─base (local) tryCatchOne(...)
   16.                 └─value[[3L]](cond)
   17.                   └─future.apply:::onError(e, futures = fs, debug = debug)
  ── Failure ('test-policy_learn-ptl.R:151:3'): policy_learn with type ptl handles varying action sets ──
  `pa2 <- get_policy(po2)(pd2)` threw an error.
  Message: object 'po2' not found
  Class:   simpleError/error/condition
  Backtrace:
      ▆
   1. ├─testthat::expect_error(pa2 <- get_policy(po2)(pd2), NA) at test-policy_learn-ptl.R:151:3
   2. │ └─testthat:::quasi_capture(...)
   3. │   ├─testthat (local) .capture(...)
   4. │   │ └─base::withCallingHandlers(...)
   5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
   6. └─polle::get_policy(po2)
  ── Failure ('test-policy_learn-ptl.R:155:3'): policy_learn with type ptl handles varying action sets ──
  `... <- NULL` threw an error.
  Message: attempt access index 12/12 in VECTOR_ELT
  Class:   simpleError/error/condition
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-policy_learn-ptl.R:155:3
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat (local) .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─polle::policy_eval(...)
    7.   ├─base::do.call(what = policy_eval_type, args = args)
    8.   └─polle (local) `<fn>`(...)
    9.     └─polle:::fit_functions(...)
   10.       └─polle::fit_g_functions(policy_data, g_models = g_models, full_history = g_full_history)
   11.         └─base::lapply(...)
   12.           └─polle (local) FUN(X[[i]], ...)
   13.             ├─polle::get_history(policy_data, stage = s, full_history = full_history)
   14.             └─polle:::get_history.policy_data(policy_data, stage = s, full_history = full_history)
   15.               └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   16.                 ├─...[]
   17.                 └─data.table:::`[.data.table`(...)
  ── Failure ('test-policy_learn-ptl.R:163:3'): policy_learn with type ptl handles varying action sets ──
  `pf2_1 <- get_policy_functions(po2, stage = 1)` threw an error.
  Message: object 'po2' not found
  Class:   simpleError/error/condition
  Backtrace:
      ▆
   1. ├─testthat::expect_error(...) at test-policy_learn-ptl.R:163:3
   2. │ └─testthat:::quasi_capture(...)
   3. │   ├─testthat (local) .capture(...)
   4. │   │ └─base::withCallingHandlers(...)
   5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
   6. └─polle::get_policy_functions(po2, stage = 1)
  ── Error ('test-policy_learn-ptl.R:167:3'): policy_learn with type ptl handles varying action sets ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 12/12 in VECTOR_ELT
  Backtrace:
      ▆
   1. ├─polle::get_history(pd2, stage = 1) at test-policy_learn-ptl.R:167:3
   2. └─polle:::get_history.policy_data(pd2, stage = 1)
   3.   └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   4.     ├─...[]
   5.     └─data.table:::`[.data.table`(...)
  ── Failure ('test-policy_learn-ptl.R:208:3'): policy_learn with type = 'ptl' works with thresholds. ──
  Expected `po <- pl(policy_data = pd, g_models = g_glm(), q_models = q_glm())` not to throw any errors.
  Actually got a <simpleError> with message:
    attempt access index 11/11 in VECTOR_ELT
  ── Failure ('test-policy_learn-ptl.R:216:3'): policy_learn with type = 'ptl' works with thresholds. ──
  Expected `pf <- get_policy(po)` not to throw any errors.
  Actually got a <simpleError> with message:
    object 'po' not found
  ── Failure ('test-policy_learn-ptl.R:220:3'): policy_learn with type = 'ptl' works with thresholds. ──
  Expected `unlist(lapply(pf, function(x) attr(x, "name")))` to equal `paste0("ptl(eta=", c(0, 0.5, 1), ")")`.
  Differences:
  target is NULL, current is character
  ── Failure ('test-policy_learn-ptl.R:225:3'): policy_learn with type = 'ptl' works with thresholds. ──
  `pf <- get_policy(po, threshold = 2)` threw an error with unexpected message.
  Expected match: "Invalid threshold. Choose between 0, 0.5, 1"
  Actual message: "object 'po' not found"
  Backtrace:
      ▆
   1. ├─testthat::expect_error(pf <- get_policy(po, threshold = 2), "Invalid threshold. Choose between 0, 0.5, 1") at test-policy_learn-ptl.R:225:3
   2. │ └─testthat:::quasi_capture(...)
   3. │   ├─testthat (local) .capture(...)
   4. │   │ └─base::withCallingHandlers(...)
   5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
   6. └─polle::get_policy(po, threshold = 2)
  ── Failure ('test-policy_learn-ptl.R:230:3'): policy_learn with type = 'ptl' works with thresholds. ──
  Expected `pf <- get_policy(po, threshold = 0.5)` not to throw any errors.
  Actually got a <simpleError> with message:
    object 'po' not found
  ── Error ('test-policy_learn-ptl.R:234:3'): policy_learn with type = 'ptl' works with thresholds. ──
  <getvarError/missingArgError/error/condition>
  Error in `pf(pd)`: argument "df1" is missing, with no default
  Backtrace:
      ▆
   1. ├─testthat::expect_true(...) at test-policy_learn-ptl.R:234:3
   2. │ └─testthat::quasi_label(enquo(object), label)
   3. │   └─rlang::eval_bare(expr, quo_get_env(quo))
   4. ├─data.table::is.data.table(pf(pd))
   5. └─stats::pf(pd)
  ── Error ('test-policy_learn-ptl.R:263:3'): get_policy and get_policy_functions agree with type ptl and a non-zero threshold argument, ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 11/11 in VECTOR_ELT
  Backtrace:
      ▆
   1. └─polle:::pl(pd, q_models = q_glm(), g_models = g_glm()) at test-policy_learn-ptl.R:263:3
   2.   ├─base::do.call(what = call, args)
   3.   └─polle:::ptl(...)
   4.     └─polle:::q_step(...)
   5.       ├─polle::get_history(policy_data, stage = k, full_history = full_history)
   6.       └─polle:::get_history.policy_data(policy_data, stage = k, full_history = full_history)
   7.         └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   8.           ├─...[]
   9.           └─data.table:::`[.data.table`(...)
  ── Failure ('test-policy_learn-ql.R:10:3'): get_policy.ql returns a policy ─────
  `{ ... }` threw an error.
  Message: attempt access index 12/12 in VECTOR_ELT
  Class:   simpleError/error/condition
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-policy_learn-ql.R:10:3
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat (local) .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. ├─polle::get_policy(pl(pd, q_models = q_glm())) at test-policy_learn-ql.R:12:7
    7. └─polle:::pl(pd, q_models = q_glm())
    8.   ├─base::do.call(what = call, args)
    9.   └─polle:::rql(...)
   10.     └─polle:::q_step(...)
   11.       ├─polle::get_history(policy_data, stage = k, full_history = full_history)
   12.       └─polle:::get_history.policy_data(policy_data, stage = k, full_history = full_history)
   13.         └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   14.           ├─...[]
   15.           └─data.table:::`[.data.table`(...)
  ── Error ('test-policy_learn-ql.R:16:3'): get_policy.ql returns a policy ───────
  Error in `eval(code, test_env)`: object 'p' not found
  Backtrace:
      ▆
   1. ├─testthat::expect_true(inherits(p, what = "policy")) at test-policy_learn-ql.R:16:3
   2. │ └─testthat::quasi_label(enquo(object), label)
   3. │   └─rlang::eval_bare(expr, quo_get_env(quo))
   4. └─base::inherits(p, what = "policy")
  ── Error ('test-policy_learn-ql.R:36:3'): get_policy_functions.ql agrees with get_policy.ql ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 11/11 in VECTOR_ELT
  Backtrace:
      ▆
   1. └─polle:::pl(pd, q_models = q_glm()) at test-policy_learn-ql.R:36:3
   2.   ├─base::do.call(what = call, args)
   3.   └─polle:::rql(...)
   4.     └─polle:::q_step(...)
   5.       ├─polle::get_history(policy_data, stage = k, full_history = full_history)
   6.       └─polle:::get_history.policy_data(policy_data, stage = k, full_history = full_history)
   7.         └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   8.           ├─...[]
   9.           └─data.table:::`[.data.table`(...)
  ── Error ('test-policy_learn-ql.R:113:3'): get_policy_functions.ql handles deterministic rewards ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 11/11 in VECTOR_ELT
  Backtrace:
      ▆
   1. └─polle:::pl(pd, q_models = q_glm()) at test-policy_learn-ql.R:113:3
   2.   ├─base::do.call(what = call, args)
   3.   └─polle:::rql(...)
   4.     └─polle:::q_step(...)
   5.       ├─polle::get_history(policy_data, stage = k, full_history = full_history)
   6.       └─polle:::get_history.policy_data(policy_data, stage = k, full_history = full_history)
   7.         └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   8.           ├─...[]
   9.           └─data.table:::`[.data.table`(...)
  ── Error ('test-policy_learn-ql.R:186:3'): get_policy_functions.ql handles partially missing deterministic rewards ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 11/11 in VECTOR_ELT
  Backtrace:
      ▆
   1. └─polle:::pl(pd, q_models = q_glm()) at test-policy_learn-ql.R:186:3
   2.   ├─base::do.call(what = call, args)
   3.   └─polle:::rql(...)
   4.     └─polle:::q_step(...)
   5.       ├─polle::get_history(policy_data, stage = k, full_history = full_history)
   6.       └─polle:::get_history.policy_data(policy_data, stage = k, full_history = full_history)
   7.         └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   8.           ├─...[]
   9.           └─data.table:::`[.data.table`(...)
  ── Error ('test-policy_learn-ql.R:255:3'): get_policy_functions.ql handles realistic actions ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 11/11 in VECTOR_ELT
  Backtrace:
      ▆
   1. └─polle:::pl(pd, q_models = q_glm(), g_models = g_glm()) at test-policy_learn-ql.R:255:3
   2.   ├─base::do.call(what = call, args)
   3.   └─polle:::rql(...)
   4.     └─polle:::q_step(...)
   5.       ├─polle::get_history(policy_data, stage = k, full_history = full_history)
   6.       └─polle:::get_history.policy_data(policy_data, stage = k, full_history = full_history)
   7.         └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   8.           ├─...[]
   9.           └─data.table:::`[.data.table`(...)
  ── Error ('test-policy_learn-ql.R:327:3'): get_policy_functions.ql handles varying stage action set ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 12/12 in VECTOR_ELT
  Backtrace:
       ▆
    1. └─polle:::pl(pd, q_models = q_glm(), g_models = list(g_glm(), g_empir())) at test-policy_learn-ql.R:327:3
    2.   ├─base::do.call(what = call, args)
    3.   └─polle:::rql(...)
    4.     └─polle::fit_g_functions(policy_data, g_models = g_models, full_history = g_full_history)
    5.       └─base::lapply(...)
    6.         └─polle (local) FUN(X[[i]], ...)
    7.           ├─polle::get_history(policy_data, stage = s, full_history = full_history)
    8.           └─polle:::get_history.policy_data(policy_data, stage = s, full_history = full_history)
    9.             └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   10.               ├─...[]
   11.               └─data.table:::`[.data.table`(...)
  ── Failure ('test-policy_learn-ql.R:369:3'): policy_learn with type = 'ql' works as intended ──
  `ql(policy_data = pd, q_models = q_glm())` threw an error.
  Message: attempt access index 11/11 in VECTOR_ELT
  Class:   simpleError/error/condition
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-policy_learn-ql.R:369:3
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat (local) .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─polle (local) ql(policy_data = pd, q_models = q_glm())
    7.   ├─base::do.call(what = call, args)
    8.   └─polle:::rql(...)
    9.     └─polle:::q_step(...)
   10.       ├─polle::get_history(policy_data, stage = k, full_history = full_history)
   11.       └─polle:::get_history.policy_data(policy_data, stage = k, full_history = full_history)
   12.         └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   13.           ├─...[]
   14.           └─data.table:::`[.data.table`(...)
  ── Failure ('test-policy_learn-ql.R:373:3'): policy_learn with type = 'ql' works as intended ──
  `ql(policy_data = pd, q_models = list(q_glm(), q_glm()))` threw an error.
  Message: attempt access index 11/11 in VECTOR_ELT
  Class:   simpleError/error/condition
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-policy_learn-ql.R:373:3
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat (local) .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─polle (local) ql(policy_data = pd, q_models = list(q_glm(), q_glm()))
    7.   ├─base::do.call(what = call, args)
    8.   └─polle:::rql(...)
    9.     └─polle:::q_step(...)
   10.       ├─polle::get_history(policy_data, stage = k, full_history = full_history)
   11.       └─polle:::get_history.policy_data(policy_data, stage = k, full_history = full_history)
   12.         └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   13.           ├─...[]
   14.           └─data.table:::`[.data.table`(...)
  ── Failure ('test-policy_learn-ql.R:387:3'): policy_learn with type = 'ql' works as intended ──
  `{ ... }` threw an error.
  Message: attempt access index 11/11 in VECTOR_ELT
  Class:   simpleError/error/condition
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-policy_learn-ql.R:387:3
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat (local) .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─polle (local) ql(policy_data = pd, q_models = q_glm(), g_glm()) at test-policy_learn-ql.R:388:5
    7.   ├─base::do.call(what = call, args)
    8.   └─polle:::rql(...)
    9.     └─polle:::q_step(...)
   10.       ├─polle::get_history(policy_data, stage = k, full_history = full_history)
   11.       └─polle:::get_history.policy_data(policy_data, stage = k, full_history = full_history)
   12.         └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   13.           ├─...[]
   14.           └─data.table:::`[.data.table`(...)
  ── Failure ('test-policy_learn-ql.R:391:3'): policy_learn with type = 'ql' works as intended ──
  `{ ... }` threw an error.
  Message: object 'po' not found
  Class:   simpleError/error/condition
  Backtrace:
      ▆
   1. ├─testthat::expect_error(...) at test-policy_learn-ql.R:391:3
   2. │ └─testthat:::quasi_capture(...)
   3. │   ├─testthat (local) .capture(...)
   4. │   │ └─base::withCallingHandlers(...)
   5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
   6. └─polle::get_policy(po) at test-policy_learn-ql.R:392:5
  ── Error ('test-policy_learn-ql.R:395:3'): policy_learn with type = 'ql' works as intended ──
  Error in `p(pd)`: could not find function "p"
  Backtrace:
      ▆
   1. └─testthat::expect_s3_class(p(pd), class = "data.table") at test-policy_learn-ql.R:395:3
   2.   └─testthat::quasi_label(enquo(object))
   3.     └─rlang::eval_bare(expr, quo_get_env(quo))
  ── Failure ('test-policy_learn-ql.R:412:3'): policy_learn with type ql handles varying action sets ──
  `po <- pl(pd, q_models = q_glm())` threw an error.
  Message: attempt access index 12/12 in VECTOR_ELT
  Class:   simpleError/error/condition
  Backtrace:
       ▆
    1. ├─testthat::expect_error(po <- pl(pd, q_models = q_glm()), NA) at test-policy_learn-ql.R:412:3
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat (local) .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─polle:::pl(pd, q_models = q_glm())
    7.   ├─base::do.call(what = call, args)
    8.   └─polle:::rql(...)
    9.     └─polle:::q_step(...)
   10.       ├─polle::get_history(policy_data, stage = k, full_history = full_history)
   11.       └─polle:::get_history.policy_data(policy_data, stage = k, full_history = full_history)
   12.         └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   13.           ├─...[]
   14.           └─data.table:::`[.data.table`(...)
  ── Failure ('test-policy_learn-ql.R:416:3'): policy_learn with type ql handles varying action sets ──
  `pa <- get_policy(po)(pd)` threw an error.
  Message: object 'po' not found
  Class:   simpleError/error/condition
  Backtrace:
      ▆
   1. ├─testthat::expect_error(pa <- get_policy(po)(pd), NA) at test-policy_learn-ql.R:416:3
   2. │ └─testthat:::quasi_capture(...)
   3. │   ├─testthat (local) .capture(...)
   4. │   │ └─base::withCallingHandlers(...)
   5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
   6. └─polle::get_policy(po)
  ── Failure ('test-policy_learn-ql.R:420:3'): policy_learn with type ql handles varying action sets ──
  `... <- NULL` threw an error.
  Message: object 'po' not found
  Class:   simpleError/error/condition
  Backtrace:
      ▆
   1. ├─testthat::expect_error(...) at test-policy_learn-ql.R:420:3
   2. │ └─testthat:::quasi_capture(...)
   3. │   ├─testthat (local) .capture(...)
   4. │   │ └─base::withCallingHandlers(...)
   5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
   6. ├─polle::policy_eval(...)
   7. │ ├─base::as.list(environment())
   8. │ └─base::as.list.environment(environment())
   9. └─polle::get_policy(po)
  ── Failure ('test-policy_learn.R:39:3'): policy_learn checks input ─────────────
  `policy_eval(pd, policy_learn = policy_learn(type = "ql", alpha = 0))` threw an error.
  Message: attempt access index 12/12 in VECTOR_ELT
  Class:   simpleError/error/condition
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-policy_learn.R:39:3
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat (local) .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─polle::policy_eval(...)
    7.   ├─base::do.call(what = policy_eval_type, args = args)
    8.   └─polle (local) `<fn>`(...)
    9.     └─polle:::fit_functions(...)
   10.       └─polle::policy_learn(...)
   11.         ├─base::do.call(what = call, args)
   12.         └─polle:::rql(...)
   13.           └─polle:::q_step(...)
   14.             ├─polle::get_history(policy_data, stage = k, full_history = full_history)
   15.             └─polle:::get_history.policy_data(policy_data, stage = k, full_history = full_history)
   16.               └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   17.                 ├─...[]
   18.                 └─data.table:::`[.data.table`(...)
  ── Failure ('test-policy_learn.R:45:3'): policy_learn checks input ─────────────
  `policy_eval(pd, policy_learn = policy_learn(type = "ql", alpha = 0.1))` threw an error.
  Message: attempt access index 12/12 in VECTOR_ELT
  Class:   simpleError/error/condition
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-policy_learn.R:45:3
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat (local) .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─polle::policy_eval(...)
    7.   ├─base::do.call(what = policy_eval_type, args = args)
    8.   └─polle (local) `<fn>`(...)
    9.     └─polle:::fit_functions(...)
   10.       └─polle::policy_learn(...)
   11.         ├─base::do.call(what = call, args)
   12.         └─polle:::rql(...)
   13.           ├─stats::predict(g_functions, policy_data)
   14.           └─polle:::predict.nuisance_functions(g_functions, policy_data)
   15.             └─base::lapply(...)
   16.               └─polle (local) FUN(X[[i]], ...)
   17.                 ├─polle::get_history(...)
   18.                 └─polle:::get_history.policy_data(...)
   19.                   └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   20.                     ├─...[]
   21.                     └─data.table:::`[.data.table`(...)
  ── Failure ('test-policy_learn.R:53:3'): policy_learn checks input ─────────────
  `policy_eval(pd, policy_learn = policy_learn(type = "ql", full_history = TRUE))` threw an error.
  Message: attempt access index 12/12 in VECTOR_ELT
  Class:   simpleError/error/condition
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-policy_learn.R:53:3
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat (local) .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─polle::policy_eval(...)
    7.   ├─base::do.call(what = policy_eval_type, args = args)
    8.   └─polle (local) `<fn>`(...)
    9.     └─polle:::fit_functions(...)
   10.       └─polle::policy_learn(...)
   11.         ├─base::do.call(what = call, args)
   12.         └─polle:::rql(...)
   13.           └─polle:::q_step(...)
   14.             ├─polle::get_history(policy_data, stage = k, full_history = full_history)
   15.             └─polle:::get_history.policy_data(policy_data, stage = k, full_history = full_history)
   16.               └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   17.                 ├─...[]
   18.                 └─data.table:::`[.data.table`(...)
  ── Failure ('test-policy_learn.R:59:3'): policy_learn checks input ─────────────
  `policy_eval(pd, policy_learn = policy_learn(type = "ql", full_history = FALSE))` threw an error.
  Message: attempt access index 12/12 in VECTOR_ELT
  Class:   simpleError/error/condition
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-policy_learn.R:59:3
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat (local) .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─polle::policy_eval(...)
    7.   ├─base::do.call(what = policy_eval_type, args = args)
    8.   └─polle (local) `<fn>`(...)
    9.     └─polle:::fit_functions(...)
   10.       └─polle::policy_learn(...)
   11.         ├─base::do.call(what = call, args)
   12.         └─polle:::rql(...)
   13.           └─polle:::q_step(...)
   14.             ├─polle::get_history(policy_data, stage = k, full_history = full_history)
   15.             └─polle:::get_history.policy_data(policy_data, stage = k, full_history = full_history)
   16.               └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   17.                 ├─...[]
   18.                 └─data.table:::`[.data.table`(...)
  ── Failure ('test-policy_learn.R:294:3'): policy_learn() does not run with missing outcomes for drql, rql, ptl, earl, rwl, owl. ──
  `... <- NULL` threw an error with unexpected message.
  Expected match: "policy learning with type 'drql' not implemented under right-censoring/missing outcomes."
  Actual message: "attempt access index 12/12 in VECTOR_ELT"
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-policy_learn.R:294:3
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat (local) .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─polle::policy_eval(...)
    7.   ├─base::do.call(what = policy_eval_type, args = args)
    8.   └─polle (local) `<fn>`(...)
    9.     └─polle:::fit_functions(...)
   10.       └─polle:::fit_m_function(policy_data, m_model = m_model, full_history = m_full_history)
   11.         ├─polle::get_history(...)
   12.         └─polle:::get_history.policy_data(...)
   13.           └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   14.             ├─...[]
   15.             └─data.table:::`[.data.table`(...)
  ── Failure ('test-policy_learn.R:305:3'): policy_learn() does not run with missing outcomes for drql, rql, ptl, earl, rwl, owl. ──
  `... <- NULL` threw an error with unexpected message.
  Expected match: "policy learning with type 'rql' not implemented under right-censoring/missing outcomes."
  Actual message: "attempt access index 12/12 in VECTOR_ELT"
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-policy_learn.R:305:3
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat (local) .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─polle::policy_eval(...)
    7.   ├─base::do.call(what = policy_eval_type, args = args)
    8.   └─polle (local) `<fn>`(...)
    9.     └─polle:::fit_functions(...)
   10.       └─polle:::fit_m_function(policy_data, m_model = m_model, full_history = m_full_history)
   11.         ├─polle::get_history(...)
   12.         └─polle:::get_history.policy_data(...)
   13.           └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   14.             ├─...[]
   15.             └─data.table:::`[.data.table`(...)
  ── Failure ('test-policy_learn.R:316:3'): policy_learn() does not run with missing outcomes for drql, rql, ptl, earl, rwl, owl. ──
  `... <- NULL` threw an error with unexpected message.
  Expected match: "policy learning with type 'ptl' not implemented under right-censoring/missing outcomes."
  Actual message: "attempt access index 12/12 in VECTOR_ELT"
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-policy_learn.R:316:3
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat (local) .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─polle::policy_eval(...)
    7.   ├─base::do.call(what = policy_eval_type, args = args)
    8.   └─polle (local) `<fn>`(...)
    9.     └─polle:::fit_functions(...)
   10.       └─polle:::fit_m_function(policy_data, m_model = m_model, full_history = m_full_history)
   11.         ├─polle::get_history(...)
   12.         └─polle:::get_history.policy_data(...)
   13.           └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   14.             ├─...[]
   15.             └─data.table:::`[.data.table`(...)
  ── Failure ('test-policy_learn.R:327:3'): policy_learn() does not run with missing outcomes for drql, rql, ptl, earl, rwl, owl. ──
  `... <- NULL` threw an error with unexpected message.
  Expected match: "policy learning with type 'earl' not implemented under right-censoring/missing outcomes."
  Actual message: "attempt access index 12/12 in VECTOR_ELT"
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-policy_learn.R:327:3
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat (local) .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─polle::policy_eval(...)
    7.   ├─base::do.call(what = policy_eval_type, args = args)
    8.   └─polle (local) `<fn>`(...)
    9.     └─polle:::fit_functions(...)
   10.       └─polle:::fit_m_function(policy_data, m_model = m_model, full_history = m_full_history)
   11.         ├─polle::get_history(...)
   12.         └─polle:::get_history.policy_data(...)
   13.           └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   14.             ├─...[]
   15.             └─data.table:::`[.data.table`(...)
  ── Failure ('test-policy_learn.R:338:3'): policy_learn() does not run with missing outcomes for drql, rql, ptl, earl, rwl, owl. ──
  `... <- NULL` threw an error with unexpected message.
  Expected match: "policy learning with type 'rwl' not implemented under right-censoring/missing outcomes."
  Actual message: "attempt access index 12/12 in VECTOR_ELT"
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-policy_learn.R:338:3
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat (local) .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─polle::policy_eval(...)
    7.   ├─base::do.call(what = policy_eval_type, args = args)
    8.   └─polle (local) `<fn>`(...)
    9.     └─polle:::fit_functions(...)
   10.       └─polle:::fit_m_function(policy_data, m_model = m_model, full_history = m_full_history)
   11.         ├─polle::get_history(...)
   12.         └─polle:::get_history.policy_data(...)
   13.           └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   14.             ├─...[]
   15.             └─data.table:::`[.data.table`(...)
  ── Failure ('test-policy_learn.R:349:3'): policy_learn() does not run with missing outcomes for drql, rql, ptl, earl, rwl, owl. ──
  `... <- NULL` threw an error with unexpected message.
  Expected match: "policy learning with type 'owl' not implemented under right-censoring/missing outcomes."
  Actual message: "attempt access index 12/12 in VECTOR_ELT"
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-policy_learn.R:349:3
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat (local) .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─polle::policy_eval(...)
    7.   ├─base::do.call(what = policy_eval_type, args = args)
    8.   └─polle (local) `<fn>`(...)
    9.     └─polle:::fit_functions(...)
   10.       └─polle:::fit_m_function(policy_data, m_model = m_model, full_history = m_full_history)
   11.         ├─polle::get_history(...)
   12.         └─polle:::get_history.policy_data(...)
   13.           └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   14.             ├─...[]
   15.             └─data.table:::`[.data.table`(...)
  ── Error ('test-q_glmnet.R:9:3'): predict.q_glmnet return a vector ─────────────
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 12/12 in VECTOR_ELT
  Backtrace:
      ▆
   1. ├─polle::get_history(pd, stage = 1) at test-q_glmnet.R:9:3
   2. └─polle:::get_history.policy_data(pd, stage = 1)
   3.   └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   4.     ├─...[]
   5.     └─data.table:::`[.data.table`(...)
  ── Failure ('test-q_glmnet.R:33:5'): q_glmnet formats data correctly via the formula ──
  `... <- NULL` threw an error.
  Message: attempt access index 13/13 in VECTOR_ELT
  Class:   simpleError/error/condition
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-q_glmnet.R:33:5
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat (local) .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─polle::policy_eval(...)
    7.   ├─base::do.call(what = policy_eval_type, args = args)
    8.   └─polle (local) `<fn>`(...)
    9.     └─polle:::fit_functions(...)
   10.       └─polle::policy_learn(...)
   11.         ├─base::do.call(what = call, args)
   12.         └─polle:::rql(...)
   13.           ├─stats::predict(g_functions, policy_data)
   14.           └─polle:::predict.nuisance_functions(g_functions, policy_data)
   15.             └─base::lapply(...)
   16.               └─polle (local) FUN(X[[i]], ...)
   17.                 ├─polle::get_history(...)
   18.                 └─polle:::get_history.policy_data(...)
   19.                   └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   20.                     ├─...[]
   21.                     └─data.table:::`[.data.table`(...)
  ── Failure ('test-q_glmnet.R:70:5'): q_glmnet handles missing covariates ───────
  `policy_eval(...)` threw an error.
  Message: attempt access index 11/11 in VECTOR_ELT
  Class:   simpleError/error/condition
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-q_glmnet.R:70:5
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat (local) .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─polle::policy_eval(...)
    7.   ├─base::do.call(what = policy_eval_type, args = args)
    8.   └─polle (local) `<fn>`(...)
    9.     └─polle:::fit_functions(...)
   10.       └─polle (local) policy(policy_data = policy_data)
   11.         └─base::lapply(...)
   12.           └─polle (local) FUN(X[[i]], ...)
   13.             ├─polle::get_history(...)
   14.             └─polle:::get_history.policy_data(...)
   15.               └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   16.                 ├─...[]
   17.                 └─data.table:::`[.data.table`(...)
  ── Failure ('test-q_glmnet.R:79:5'): q_glmnet handles missing covariates ───────
  `policy_eval(...)` threw an error.
  Message: attempt access index 11/11 in VECTOR_ELT
  Class:   simpleError/error/condition
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-q_glmnet.R:79:5
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat (local) .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─polle::policy_eval(...)
    7.   ├─base::do.call(what = policy_eval_type, args = args)
    8.   └─polle (local) `<fn>`(...)
    9.     └─polle:::fit_functions(...)
   10.       └─polle (local) policy(policy_data = policy_data)
   11.         └─base::lapply(...)
   12.           └─polle (local) FUN(X[[i]], ...)
   13.             ├─polle::get_history(...)
   14.             └─polle:::get_history.policy_data(...)
   15.               └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   16.                 ├─...[]
   17.                 └─data.table:::`[.data.table`(...)
  ── Error ('test-q_glmnet.R:156:3'): testing that q_glmnet returns the prediction associated with lambda.min ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 11/11 in VECTOR_ELT
  Backtrace:
       ▆
    1. └─polle:::pl(...) at test-q_glmnet.R:156:3
    2.   ├─base::do.call(what = call, args)
    3.   └─polle:::blip(...)
    4.     ├─stats::predict(g_functions, policy_data)
    5.     └─polle:::predict.nuisance_functions(g_functions, policy_data)
    6.       └─base::lapply(...)
    7.         └─polle (local) FUN(X[[i]], ...)
    8.           ├─polle::get_history(...)
    9.           └─polle:::get_history.policy_data(...)
   10.             └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   11.               ├─...[]
   12.               └─data.table:::`[.data.table`(...)
  ── Failure ('test-q_models.R:18:3'): fit_q_functions handles varying stage-action sets ──
  `... <- NULL` threw an error.
  Message: attempt access index 12/12 in VECTOR_ELT
  Class:   simpleError/error/condition
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-q_models.R:18:3
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat (local) .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─polle:::fit_Q_functions(...)
    7.   └─polle:::q_step(...)
    8.     ├─polle::get_history(policy_data, stage = k, full_history = full_history)
    9.     └─polle:::get_history.policy_data(policy_data, stage = k, full_history = full_history)
   10.       └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   11.         ├─...[]
   12.         └─data.table:::`[.data.table`(...)
  ── Failure ('test-q_models.R:22:3'): fit_q_functions handles varying stage-action sets ──
  `tmp <- predict(qfit, pd)` threw an error.
  Message: object 'qfit' not found
  Class:   simpleError/error/condition
  Backtrace:
      ▆
   1. ├─testthat::expect_error(tmp <- predict(qfit, pd), NA) at test-q_models.R:22:3
   2. │ └─testthat:::quasi_capture(...)
   3. │   ├─testthat (local) .capture(...)
   4. │   │ └─base::withCallingHandlers(...)
   5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
   6. └─stats::predict(qfit, pd)
  ── Error ('test-q_models.R:27:3'): fit_q_functions handles varying stage-action sets ──
  Error in `eval(code, test_env)`: object 'qfit' not found
  Backtrace:
      ▆
   1. └─stats::predict(...) at test-q_models.R:27:3
  ── Failure ('test-q_models.R:55:3'): q_models checks formula input ─────────────
  `policy_eval(...)` threw an error with unexpected message.
  Expected match: "variable 'X' is not found in data when calling 'q_glm' with formula: ~X"
  Actual message: "attempt access index 11/11 in VECTOR_ELT"
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-q_models.R:55:3
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat (local) .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─polle::policy_eval(...)
    7.   ├─base::do.call(what = policy_eval_type, args = args)
    8.   └─polle (local) `<fn>`(...)
    9.     └─polle:::fit_functions(...)
   10.       └─polle (local) policy(policy_data = policy_data)
   11.         └─base::lapply(...)
   12.           └─polle (local) FUN(X[[i]], ...)
   13.             ├─polle::get_history(...)
   14.             └─polle:::get_history.policy_data(...)
   15.               └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   16.                 ├─...[]
   17.                 └─data.table:::`[.data.table`(...)
  ── Failure ('test-q_models.R:59:3'): q_models checks formula input ─────────────
  Expected `policy_eval(policy_data = pd, policy = p_dynamic, q_models = q_glm(formula = ~ns(C)))` not to throw any errors.
  Actually got a <simpleError> with message:
    attempt access index 11/11 in VECTOR_ELT
  ── Failure ('test-q_models.R:64:3'): q_models checks formula input ─────────────
  `policy_eval(...)` threw an error with unexpected message.
  Expected match: "variable 'X' is not found in data when calling 'q_xgboost' with formula: ~X"
  Actual message: "attempt access index 11/11 in VECTOR_ELT"
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-q_models.R:64:3
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat (local) .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─polle::policy_eval(...)
    7.   ├─base::do.call(what = policy_eval_type, args = args)
    8.   └─polle (local) `<fn>`(...)
    9.     └─polle:::fit_functions(...)
   10.       └─polle (local) policy(policy_data = policy_data)
   11.         └─base::lapply(...)
   12.           └─polle (local) FUN(X[[i]], ...)
   13.             ├─polle::get_history(...)
   14.             └─polle:::get_history.policy_data(...)
   15.               └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   16.                 ├─...[]
   17.                 └─data.table:::`[.data.table`(...)
  ── Failure ('test-q_models.R:84:3'): q_models checks formula input 2 ───────────
  `po <- pl(pd, q_models = q_glm(), g_models = g_glm())` threw an error with unexpected message.
  Expected match: "Error in blip_model: variable 'A' is not found in data when calling 'q_glm' with formula: ~A \\+ Z \\+ B \\+ L \\+ A:Z \\+ A:B \\+ A:L"
  Actual message: "attempt access index 12/12 in VECTOR_ELT"
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-q_models.R:84:3
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat (local) .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─polle:::pl(pd, q_models = q_glm(), g_models = g_glm())
    7.   ├─base::do.call(what = call, args)
    8.   └─polle:::blip(...)
    9.     ├─stats::predict(g_functions, policy_data)
   10.     └─polle:::predict.nuisance_functions(g_functions, policy_data)
   11.       └─base::lapply(...)
   12.         └─polle (local) FUN(X[[i]], ...)
   13.           ├─polle::get_history(...)
   14.           └─polle:::get_history.policy_data(...)
   15.             └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   16.               ├─...[]
   17.               └─data.table:::`[.data.table`(...)
  ── Failure ('test-q_models.R:96:3'): q_models checks formula input 2 ───────────
  `po <- pl(pd, q_models = q_glm(), g_models = g_glm())` threw an error with unexpected message.
  Expected match: "Error in blip_model: variable 'A' is not found in data when calling 'q_glm' with formula: ~A \\+ Z \\+ B \\+ L \\+ A:Z \\+ A:B \\+ A:L"
  Actual message: "attempt access index 12/12 in VECTOR_ELT"
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-q_models.R:96:3
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat (local) .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─polle:::pl(pd, q_models = q_glm(), g_models = g_glm())
    7.   ├─base::do.call(what = call, args)
    8.   └─polle:::blip(...)
    9.     ├─stats::predict(g_functions, policy_data)
   10.     └─polle:::predict.nuisance_functions(g_functions, policy_data)
   11.       └─base::lapply(...)
   12.         └─polle (local) FUN(X[[i]], ...)
   13.           ├─polle::get_history(...)
   14.           └─polle:::get_history.policy_data(...)
   15.             └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   16.               ├─...[]
   17.               └─data.table:::`[.data.table`(...)
  ── Failure ('test-q_models.R:111:3'): q_rf formats data correctly via the formula ──
  `... <- NULL` threw an error.
  Message: attempt access index 13/13 in VECTOR_ELT
  Class:   simpleError/error/condition
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-q_models.R:111:3
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat (local) .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─polle::policy_eval(...)
    7.   ├─base::do.call(what = policy_eval_type, args = args)
    8.   └─polle (local) `<fn>`(...)
    9.     └─polle:::fit_functions(...)
   10.       └─polle::policy_learn(...)
   11.         ├─base::do.call(what = call, args)
   12.         └─polle:::rql(...)
   13.           ├─stats::predict(g_functions, policy_data)
   14.           └─polle:::predict.nuisance_functions(g_functions, policy_data)
   15.             └─base::lapply(...)
   16.               └─polle (local) FUN(X[[i]], ...)
   17.                 ├─polle::get_history(...)
   18.                 └─polle:::get_history.policy_data(...)
   19.                   └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   20.                     ├─...[]
   21.                     └─data.table:::`[.data.table`(...)
  ── Failure ('test-q_models.R:131:3'): q_sl formats data correctly via the formula ──
  `... <- NULL` threw an error.
  Message: attempt access index 13/13 in VECTOR_ELT
  Class:   simpleError/error/condition
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-q_models.R:131:3
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat (local) .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─polle::policy_eval(...)
    7.   ├─base::do.call(what = policy_eval_type, args = args)
    8.   └─polle (local) `<fn>`(...)
    9.     └─polle:::fit_functions(...)
   10.       └─polle::policy_learn(...)
   11.         ├─base::do.call(what = call, args)
   12.         └─polle:::rql(...)
   13.           ├─stats::predict(g_functions, policy_data)
   14.           └─polle:::predict.nuisance_functions(g_functions, policy_data)
   15.             └─base::lapply(...)
   16.               └─polle (local) FUN(X[[i]], ...)
   17.                 ├─polle::get_history(...)
   18.                 └─polle:::get_history.policy_data(...)
   19.                   └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   20.                     ├─...[]
   21.                     └─data.table:::`[.data.table`(...)
  ── Failure ('test-q_models.R:174:3'): q_sl can find user-defined learners ──────
  `... <- NULL` threw an error.
  Message: attempt access index 13/13 in VECTOR_ELT
  Class:   simpleError/error/condition
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-q_models.R:174:3
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat (local) .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─polle:::fit_Q_functions(...)
    7.   └─polle:::q_step(...)
    8.     ├─polle::get_history(policy_data, stage = k, full_history = full_history)
    9.     └─polle:::get_history.policy_data(policy_data, stage = k, full_history = full_history)
   10.       └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   11.         ├─...[]
   12.         └─data.table:::`[.data.table`(...)
  ── Error ('test-q_models.R:205:3'): q_glm and q_sl(SL.library('SL.glm')) are (almost) equivalent ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 13/13 in VECTOR_ELT
  Backtrace:
       ▆
    1. └─polle::policy_eval(...) at test-q_models.R:205:3
    2.   ├─base::do.call(what = policy_eval_type, args = args)
    3.   └─polle (local) `<fn>`(...)
    4.     └─polle:::fit_functions(...)
    5.       └─polle (local) policy(policy_data = policy_data)
    6.         └─base::lapply(...)
    7.           └─polle (local) FUN(X[[i]], ...)
    8.             ├─polle::get_history(...)
    9.             └─polle:::get_history.policy_data(...)
   10.               └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   11.                 ├─...[]
   12.                 └─data.table:::`[.data.table`(...)
  ── Failure ('test-q_models.R:241:3'): q_glm handles missing covariates ─────────
  `policy_eval(policy_data = pd, policy = p, type = "or", q_models = q_glm(~L))` threw an error.
  Message: attempt access index 11/11 in VECTOR_ELT
  Class:   simpleError/error/condition
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-q_models.R:241:3
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat (local) .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─polle::policy_eval(...)
    7.   ├─base::do.call(what = policy_eval_type, args = args)
    8.   └─polle (local) `<fn>`(...)
    9.     └─polle:::fit_functions(...)
   10.       └─polle (local) policy(policy_data = policy_data)
   11.         └─base::lapply(...)
   12.           └─polle (local) FUN(X[[i]], ...)
   13.             ├─polle::get_history(...)
   14.             └─polle:::get_history.policy_data(...)
   15.               └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   16.                 ├─...[]
   17.                 └─data.table:::`[.data.table`(...)
  ── Failure ('test-q_models.R:248:3'): q_glm handles missing covariates ─────────
  `policy_eval(...)` threw an error.
  Message: attempt access index 11/11 in VECTOR_ELT
  Class:   simpleError/error/condition
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-q_models.R:248:3
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat (local) .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─polle::policy_eval(...)
    7.   ├─base::do.call(what = policy_eval_type, args = args)
    8.   └─polle (local) `<fn>`(...)
    9.     └─polle:::fit_functions(...)
   10.       └─polle (local) policy(policy_data = policy_data)
   11.         └─base::lapply(...)
   12.           └─polle (local) FUN(X[[i]], ...)
   13.             ├─polle::get_history(...)
   14.             └─polle:::get_history.policy_data(...)
   15.               └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   16.                 ├─...[]
   17.                 └─data.table:::`[.data.table`(...)
  ── Error ('test-q_sl.R:12:3'): q_sl with discreteSL = TRUE picks the learner with the lowest cvrisk. ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 13/13 in VECTOR_ELT
  Backtrace:
      ▆
   1. └─polle:::fit_Q_functions(...) at test-q_sl.R:12:3
   2.   └─polle:::q_step(...)
   3.     ├─polle::get_history(policy_data, stage = k, full_history = full_history)
   4.     └─polle:::get_history.policy_data(policy_data, stage = k, full_history = full_history)
   5.       └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   6.         ├─...[]
   7.         └─data.table:::`[.data.table`(...)
  ── Error ('test-q_xgboost.R:11:3'): q_xgboost tunes parameters ─────────────────
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 12/12 in VECTOR_ELT
  Backtrace:
      ▆
   1. └─polle:::fit_Q_functions(...) at test-q_xgboost.R:11:3
   2.   └─polle:::q_step(...)
   3.     ├─polle::get_history(policy_data, stage = k, full_history = full_history)
   4.     └─polle:::get_history.policy_data(policy_data, stage = k, full_history = full_history)
   5.       └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   6.         ├─...[]
   7.         └─data.table:::`[.data.table`(...)
  ── Error ('test-q_xgboost.R:49:3'): q_xgboost gives the same result as plain xgboost ──
  Error in ``[.data.table`(stage_data[stage <= stage_], , `:=`(U_bar, sum(U * (event != 1), na.rm = TRUE)), by = "id")`: attempt access index 12/12 in VECTOR_ELT
  Backtrace:
      ▆
   1. └─polle:::fit_Q_functions(...) at test-q_xgboost.R:49:3
   2.   └─polle:::q_step(...)
   3.     ├─polle::get_history(policy_data, stage = k, full_history = full_history)
   4.     └─polle:::get_history.policy_data(policy_data, stage = k, full_history = full_history)
   5.       └─polle:::stage_state_history(object, stage = stage, event_set = event_set)
   6.         ├─...[]
   7.         └─data.table:::`[.data.table`(...)
  
  [ FAIL 196 | WARN 8 | SKIP 0 | PASS 220 ]
  Error:
  ! Test failures.
  Execution halted