Only parameters that vary by agent/class can be ranked.

# S3 method for mbnma
rank(
  x,
  params = NULL,
  lower_better = TRUE,
  level = "agent",
  to.rank = NULL,
  ...
)

Arguments

x

An object on which to apply the rank method

params

A character vector of named parameters in the model that vary by either agent or class (depending on the value assigned to level). If left as NULL (the default), then ranking will be calculated for all available parameters that vary by agent/class.

lower_better

Indicates whether negative responses are better (TRUE) or positive responses are better (FALSE)

level

Can be set to "agent" to rank across different agents or "class" to rank across different classes.

to.rank

A numeric vector containing the codes for the agents/classes you wish to rank. If left NULL then all agents/classes (depending on the value assigned to level) in the model will be ranked. Included codes must be greater than 2 if placebo has been modelled, since placebo cannot be included in the ranking

...

Arguments to be passed to methods

Value

An object of class("mbnma.rank") which is a list containing a summary data frame, a matrix of rankings for each MCMC iteration, a matrix of probabilities that each agent has a particular rank, and a matrix of cumulative ranking probabilities for each agent, for each parameter that has been ranked.

Details

Ranking cannot currently be performed on non-parametric dose-response MBNMA

Examples

# \donttest{
# Using the triptans data
network <- mbnma.network(triptans)
#> Values for `agent` with dose = 0 have been recoded to `Placebo`
#> agent is being recoded to enforce sequential numbering

# Rank selected agents from a log-linear dose-response MBNMA
loglin <- mbnma.run(network, fun=dloglin())
#> `likelihood` not given by user - set to `binomial` based on data provided
#> `link` not given by user - set to `logit` based on assigned value for `likelihood`
#> Compiling model graph
#>    Resolving undeclared variables
#>    Allocating nodes
#> Graph information:
#>    Observed stochastic nodes: 182
#>    Unobserved stochastic nodes: 77
#>    Total graph size: 3644
#> 
#> Initializing model
#> 
ranks <- rank(loglin, to.rank=c("zolmitriptan", "eletriptan", "sumatriptan"))
summary(ranks)
#> $rate
#>     rank.param     mean         sd 2.5% 25% 50% 75% 97.5%
#> 1 zolmitriptan 2.007667 0.08723775    2   2   2   2     2
#> 2   eletriptan 1.000000 0.00000000    1   1   1   1     1
#> 3  sumatriptan 2.992333 0.08723775    3   3   3   3     3
#> 

# Rank only ED50 parameters from an Emax dose-response MBNMA
emax <- mbnma.run(network, fun=demax(), method="random")
#> `likelihood` not given by user - set to `binomial` based on data provided
#> `link` not given by user - set to `logit` based on assigned value for `likelihood`
#> Compiling model graph
#>    Resolving undeclared variables
#>    Allocating nodes
#> Graph information:
#>    Observed stochastic nodes: 182
#>    Unobserved stochastic nodes: 197
#>    Total graph size: 4115
#> 
#> Initializing model
#> 
ranks <- rank(emax, params="ed50")
summary(ranks)
#> $ed50
#>     rank.param     mean        sd 2.5% 25% 50% 75% 97.5%
#> 1   eletriptan 6.635333 0.5942524    5   6   7   7     7
#> 2  sumatriptan 5.703000 0.7977070    4   5   6   6     7
#> 3 frovatriptan 2.558667 1.1303322    1   2   3   4     4
#> 4  almotriptan 2.333333 1.1301835    1   1   2   3     4
#> 5 zolmitriptan 5.586667 0.7257165    5   5   5   6     7
#> 6  naratriptan 2.063667 1.0655163    1   1   2   3     4
#> 7  rizatriptan 3.119333 1.0260493    1   2   3   4     5
#> 


#### Ranking by class ####
# Generate some classes for the data
class.df <- triptans
class.df$class <- ifelse(class.df$agent=="placebo", "placebo", "active1")
class.df$class <- ifelse(class.df$agent=="eletriptan", "active2", class.df$class)
netclass <- mbnma.network(class.df)
#> Values for `agent` with dose = 0 have been recoded to `Placebo`
#> agent is being recoded to enforce sequential numbering
#> Values for `class` with dose = 0 have been recoded to `Placebo`
#> class is being recoded to enforce sequential numbering
emax <- mbnma.run(netclass, fun=demax(), method="random",
            class.effect=list("ed50"="common"))
#> `likelihood` not given by user - set to `binomial` based on data provided
#> `link` not given by user - set to `logit` based on assigned value for `likelihood`
#> Compiling model graph
#>    Resolving undeclared variables
#>    Allocating nodes
#> Graph information:
#>    Observed stochastic nodes: 182
#>    Unobserved stochastic nodes: 192
#>    Total graph size: 4108
#> 
#> Initializing model
#> 

# Rank by class, with negative responses being worse
ranks <- rank(emax, level="class", lower_better=FALSE)
print(ranks)
#> 
#> ================================
#> Ranking of dose-response MBNMA
#> ================================
#> 
#> Includes ranking of relative class effects from dose-response MBNMA:
#> ED50
#> 
#> 
#> 2 classes ranked with positive responses being `better`
#> 
#> ED50 ranking (from best to worst)
#> 
#> |Treatment | Mean| Median| 2.5%| 97.5%|
#> |:---------|----:|------:|----:|-----:|
#> |active2   | 1.11|      1|    1|     2|
#> |active1   | 1.89|      2|    1|     2|
#> 
#> 

# Print and generate summary data frame for `mbnma.rank` object
summary(ranks)
#> $ED50
#>   rank.param     mean        sd 2.5% 25% 50% 75% 97.5%
#> 1    active1 1.894333 0.3074618    1   2   2   2     2
#> 2    active2 1.105667 0.3074618    1   1   1   1     2
#> 
print(ranks)
#> 
#> ================================
#> Ranking of dose-response MBNMA
#> ================================
#> 
#> Includes ranking of relative class effects from dose-response MBNMA:
#> ED50
#> 
#> 
#> 2 classes ranked with positive responses being `better`
#> 
#> ED50 ranking (from best to worst)
#> 
#> |Treatment | Mean| Median| 2.5%| 97.5%|
#> |:---------|----:|------:|----:|-----:|
#> |active2   | 1.11|      1|    1|     2|
#> |active1   | 1.89|      2|    1|     2|
#> 
#> 

# Plot `mbnma.rank` object
plot(ranks)

# }