data_simu: function to generate a dataset which is compatible with the...

Description Usage Arguments Value Examples

Description

This function generates a dataset which contains a matrix corresponding to the genetic information and a vector of observations. This dataset corresponds to the type of arguments which is expected in the funtion HiLMM.

Usage

1
data_simu(n, N, eta_star, q)

Arguments

n

size of the vector of observations that the user wants to generate.

N

number of columns of the genetic information matrix that the user wants to generate.

eta_star

value of the heritability.

q

proportion of non zero components in the random effects associated to the genetic information matrix.

Value

Y

vector of observations of size n

W

Matrix of size n x N which contains entries with 0,1 and 2

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
library(HiLMM)
data_sim=data_simu(100,1000,0.5,0.5)
 Y=data_sim$Y
 W=data_sim$W
## The function is currently defined as
function (n, N, eta_star, q) 
{
    sigma_u = 1
    P = runif(N, 0.1, 0.5)
    W = matrix(0, n, N)
    for (j in 1:N) {
        W[, j] = rbinom(n, 2, P[j])
    }
    nb_comp_non_zero = q * N
    sigma_e = sqrt(q * N * sigma_u^2 * (1 - eta_star)/eta_star)
    b = sample(1:N, nb_comp_non_zero)
    a1 = sort(b)
    u = rnorm(nb_comp_non_zero, 0, sigma_u)
    e = rnorm(n, 0, sigma_e)
    U = matrix(0, N)
    U[a1] = u
    Z = scale(W, center = TRUE, scale = TRUE)
    Y = Z %*% U + e
    list(Z = Z, Y = Y)
  }

HiLMM documentation built on May 2, 2019, 6:59 a.m.