Description Usage Arguments Value Author(s) See Also Examples
This function simulates one or more pseudo-random datasets from a specified Bradley-Terry model. Counts are simulated from independent binomial distributions, with the binomial probabilities and totals specified through the function arguments.
1 2 3 4 5 6 |
pi |
a numeric vector, with all values finite and positive. The vector of item strengths in the Bradley-Terry model. |
N |
a symmetric, numeric matrix with dimensions the same as
|
nsim |
a scalar integer, the number of datasets to be generated. |
seed |
an object specifying if and how the random number generator
should be initialized (‘seeded’).
For details see |
result_class |
a character vector specifying whether the generated datasets should be of class "sparseMatrix" or of class "btdata". If not specified, the first match among those alternatives is used. |
object |
An object of class "btfit", typically the result of |
... |
Other arguments |
a list of length nsim
of simulated datasets.
If result_class = "sparseMatrix"
, the datasets are sparse matrices
with the same dimensions as N
. If result_class = "btdata"
then
the datasets are "btdata" objects. See btdata
David Firth
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | set.seed(1)
n <- 6
N <- matrix(rpois(n ^ 2, lambda = 1), n, n)
N <- N + t(N) ; diag(N) <- 0
p <- exp(rnorm(n)/4)
names(p) <- rownames(N) <- colnames(N) <- letters[1:6]
simulate_BT(p, N, seed = 6)
citations_btdata <- btdata(BradleyTerryScalable::citations)
fit1 <- btfit(citations_btdata, 1)
simulate(fit1, nsim = 2, seed = 1)
toy_df_4col <- codes_to_counts(BradleyTerryScalable::toy_data, c("W1", "W2", "D"))
toy_btdata <- btdata(toy_df_4col)
fit2 <- btfit(toy_btdata, 1, subset = function(x) "Amy" %in% x)
fit2_sim <- simulate(fit2, nsim = 3, result_class = "btdata")
fit2_sim$sim_1
purrr::map(fit2_sim, "wins")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.