# Adverse event probabilities

Source: `R/adverse-events.R`
`ae_probs.Rd`

Obtain adverse event probabilities for treatment sequences given existing probabilities by treatment from a network meta-analysis.

    ae_probs(n, struct, params_ae = iviNSCLC::params_ae_nma)

## Arguments

n | The number of random observations of the parameters to draw.
struct | A `model_structure` object.
params_ae | Parameter estimates of the probabilities of adverse events in the same format as `params_ae_nma`.

## Value

A list of matrices where each matrix corresponds to a type of adverse event. Rows of each matrix are posterior samples of the parameters and columns are treatment strategies. The list is an object of class "ae_probs" with an attribute "tx_abb" denoting the treatment used to estimate adverse events for each treatment sequence.

## Examples

    txseq1 <- txseq(first = "erlotinib",
                    second = c("osimertinib", "PBDC"),
                    second_plus = c("PBDC + bevacizumab", "PBDC + bevacizumab"))
    txseq2 <- txseq(first = "gefitinib",
                    second = c("osimertinib", "PBDC"),
                    second_plus = c("PBDC + bevacizumab", "PBDC + bevacizumab"))
    txseqs <- txseq_list(seq1 = txseq1, seq2 = txseq2)
    struct <- model_structure(txseqs)
    ae_probs <- ae_probs(n = 3, struct = struct)
    print(ae_probs[1:3])#> $alt
    #>            seq1       seq2
    #> [1,] 0.04947135 0.11533762
    #> [2,] 0.02617712 0.08485151
    #> [3,] 0.02156232 0.09119395
    #>
    #> $ast
    #>            seq1       seq2
    #> [1,] 0.10312491 0.10312491
    #> [2,] 0.07267753 0.07267753
    #> [3,] 0.10509515 0.10509515
    #>
    #> $diarrhea
    #>             seq1        seq2
    #> [1,] 0.007514118 0.008037219
    #> [2,] 0.013627760 0.018529599
    #> [3,] 0.002408500 0.017021846
    #> tidy_ae_probs <- tidy(ae_probs)
    head(tidy_ae_probs)#>    strategy_id                       ae_name       prob
    #> 1:           1 Elevated alanine transaminase 0.04947135
    #> 2:           1 Elevated alanine transaminase 0.02617712
    #> 3:           1 Elevated alanine transaminase 0.02156232
    #> 4:           2 Elevated alanine transaminase 0.11533762
    #> 5:           2 Elevated alanine transaminase 0.08485151
    #> 6:           2 Elevated alanine transaminase 0.09119395