waffect: Simulation of phenotypes in the binary (case/control) and...

Description Usage Arguments Value See Also Examples

View source: R/waffect.R

Description

This is the main function of the waffect package. Given a vector (matrix) of probabilities and the desired total number of cases and controls (resp.: individuals in each class) waffect outputs a simulated phenotypic dataset.

Usage

1
waffect(prob, count, label, method, burnin)	

Arguments

prob

a vector of probabilities corresponding to the disease model H1: the i-th entry is the probability that the i-th individual is a case. Alternatively, a matrix with k rows and n columns where K = number of classes and n = total number of individuals. In this case, the entry in the k-th row and j-th column is the probability that the phenotype of the j-th individual is in the k-th class. If prob is missing and count is a vector of length 2, then the constant vector of probabilities rep(0.1, sum(count)) is assumed, thus resulting in simulating phenotypes under the null hypothesis H0. If prob is missing and count is a vector with length greater or equal than 3, then for each individual the probability to be in the first class is 0.1 and the probability to be in each of the other classes is 0.9/(K-1).

count

either an integer (the total number of cases), or a vector of length two (number of cases and number of controls), or, in the multiclass case, a vector of length greater or equal than 3 (number of individuals in each class).

label

a list with either the labels for cases and controls or, in the multiclass case, the codes for each class. In the binary case the first entry must be the label for cases. By default label = c(1,0) in the binary case and label = 1:K, where K is the total number of classes.

method

the method to be implemented for the simulation. Three methods are available: "backward", "mcmc", "reject". The default method is "backward"; "reject" is deprecated.

burnin

the burn-in step if method is "reject"; by default burnin = 1e+05 * n, where n is the total number of individuals.

Value

A list of phenotypes coded by the entries in label.

See Also

Package documentation: waffect-package. Useful information can be also found in the vignette: vignette("waffect-tutorial").

Examples

 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
## Not run: Typical usage to simulate case/control phenotypes under H1 (in this example: 12 individuals, 7 cases, 5 controls, the probability that individual 1 is a case is 0.2...):
waffect(prob =  c(0.2, 0.4, 0.9, 0.6, 0.9, 0.1, 0.4, 0.6, 0.6, 0.3, 0.8, 0.1), count=c(7,5), label=c(1,0))

## Not run: By rerunning the command we obtain another simulation:
waffect(prob =  c(0.2, 0.4, 0.9, 0.6, 0.9, 0.1, 0.4, 0.6, 0.6, 0.3, 0.8, 0.1), count=c(7,5), label=c(1,0))

## Not run: We can just specify the number of cases:
waffect(prob =  c(0.2, 0.4, 0.9, 0.6, 0.9, 0.1, 0.4, 0.6, 0.6, 0.3, 0.8, 0.1), count=7, label=c(1,0))

## Not run: It is possible to change the default code for cases and controls:
pi <- runif(100)
waffect(prob = pi, c(50,50), label = c("case","control"))

## Not run: If prob is not specified then a constant vector of probabilities is assumed by default. This is equivalent to simulate phenotypes under the null hypothesis H0:
waffect(count = c(20,30), label=c(1,0))  

## Not run: Example with 6 individuals and 3 classes:
pi1 = c(0.3,0.4,0.3)
pi2 = c(0.3,0.5,0.2)
pi3 = c(0.1,0.2,0.7)
pi4 = c(0.1,0.6,0.3)
pi5 = c(0.1,0.7,0.2)
pi6 = c(0.4,0.1,0.5)
pi = cbind(pi1,pi2,pi3,pi4,pi5,pi6)
waffect(prob = pi, count = c(1,2,3))

waffect documentation built on May 2, 2019, 6:11 a.m.