library("polle")
### Simulating two-stage policy data
d <- sim_two_stage(2e3, seed=1)
pd <- policy_data(d,
action = c("A_1", "A_2"),
covariates = list(L = c("L_1", "L_2"),
C = c("C_1", "C_2")),
utility = c("U_1", "U_2", "U_3"))
pd
# fitting a single g-model across all stages:
g_functions <- fit_g_functions(policy_data = pd,
g_models = g_glm(),
full_history = FALSE)
g_functions
# fitting a g-model for each stage:
g_functions <- fit_g_functions(policy_data = pd,
g_models = list(g_glm(), g_glm()),
full_history = TRUE)
g_functions
Run the code above in your browser using DataLab