Skip to contents

Same latent genotype, Z, with independent errors for true donor (D) and suspect (S).

Usage

sample_data_Hp_w(n, w, p, ...)

Arguments

n

number of samples

w

error probability

p

list of genotype probabilities (length is number of loci) or vector of length 3 for single locus

...

Passed on to add_errors_to_genotypes()

Value

list of two matrices, each of size n x loci with genotype in 0/1/2 format resembling the situation in real life.

Examples

sample_data_Hp_w(n = 10, w = 0.3, p = c(0.25, 0.25, 0.5))
#> $X_D
#>       [,1]
#>  [1,]    1
#>  [2,]    2
#>  [3,]    1
#>  [4,]    1
#>  [5,]    2
#>  [6,]    1
#>  [7,]    2
#>  [8,]    2
#>  [9,]    1
#> [10,]    1
#> 
#> $X_S
#>       [,1]
#>  [1,]    1
#>  [2,]    1
#>  [3,]    2
#>  [4,]    1
#>  [5,]    1
#>  [6,]    1
#>  [7,]    0
#>  [8,]    1
#>  [9,]    1
#> [10,]    0
#> 
sample_data_Hp_w(n = 10, w = 0.1, p = list(
  c(0.25, 0.25, 0.5), c(0.1, 0.8, 0.1)))
#> $X_D
#>       [,1] [,2]
#>  [1,]    2    1
#>  [2,]    2    1
#>  [3,]    1    0
#>  [4,]    0    1
#>  [5,]    0    1
#>  [6,]    2    2
#>  [7,]    1    1
#>  [8,]    1    1
#>  [9,]    2    1
#> [10,]    2    2
#> 
#> $X_S
#>       [,1] [,2]
#>  [1,]    2    1
#>  [2,]    2    1
#>  [3,]    0    1
#>  [4,]    1    1
#>  [5,]    0    1
#>  [6,]    2    1
#>  [7,]    1    1
#>  [8,]    0    1
#>  [9,]    2    1
#> [10,]    0    2
#> 
  
cases <- sample_data_Hp_w(n = 1000, w = 0.3, p = c(0.25, 0.25, 0.5))
tab <- table(X_D = cases$X_D, X_S = cases$X_S)
tab
#>    X_S
#> X_D   0   1   2
#>   0  65  92  50
#>   1  84 213 141
#>   2  56 158 141
estimate_w(tab)
#> [1] 0.3358798

cases <- sample_data_Hp_w(n = 1000, w = 0, p = c(0.1, 0.7, 0.2))
tab <- table(X_D = cases$X_D, X_S = cases$X_S)
diag(tab/sum(tab))
#>     0     1     2 
#> 0.111 0.702 0.187