simulate_under_LTM simulates families and thresholds under the liability threshold model for a given family structure and a variable number of phenotypes.Please note that it is not possible to simulate different family structures.

simulate_under_LTM(
  fam_vec = c("m", "f", "s1", "mgm", "mgf", "pgm", "pgf"),
  n_fam = NULL,
  add_ind = TRUE,
  h2 = 0.5,
  genetic_corrmat = NULL,
  full_corrmat = NULL,
  phen_names = NULL,
  n_sim = 1000,
  pop_prev = 0.1
)

Arguments

fam_vec

A vector of strings holding the different family members. All family members must be represented by strings from the following list:

  • m (Mother)

  • f (Father)

  • c[0-9]*.[0-9]* (Children)

  • mgm (Maternal grandmother)

  • mgf (Maternal grandfather)

  • pgm (Paternal grandmother)

  • pgf (Paternal grandfather)

  • s[0-9]* (Full siblings)

  • mhs[0-9]* (Half-siblings - maternal side)

  • phs[0-9]* (Half-siblings - paternal side)

  • mau[0-9]* (Aunts/Uncles - maternal side)

  • pau[0-9]* (Aunts/Uncles - paternal side). Defaults to c("m","f","s1","mgm","mgf","pgm","pgf").

n_fam

A named vector holding the desired number of family members. See setNames. All names must be picked from the list mentioned above. Defaults to NULL.

add_ind

A logical scalar indicating whether the genetic component of the full liability as well as the full liability for the underlying target individual should be included in the covariance matrix. Defaults to TRUE.

h2

Either a number or a numeric vector holding the liability-scale heritability(ies) for one or more phenotypes. All entries in h2 must be non-negative. Note that under the liability threshold model, the heritabilities must also be at most 1. Defaults to 0.5.

genetic_corrmat

Either NULL or a numeric matrix holding the genetic correlations between the desired phenotypes. Must be specified, if length(h2)\(>0\), and will be ignored if h2 is a number. All diagonal entries in genetic_corrmat must be equal to one, while all off-diagonal entries must be between -1 and 1. In addition, the matrix must be symmetric. Defaults to NULL.

full_corrmat

Either NULL or a numeric matrix holding the full correlations between the desired phenotypes. Must be specified, if length(h2)\(>0\), and will be ignored if h2 is a number. All diagonal entries in full_corrmat must be equal to one, while all off-diagonal entries must be between -1 and 1. In addition, the matrix must be symmetric. Defaults to NULL.

phen_names

Either NULL or character vector holding the phenotype names. These names will be used to create the row and column names for the covariance matrix. Must be specified, if length(h2) \(> 0\), and will be ignored if h2 is a number. If it is not specified, the names will default to phenotype1, phenotype2, etc. Defaults to NULL.

n_sim

A positive number representing the number of simulations. Defaults to 1000.

pop_prev

Either a number or a numeric vector holding the population prevalence(s), i.e. the overall prevalence(s) in the population. All entries in pop_prev must be positive and smaller than 1. Defaults to 0.1.

Value

If either fam_vec or n_fam is used as the argument, if it is of the required format, if the liability-scale heritability h2

is a number satisfying \(0 \leq h^2\), n_sim is a strictly positive number, and pop_prev is a positive number that is at most one, then the output will be a list containing two tibbles. The first tibble, sim_obs, holds the simulated liabilities, the disease status and the current age/age-of-onset for all family members in each of the n_sim families. The second tibble, thresholds, holds the family identifier, the personal identifier, the role (specified in fam_vec or n_fam) as well as the lower and upper thresholds for all individuals in all families. Note that this tibble has the format required in estimate_liability. If either fam_vec or n_fam is used as the argument and if it is of the required format, if genetic_corrmat and full_corrmat are two numeric and symmetric matrices satisfying that all diagonal entries are one and that all off-diagonal entries are between -1 and 1, if the liability-scale heritabilities in h2_vec are numbers satisfying \(0 \leq h^2_i\) for all \(i \in \{1,...,n_pheno\}\), n_sim is a strictly positive number, and pop_prev is a positive numeric vector such that all entries are at most one, then the output will be a list containing the following lists. The first outer list, which is named after the first phenotype in phen_names, holds the tibble sim_obs, which holds the simulated liabilities, the disease status and the current age/age-of-onset for all family members in each of the n_sim families for the first phenotype. As the first outer list, the second outer list, which is named after the second phenotype in phen_names, holds the tibble sim_obs, which holds the simulated liabilities, the disease status and the current age/age-of-onset for all family members in each of the n_sim families for the second phenotype. There is a list containing sim_obs for each phenotype in phen_names. The last list entry, thresholds, holds the family identifier, the personal identifier, the role (specified in fam_vec or n_fam) as well as the lower and upper thresholds for all individuals in all families and all phenotypes. Note that this tibble has the format required in estimate_liability. Finally, note that if neither fam_vec nor n_fam are specified, the function returns the disease status, the current age/age-of-onset, the lower and upper thresholds, as well as the personal identifier for a single individual, namely the individual under consideration (called o). If both fam_vec and n_fam are defined, the user is asked to ' decide on which of the two vectors to use.

