data(EFV)
# \donttest{
Lnodes <- c("adherence.1","weight.1",
"adherence.2","weight.2",
"adherence.3","weight.3",
"adherence.4","weight.4")
Ynodes <- c("VL.0","VL.1","VL.2","VL.3","VL.4")
Anodes <- c("efv.0","efv.1","efv.2","efv.3","efv.4")
## ------------------------------------------------------------------
## Example 1: Hazard binning with default grid
## Static grid of targets (vector abar) over the full support of efv.*
## ------------------------------------------------------------------
abar_static <- seq(0, 10, by = 1)
m_hazard <- feasible(
X = EFV,
Anodes = Anodes,
Lnodes = Lnodes,
Ynodes = Ynodes,
d.method = "hazardbinning", # long computation, but appropriate
abar = abar_static,
grid.size = 0.5,
left.boundary = 0,
right.boundary = 10
)
## Individual-level feasible values (one matrix per strategy):
## rows = individuals, columns = time points
feasible_matrix <- m_hazard$feasible # pass on to gofrmula/sgf
lapply(feasible_matrix, head)
## Inspect feasability of strategies
m_hazard # see also ?print.feasible
summary(m_hazard) # see also ?summary.feasible
## ------------------------------------------------------------------
## Example 2: Parametric density, using abar as the grid
## Here grid.size = NULL, so only the target values are used as grid
## ------------------------------------------------------------------
abar_param <- seq(0, 10, by = 2)
m_param <- feasible(
X = EFV,
Anodes = Anodes,
Lnodes = Lnodes,
Ynodes = Ynodes,
# fast, but useful for reasonably symmetric distributions
d.method = "parametric",
abar = abar_param,
grid.size = NULL,
left.boundary = 0,
right.boundary = 10
)
## Inspect feasability of strategies
m_param # see also ?print.feasible
summary(m_param) # see also ?summary.feasible
## ------------------------------------------------------------------
## Example 3: Matrix abar with non-constant strategies over time
## Each row is a strategy, each column corresponds to efv.0, ..., efv.4
## ------------------------------------------------------------------
abar_matrix <- rbind(
c(0, 2, 4, 6, 8), # strategy 1
c(9, 6, 2, 1, 0), # strategy 2
c(1, 3, 5, 7, 9) # strategy 3
)
m_matrix <- feasible(
X = EFV,
Anodes = Anodes,
Lnodes = Lnodes,
Ynodes = Ynodes,
d.method = "parametric",
abar = abar_matrix,
grid.size = 1,
left.boundary = 0,
right.boundary = 10
)
## Inspect feasability of strategies
m_matrix # see also ?print.feasible
summary(m_matrix) # see also ?summary.feasible
# }
Run the code above in your browser using DataLab