Skip to contents

Generate random F

Usage

generate_random_F(
  K,
  M,
  g_F = function(n) {
     runif(n, -1, 1)
 },
  nz_factor,
  omega,
  h2_trait,
  pad = FALSE
)

Arguments

g_F

Function from which non-zero elements of F are generated

nz_factor

Number of non-zero elements of each factor if F is to be generated.

omega

Proportion of trait heritability explained by factors

h2_trait

Trait heritability

pad

Add single trait factors? (See details)

Value

A matrix

Details

Generate a random set of (at least) K factors for M traits. The number of traits affected by each factor is given by nz_factor. Each effect is chosen as a random draw from function g_F. If any rows of the resulting matrix corresponding to non-zero elements of omega are all zero and pad = TRUE, single-trait factors are added. Finally, the matrix is re-scaled so that colSums(F_mat^2) = omega*h2_trait.