Details

This function can be used to simulate the case-control status, the current age and age-of-onset as well as the lower and upper thresholds for a variable number of phenotypes for all family members in each of the n_sim families. If h2 is a number, simulate_under_LTM simulates the case- control status, the current age and age-of-onset as well as thresholds for a single phenotype. However, if h2 is a numeric vector, if genetic_corrmat and full_corrmat are two symmetric correlation matrices, and if phen_names and pop_prev are to numeric vectors holding the phenotype names and the population prevalences, respectively, then simulate_under_LTM simulates the case-control status, the current age and age-of-onset as well as thresholds for two or more (correlated) phenotypes. The family members can be specified using one of two possible formats.

Examples

simulate_under_LTM()
#> $sim_obs
#> # A tibble: 1,000 × 26
#>    fam_ID           g       o       m       f      s1     mgm     mgf     pgm
#>    <chr>        <dbl>   <dbl>   <dbl>   <dbl>   <dbl>   <dbl>   <dbl>   <dbl>
#>  1 fam_ID_1   0.108   -0.521  -0.643  -0.390   0.919  -2.77    0.462  -0.885 
#>  2 fam_ID_2  -0.648   -0.577   0.0365  1.16   -0.0330 -0.0978 -0.132   2.01  
#>  3 fam_ID_3   0.897    0.0153  1.31    0.333   0.123   0.500   0.671   0.0854
#>  4 fam_ID_4  -1.36    -2.12   -1.96   -1.50   -1.02    0.0177 -0.433  -0.518 
#>  5 fam_ID_5  -0.563   -0.151  -0.259  -0.313  -0.182  -2.15   -0.806   0.0901
#>  6 fam_ID_6   0.00290  0.166   0.383  -0.384   0.246  -0.284   1.39    0.850 
#>  7 fam_ID_7   0.429    0.285   0.716   0.0402  0.659  -0.714  -1.01   -0.266 
#>  8 fam_ID_8  -0.955   -0.547  -0.368   0.627   0.0231  0.690  -1.08   -1.11  
#>  9 fam_ID_9   0.185    0.501   1.70    0.978   1.59   -1.11    0.0535  0.812 
#> 10 fam_ID_10  0.109   -0.204  -0.126  -0.103  -0.501   1.26    0.924  -1.96  
#> # ℹ 990 more rows
#> # ℹ 17 more variables: pgf <dbl>, o_status <lgl>, m_status <lgl>,
#> #   f_status <lgl>, s1_status <lgl>, mgm_status <lgl>, mgf_status <lgl>,
#> #   pgm_status <lgl>, pgf_status <lgl>, o_aoo <dbl>, m_aoo <dbl>, f_aoo <dbl>,
#> #   s1_aoo <dbl>, mgm_aoo <dbl>, mgf_aoo <dbl>, pgm_aoo <dbl>, pgf_aoo <dbl>
#> 
#> $thresholds
#> # A tibble: 8,000 × 5
#>    fam_ID    indiv_ID    role  lower upper
#>    <chr>     <chr>       <chr> <dbl> <dbl>
#>  1 fam_ID_1  fam_ID_1_1  o      -Inf  3.24
#>  2 fam_ID_2  fam_ID_2_1  o      -Inf  3.45
#>  3 fam_ID_3  fam_ID_3_1  o      -Inf  2.91
#>  4 fam_ID_4  fam_ID_4_1  o      -Inf  2.43
#>  5 fam_ID_5  fam_ID_5_1  o      -Inf  2.68
#>  6 fam_ID_6  fam_ID_6_1  o      -Inf  3.17
#>  7 fam_ID_7  fam_ID_7_1  o      -Inf  2.83
#>  8 fam_ID_8  fam_ID_8_1  o      -Inf  2.68
#>  9 fam_ID_9  fam_ID_9_1  o      -Inf  3.10
#> 10 fam_ID_10 fam_ID_10_1 o      -Inf  3.38
#> # ℹ 7,990 more rows
#> 

