Skip to content

non-numeric argument to binary operator #14

Description

@yangliu6768

Hi,

When I tried to learn the individualized best treatment effect, I found an error called non-numeric argument to binary operator.

Here is my code:

library(data.table)
library(sl3)
library(tmle3)
library(tmle3mopttx)
library(devtools)
set.seed(111)

data <- read.csv("updated_dat_r.csv",header = TRUE)
node_list <- list(
W = colnames(data)[1:148],
A = 'tm_grp',
Y = "death.no_readmission"
)
processed <- process_missing(data, node_list)
data <- processed$data
node_list <- processed$node_list

Initialize few of the learners:

lrn_xgboost_50 <- Lrnr_xgboost$new(nrounds = 50)
lrn_xgboost_100 <- Lrnr_xgboost$new(nrounds = 100)
lrn_xgboost_500 <- Lrnr_xgboost$new(nrounds = 500)
lrn_mean <- Lrnr_mean$new()
lrn_glm <- Lrnr_glm_fast$new()

Define the Q learner, which is just a regular learner:

Q_learner <- Lrnr_sl$new(
learners = list(lrn_glm #,
# lrn_xgboost_100, lrn_mean,
),
metalearner = Lrnr_nnls$new()
)

Q_learner <- Lrnr_hal9001$new()

Define the g learner, which is a multinomial learner:

specify the appropriate loss of the multinomial learner:

mn_metalearner <- make_learner(Lrnr_solnp,
eval_function = loss_loglik_multinomial,
learner_function = metalearner_linear_multinomial
)
g_learner <- make_learner(Lrnr_sl, list(# lrn_glm
lrn_xgboost_50

lrn_xgboost_100, lrn_xgboost_500, lrn_mean

),
mn_metalearner)

g_learner <- Lrnr_hal9001$new()

Define the Blip learner, which is a multivariate learner:

learners <- list(
lrn_xgboost_50,

lrn_xgboost_100, lrn_xgboost_500,

lrn_mean,

lrn_glm)
b_learner <- create_mv_learners(learners = learners)

specify outcome and treatment regressions and create learner list

learner_list <- list(Y = Q_learner, A = g_learner, B = b_learner)

initialize a tmle specification

tmle_spec <- tmle3_mopttx_blip_revere(
type = "blip3",
learners = learner_list,
maximize = FALSE, complex = TRUE,
realistic = FALSE, resource = 1
)

complex = TRUE must use all V to determine treatment rule

realistic = TRUE: respect the possitivity issue

resource: 0.5, can only give half of them treatment

fit the TML estimator

fit <- tmle3(tmle_spec, data, node_list, learner_list)
fit

And here is the error:

Error in .Primitive("*")(dots[[1L]][[1L]], dots[[2L]][[1L]]) :
non-numeric argument to binary operator

And the traceback:

8.stop(first_error$value)
7.self$compute_step()
6.scheduler$compute()
5.delayed_fit$compute(job_type = sl3_delayed_job_type(), progress = verbose)
4.likelihood_def$train(tmle_task)
3.point_tx_likelihood(tmle_task, learner_list)
2.tmle_spec$make_initial_likelihood(tmle_task, learner_list)
1.tmle3(tmle_spec, data, node_list, learner_list)

Could you please help me? Thank you very much! I appreciate your help.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions