Learn R Programming

polle (version 1.6.2)

predict.nuisance_functions: Predict g-functions and Q-functions

Description

predict() returns the fitted values of the g-functions and Q-functions when applied to a (new) policy data object.

Usage

# S3 method for nuisance_functions
predict(object, new_policy_data, event_set = c(0), ...)

Value

data.table::data.table with keys id and stage and variables g_a or Q_a for each action a in the actions set.

Arguments

object

Object of class "nuisance_functions". Either g_functions or q_functions as returned by policy_eval() or policy_learn().

new_policy_data

Policy data object created by policy_data(). Action events (0), terminal events (1), or right-censoring events (2).

event_set

Subset of the events considered. Action events (0), terminal events (1), or right-censoring events (2)

...

Additional arguments.

Examples

Run this code
library("polle")
### Single stage:
d <- sim_single_stage(5e2, seed=1)
pd <- policy_data(d, action="A", covariates=list("Z", "B", "L"), utility="U")
pd
# defining a static policy (A=1):
pl <- policy_def(1, name = "A=1")

# doubly robust evaluation of the policy:
pe <- policy_eval(policy_data = pd,
                  policy = pl,
                  g_models = g_glm(),
                  q_models = q_glm())
# summarizing the estimated value of the policy:
pe

# getting the fitted g-function values:
head(predict(get_g_functions(pe), pd))

# getting the fitted Q-function values:
head(predict(get_q_functions(pe), pd))

Run the code above in your browser using DataLab