response: Random response generator

Description Usage Arguments Value Author(s) Examples

View source: R/response.R View source: R/RcppExports.R

Description

Generates random efficacy responses of subjects randomized in a clinical trial

Usage

1
response(distr, distr_param, treatment)

Arguments

distr

distribution of responses. The following values are supported:

  • "binary"Binary (Bernoulli) distribution,

  • "uniform"Uniform distribution,

  • "normal"Normal distribution,

  • "exponential"Exponential distribution,

  • "weibull"Weibull distribution,

  • "loglogistic"Log-logistic distribution,

  • "lognormal"Log-normal distribution.

distr_param

parameter(s) of the response distribution (a named list with numeric vector(s) of length K each, where K is a total number of treatments studied in a clinical trial. It must have the following structure depending on a value of the distr parameter:

  • distr_param = list(prob) if distr == "binary"; in this case response is a binary variable with values {0, 1}. It has a parameter prob = p, and

    Pr(response = 1) = p,

  • distr_param = list(min, max) if distr == "uniform"; the Unifrom distribution has a p.d.f.

    f(x) = 1/(max-min),

  • distr_param = list(mean, sd) "normal"; it is assumed that a p.d.f. of Normal distribution with mean = μ and sd = σ equals to

    f(x) = 1/(σ√(2π))exp(-(x-μ)^2/(2σ^2)),

  • distr_param = list(rate) if distr == "exponential"; it is assumed that a p.d.f. of Exponential distribution with rate = λ equals to

    f(x) = λ exp(-λ x),

  • distr_param = list(shape, scale) if distr == "weibull"; it is assumed that a p.d.f. of Weibull distribution with shape = k and scale = λ equals to

    f(x) = (k/λ)(x/k)^(k-1)exp(-(x/λ)^k),

  • distr_param = list(shape, scale) if distr == "loglogistic"; it is assumed that a p.d.f. of Log-logistic distribution with shape = β and scale = α equals to

    f(x) = (β/α)(x/α)^(β-1)/(1+(x/α)^β)^2,

  • distr_param = list(mu, sigma) "lognormal"; it is assumed that a p.d.f. of Log-normal distribution with mu = μ and sigma = σ equals to

    f(x) = 1/(xσ√(2π))exp(-(lnx-μ)^2/(2σ^2)).

treatment

vector of treatment assignments (contains integers from 1 to K, where K is a total number of treatments studied in a clinical trial).

Value

a numeric vector of rsponses' values

Author(s)

Yevgen Ryeznik ([email protected]), Oleksandr Sverdlov

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
   library(artool)
   
   # generate random treatment assignments (4 treatments, equal probabilities)
   treatment <- sample(1:4, 100, replace = TRUE, prob = rep(0.25,4))
   
   # generate normal responses with the same means = 0 and all sds = 1
   response("normal", list(mean = rep(0,4), sd = rep(1, 4)), treatment)
   
   # generate normal responses with means c(0, 0.2, 0.4, 0.6), and sd's = c(0.1, 0.5, 0.7, 1)
   response("normal", list(mean = c(0, 0.2, 0.4, 0.6), sd = c(0.1, 0.5, 0.7, 1)), treatment)
   
   # generate Weibul responses with shapes = c(0.5, 1, 1.5, 2) and scale = 1
   response("weibull", list(shape = c(0.5, 1, 1.5, 2), scale = rep(1, 4)), treatment)
    

yevgenryeznik/artool documentation built on Dec. 13, 2017, 1:39 a.m.