genetic_corrmat <- matrix(0.4, 3, 3)
diag(genetic_corrmat) <- 1
full_corrmat <- matrix(0.6, 3, 3)
diag(full_corrmat) <- 1

simulate_under_LTM(fam_vec = NULL, n_fam = stats::setNames(c(1,1,1,2,2), 
c("m","mgm","mgf","s","mhs")))
#> $sim_obs
#> # A tibble: 1,000 × 26
#>    fam_ID          g      o      m    mgm     mgf      s1      s2   mhs1   mhs2
#>    <chr>       <dbl>  <dbl>  <dbl>  <dbl>   <dbl>   <dbl>   <dbl>  <dbl>  <dbl>
#>  1 fam_ID_1   0.0568  0.223  1.44   0.973  2.02    1.11    1.44    1.08   0.302
#>  2 fam_ID_2   0.0991  0.839 -0.709 -0.375  0.365  -1.50    0.0962 -0.908 -0.874
#>  3 fam_ID_3   0.540   0.771  1.16  -0.592  1.20    0.127  -0.159   1.09   0.974
#>  4 fam_ID_4   1.18    1.26   0.249 -1.64   0.216  -0.724  -0.260  -1.13  -1.19 
#>  5 fam_ID_5  -0.0394  0.412  2.37  -1.15  -0.0778  0.446   0.688   0.940  0.268
#>  6 fam_ID_6  -0.107   0.523 -1.77  -1.93   0.840  -0.697   0.519   0.823  0.912
#>  7 fam_ID_7  -0.803  -0.638 -0.422 -1.44  -1.50   -1.44   -0.634  -2.15   0.472
#>  8 fam_ID_8  -0.136   0.212  0.783  0.521  0.514  -0.0401  0.601   0.609 -0.525
#>  9 fam_ID_9  -0.999  -1.74  -0.249 -0.212  0.0313 -0.839  -1.60    1.15  -0.221
#> 10 fam_ID_10  0.379   0.802 -0.999 -1.41   1.13    0.0237 -0.117  -0.245 -0.499
#> # ℹ 990 more rows
#> # ℹ 16 more variables: o_status <lgl>, m_status <lgl>, mgm_status <lgl>,
#> #   mgf_status <lgl>, s1_status <lgl>, s2_status <lgl>, mhs1_status <lgl>,
#> #   mhs2_status <lgl>, o_aoo <dbl>, m_aoo <dbl>, mgm_aoo <dbl>, mgf_aoo <dbl>,
#> #   s1_aoo <dbl>, s2_aoo <dbl>, mhs1_aoo <dbl>, mhs2_aoo <dbl>
#> 
#> $thresholds
#> # A tibble: 8,000 × 5
#>    fam_ID    indiv_ID    role  lower upper
#>    <chr>     <chr>       <chr> <dbl> <dbl>
#>  1 fam_ID_1  fam_ID_1_1  o      -Inf  3.45
#>  2 fam_ID_2  fam_ID_2_1  o      -Inf  2.99
#>  3 fam_ID_3  fam_ID_3_1  o      -Inf  3.38
#>  4 fam_ID_4  fam_ID_4_1  o      -Inf  3.48
#>  5 fam_ID_5  fam_ID_5_1  o      -Inf  2.95
#>  6 fam_ID_6  fam_ID_6_1  o      -Inf  2.68
#>  7 fam_ID_7  fam_ID_7_1  o      -Inf  2.59
#>  8 fam_ID_8  fam_ID_8_1  o      -Inf  2.83
#>  9 fam_ID_9  fam_ID_9_1  o      -Inf  2.91
#> 10 fam_ID_10 fam_ID_10_1 o      -Inf  3.38
#> # ℹ 7,990 more rows
#> 

simulate_under_LTM(fam_vec = c("m","f","s1"), n_fam = NULL, add_ind = FALSE, 
genetic_corrmat = genetic_corrmat, full_corrmat = full_corrmat, n_sim = 200)
#> $sim_obs
#> # A tibble: 200 × 10
#>    fam_ID        m      f      s1 m_status f_status s1_status m_aoo f_aoo s1_aoo
#>    <chr>     <dbl>  <dbl>   <dbl> <lgl>    <lgl>    <lgl>     <dbl> <dbl>  <dbl>
#>  1 fam_ID_1  0.912 -0.832 -2.12   FALSE    FALSE    FALSE        56    61     31
#>  2 fam_ID_2 -1.65  -0.696 -0.0462 FALSE    FALSE    FALSE        47    51     22
#>  3 fam_ID_3 -0.879 -0.164  0.721  FALSE    FALSE    FALSE        35    32     11
#>  4 fam_ID_4 -1.86   0.502  0.464  FALSE    FALSE    FALSE        70    67     40
#>  5 fam_ID_5 -0.796 -0.530  0.968  FALSE    FALSE    FALSE        57    52     27
#>  6 fam_ID_6  0.679  1.78   1.35   FALSE    TRUE     TRUE         57    56     76
#>  7 fam_ID_7 -0.569  1.24   0.987  FALSE    FALSE    FALSE        59    64     40
#>  8 fam_ID_8 -0.831  2.26   1.01   FALSE    TRUE     FALSE        47    44     23
#>  9 fam_ID_9  0.315  0.304 -0.223  FALSE    FALSE    FALSE        38    37     15
#> 10 fam_ID_… -0.214  1.31   0.333  FALSE    TRUE     FALSE        64    84     36
#> # ℹ 190 more rows
#> 
#> $thresholds
#> # A tibble: 600 × 5
#>    fam_ID    indiv_ID    role  lower upper
#>    <chr>     <chr>       <chr> <dbl> <dbl>
#>  1 fam_ID_1  fam_ID_1_1  m      -Inf  1.78
#>  2 fam_ID_2  fam_ID_2_1  m      -Inf  2.13
#>  3 fam_ID_3  fam_ID_3_1  m      -Inf  2.63
#>  4 fam_ID_4  fam_ID_4_1  m      -Inf  1.42
#>  5 fam_ID_5  fam_ID_5_1  m      -Inf  1.74
#>  6 fam_ID_6  fam_ID_6_1  m      -Inf  1.74
#>  7 fam_ID_7  fam_ID_7_1  m      -Inf  1.68
#>  8 fam_ID_8  fam_ID_8_1  m      -Inf  2.13
#>  9 fam_ID_9  fam_ID_9_1  m      -Inf  2.51
#> 10 fam_ID_10 fam_ID_10_1 m      -Inf  1.54
#> # ℹ 590 more rows
#> 

simulate_under_LTM(fam_vec = c(), n_fam = NULL, add_ind = TRUE, h2 = 0.5, 
n_sim = 200, pop_prev = 0.05)
#> Warning message: 
#>  Neither fam_vec nor n_fam is specified...
#> $sim_obs
#> # A tibble: 200 × 5
#>    fam_ID           g       o o_status o_aoo
#>    <chr>        <dbl>   <dbl> <lgl>    <dbl>
#>  1 fam_ID_1  -0.510   -0.921  FALSE       30
#>  2 fam_ID_2  -0.565    0.886  FALSE       19
#>  3 fam_ID_3  -0.274   -0.760  FALSE       12
#>  4 fam_ID_4  -0.473   -0.448  FALSE       11
#>  5 fam_ID_5   1.01     1.39   FALSE       18
#>  6 fam_ID_6   0.00167 -0.0850 FALSE       30
#>  7 fam_ID_7   0.0621  -0.0607 FALSE       19
#>  8 fam_ID_8   1.20     1.35   FALSE       22
#>  9 fam_ID_9   0.820    2.34   TRUE        48
#> 10 fam_ID_10  0.136    1.07   FALSE       17
#> # ℹ 190 more rows
#> 
#> $thresholds
#> # A tibble: 200 × 5
#>    fam_ID    indiv_ID    role    lower upper
#>    <chr>     <chr>       <chr>   <dbl> <dbl>
#>  1 fam_ID_1  fam_ID_1_1  o     -Inf     3.05
#>  2 fam_ID_2  fam_ID_2_1  o     -Inf     3.44
#>  3 fam_ID_3  fam_ID_3_1  o     -Inf     3.67
#>  4 fam_ID_4  fam_ID_4_1  o     -Inf     3.70
#>  5 fam_ID_5  fam_ID_5_1  o     -Inf     3.47
#>  6 fam_ID_6  fam_ID_6_1  o     -Inf     3.05
#>  7 fam_ID_7  fam_ID_7_1  o     -Inf     3.44
#>  8 fam_ID_8  fam_ID_8_1  o     -Inf     3.33
#>  9 fam_ID_9  fam_ID_9_1  o        2.36  2.36
#> 10 fam_ID_10 fam_ID_10_1 o     -Inf     3.50
#> # ℹ 190 more rows
#>