simulate.PlackettLuce: Simulate from 'PlackettLuce' fitted objects

View source: R/simulate.R

simulate.PlackettLuceR Documentation

Simulate from PlackettLuce fitted objects

Description

Simulate from PlackettLuce fitted objects

Usage

## S3 method for class 'PlackettLuce'
simulate(
  object,
  nsim = 1L,
  seed = NULL,
  multinomial = FALSE,
  max_combinations = 20000,
  ...
)

Arguments

object

an object representing a fitted model.

nsim

number of response vectors to simulate. Defaults to 1.

seed

an object specifying if and how the random number generator should be initialised. Either NULL or an integer that will be used in a call to set.seed before simulating the rankings. If set, the value is saved as the seed attribute of the returned value. The default, NULL, will not change the random generator state, and return .Random.seed as the seed attribute.

multinomial

use multinomial sampling anyway? Default is FALSE. see Details.

max_combinations

a positive number. Default is 20000. See Details.

...

additional optional arguments.

Details

If multinomial is FALSE (default) and there are no tie parameters in the object (i.e. length(object$ties) == 1), then rankings are sampled by ordering exponential random variates with rate 1 scaled by the estimated item-worth parameters object$coefficients (see, Diaconis, 1988, Chapter 9D for details).

In all other cases, the current implementation uses direct multinomial sampling, and will throw an error if there are more than max_combinations combinations of items that the sampler has to decide from. This is a hard-coded exit to prevent issues relating to the creation of massive objects in memory.

If length(object$ties) > 1 the user's setting for multinomial is ignored and simulate.PlackettLuce operates as if multinomial is TRUE.

Value

A data.frame of rankings objects of the same dimension as object$rankings.

References

Diaconis (1988). Group Representations in Probability and Statistics. Institute of Mathematical Statistics Lecture Notes 11. Hayward, CA.

Examples

R <- matrix(c(1, 2, 0, 0,
              4, 1, 2, 3,
              2, 1, 1, 1,
              1, 2, 3, 0,
              2, 1, 1, 0,
              1, 0, 3, 2), nrow = 6, byrow = TRUE)
colnames(R) <- c("apple", "banana", "orange", "pear")
mod <- PlackettLuce(R)
simulate(mod, 5)

s1 <- simulate(mod, 3, seed = 112)
s2 <- simulate(mod, 2, seed = 112)

identical(s1[1:2], s2[1:2])


PlackettLuce documentation built on July 9, 2023, 7:12 p.m.