branch_joint_probs: Branch Joint Probabilities

View source: R/branch_joint_probs.R

branch_joint_probsR Documentation

Branch Joint Probabilities

Description

Provides a measure of the chances of following particular paths through the decision tree.

Usage

branch_joint_probs(model, ...)

## S3 method for class 'transmat'
branch_joint_probs(model, nodes = NA, ...)

## S3 method for class 'dat_long'
branch_joint_probs(model, nodes, ...)

## Default S3 method:
branch_joint_probs(model, nodes, ...)

Arguments

model

Branch conditional probabilities (matrix)

...

Additional parameters

nodes

Which nodes to return; default to all

Details

These probabilities could be used to weight branch costs or QALYs to indicate the relative contribution to the total expected value.

Value

Transition matrix with joint probabilities

Examples


model <-
  define_model(
    transmat =
      list(prob =
             matrix(data = c(NA, 0.5, 0.5, NA,  NA,  NA,  NA,
                             NA, NA, NA,   0.1, 0.9, NA,  NA,
                             NA, NA, NA,   NA,  NA,  0.9, 0.1),
                    nrow = 3,
                    byrow = TRUE),
           vals =
             matrix(data = c(NA, 1,  5,  NA, NA, NA, NA,
                             NA, NA, NA, 1,  9,  NA, NA,
                             NA, NA, NA, NA, NA, 9,  1),
                    nrow = 3,
                    byrow = TRUE)))
model

branch_joint_probs(model)

# weighted vals
branch_joint_probs(model)*model$vals

# long data format
df <-
  data.frame(
    from = c(1,2,1),
    to = c(2,3,4),
    prob = c(0.1,0.5,0.9),
    vals = c(1,2,3))

mod <- define_model(dat_long = df)

branch_joint_probs(mod, nodes = 4)
#0.9

branch_joint_probs(mod, nodes = 3)
#0.1*0.5

branch_joint_probs(mod, nodes = 3)[[1]] |> cumprod()


n8thangreen/CEdecisiontree documentation built on Sept. 13, 2022, 5:25 a.m.