scheduler: S4 Scheduler Class Object

Description Usage Arguments Slots Methods Getters Setters Plotters Samplers

Description

S4 Scheduler Class Object

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
## S4 method for signature 'scheduler'
show(object)

getAllocation(object)

getHistory(object)

getEntropy(scheduler)

scheduler.start(
  prior.mean,
  prior.var,
  N.burn.in,
  sampler = "sampler.thompson",
  heuristic = FALSE,
  prior.nu,
  prior.alpha,
  prior.beta,
  ...
)

scheduler.update(scheduler, data.ingest, N.allocate)

plotPrior(scheduler)

plotPosterior(scheduler)

plotHistory(scheduler)

plotAllocation(scheduler)

sampler.thompson(scheduler, ...)

sampler.fixed(scheduler, ...)

sampler.auc.cutoff(scheduler, cutoff = 0, ...)

sampler.auc.reference(scheduler, reference = NULL, ...)

sampler.ucb1(scheduler, c = 2, batch = TRUE, ...)

sampler.ucb1.normal(scheduler, c = 16, batch = TRUE, ...)

sampler.epsilon.greedy(scheduler, epsilon = 0.1, ...)

Arguments

object, scheduler

A scheduler object.

prior.mean

A vector of prior means. One mean for each arm

prior.var

A vector of prior variances. One variance for each arm.

N.burn.in

An integer. The number patients to allocate each arm during the initial 'burn-in' phase. Ideally, around 20-30 per arm.

sampler

A string. The sampling method used to allocate patients.

heuristic

A logical. Toggles whether to assume precision is known, but instead estimate it from the data. When taking this approach, the conjugate prior distribution is normal.

prior.nu, prior.alpha, prior.beta

The prior statistics for each arm. These apply when the conjugate prior distribution is normal-gamma (i.e., when heuristic = TRUE).

...

Arguments passed to sampler function. For the sampler itself, a null argument.

data.ingest

A list of rewards. Must match the structure of scheduler@ingest.

N.allocate

An integer. The total number of patients to allocate next.

cutoff

The cutoff used for sampler.auc.cutoff. Allocation is proportional to area under the posterior greater than this cutoff.

reference

The reference used for sampler.auc.reference. Allocation is proportional to area under the posterior greater than the posterior mean of this reference.

c

The exploration hyper-parameter used by several UCB algorithms.

batch

Toggles whether the UCB algorithm should allocate patients to groups randomly based on the rank of the UCB score.

epsilon

The epsilon used for sampler.epsilon.greedy. Allocation is to a random group epsilon percent of the time; otherwise, it is to the group with the largest posterior mean.

Slots

prior.df

The degrees-of-freedom for the t-distribution that describes the uncertainty about the mean. Set to Inf when heuristic = TRUE.

prior.mean

The prior statistics for each arm.

prior.var

The uncertainty about the mean. When the conjugate prior distribution is normal-gamma, this slot contains the variance of the marginal distribution of the mean.

prior.nu,prior.alpha,prior.beta

The prior statistics for each arm. These apply when the conjugate prior distribution is normal-gamma.

N.burn.in

An integer. The number of patients in each arm at first time step.

K.arms

An integer. The number of experimental groups (also called 'arms').

step

An integer. The number of time steps so far. Each time step is a kind of 'mini-trial'. This initializes at 0.

rewards

A list of all rewards observed to date.

meta

A list of tables for all rewards and meta-data available. This is optional, but may be preferred for complex simulations.

online.count,online.sum,online.mean,online.var,online.prec

The empiric statistics observed to date.

heuristic

A logical. Toggles whether to assume precision is known, but instead estimate it from the data. When taking this approach, the conjugate prior distribution is normal.

post.df

The degrees-of-freedom for the t-distribution that describes the uncertainty about the mean. Set to Inf when heuristic = TRUE.

post.mean

The posterior statistics for each arm.

post.var

The uncertainty about the mean. When the conjugate prior distribution is normal-gamma, this slot contains the variance of the marginal distribution of the mean.

post.nu,post.alpha,post.beta

The posterior statistics for each arm. These apply when the conjugate prior distribution is normal-gamma.

sampler.args

A list. Arguments for the sampling method.

sampler

A string. The sampling method used to allocate patients.

dynamic.count

Like @online.count, but used by the UCB algorithm.

allocation

A vector of groups to which to allocate new patients.

ingest

A list describing the structure of the data expected by the next scheduler.update call. This slot is only used to verify the incoming data.

allocation

The most recent patient allocations. This slot implies the structure of the @ingest slot.

history.post

A table of all posterior statistics and the allocation ratios at each time step in the experiment. At @step = 0, the table records the prior statistics and burn-in conditions.

history

A list of lists of all rewards. Unlike @rewards, the rewards here are organized by time step.

Methods

show: Method to show scheduler object.

Getters

getAllocation: Method to retrieve allocations from a scheduler object. This function returns a vector of groups to which to allocate new patients.

getHistory: Method to retrieve history from a scheduler object. This function returns a table of all posterior statistics and the allocation ratios at each time step in the experiment.

getEntropy: Method to retrieve allocation entropy from a scheduler object. This function returns the entropy of the allocation ratios at each time step.

Setters

scheduler.start: Method to initiate a scheduler object. This function returns an updated scheduler object.

scheduler.start: Method to update a scheduler object with new data. This function returns an updated scheduler object.

Plotters

plotPrior: Method to plot prior distributions.

plotPosterior: Method to plot the most recent posterior distributions.

plotHistory: Method to plot all posterior distributions.

plotAllocation: Method to plot the allocation ratios for each time step.

Samplers

sampler.thompson: Method to allocate patients by Thompson sampling. This function returns an integer corresponding to the group to which the patient is randomly allocated.

sampler.fixed: Method to allocate patients at a fixed ratio. This function returns an integer corresponding to the group to which the patient is randomly allocated.

sampler.auc.cutoff: Method to allocate patients proportional to the probability that the posterior expected reward is greater than a cutoff. This function returns an integer corresponding to the group to which the patient is randomly allocated.

sampler.auc.reference: Method to allocate patients proportional to the probability that the posterior expected reward is greater than a reference. This function returns an integer corresponding to the group to which the patient is randomly allocated.

sampler.ucb1: Method to allocate patients based on a UCB algorithm, assuming that the rewards fall within the range of 0 and 1. This function returns an integer corresponding to the group to which the patient is randomly allocated.

sampler.ucb1.normal: Method to allocate patients based on a UCB algorithm, assuming that the rewards are normally distributed. This function returns an integer corresponding to the group to which the patient is randomly allocated.

sampler.epsilon.greedy: Method to allocate patients based on an epsilon-greedy algorithm. By default, epsilon = 0.1. This function returns an integer corresponding to the group to which the patient is randomly allocated.


tpq/rarsim documentation built on April 4, 2020, 3:49 a.m.