simulation: Simulating Predictors and Response Data

simulationR Documentation

Simulating Predictors and Response Data

Description

These functions simulate predictor variables and response outcomes, and summarize the analysis of simulated data.

Usage

sim.x(n, m, group = NULL, corr = 0.6, v = rep(1, m), p = 0.5, genotype = NULL)

sim.eta(x, mu = 0, coefs = NULL, herit = 0.1, sigma = 1, p.neg = 0.5)

sim.y(x, mu = 0, coefs = NULL, herit = 0.1, p.neg = 0.5, sigma = 1, quantiles = 0.5, , theta = 3, df = 3)

sim.out(coefs.p, coefs.est, alpha = c(0.05, 0.01))

Arguments

n

number of simulated data points (individuals).

m

number of simulated continuous variables or discrete genetic markers.

group

a numeric vector, or an integer, or a list indicating the groups of variables. If group = NULL, all the variables form a single group. If group = K, the predictors are evenly divided into groups each with K predictors. If group is a numberic vector, it defines groups as follows: Group 1: (group[1]+1):group[2], Group 2: (group[2]+1):group[3], Group 3: (group[3]+1):group[4], ..... If group is a list of variable names, group[[k]] includes variables in the k-th group.

corr

correlation between variables. If length(corr)=1, within-group and between correlations are corr and zero. If length(corr)=2, within-group and between correlations are corr[1] and corr[2].

v

variances of simulated variables.

p

minor allelic frequencies for simulated markers.

genotype

transform some continuous variables to three-level genotypes.

x

a design matrix of simulated variables.

mu

intercept.

coefs

coefficients of variables. If coefs = NULL, the coefficients are calculated by herit. If length(coefs) < ncol(x), all other coefficients are set to zero, i.e., coefs is expanded to c(coefs, 0, ..., 0). The linear predictors equal mu + x * coefs.

herit

heritabilities of variables (proportions of variance explained by variables), which is used to calculate the coefficients. If coefs is given, herit is not used. If herit is a single value (for example, herit = 0.05), it is the total heritability of all variables. If herit is a vector, it gives the heritabilities of the corresponding variables (for example, if herit = c(h1, h2, h3), the heritabilities are h1, h2 and h3, for the first three variables, and zero for other variables).

p.neg

proportion of negative coefficients.

sigma

residual standard deviation for normal or t response.

quantiles

quantiles for generating binary or ordinal responses.

theta

shape parameter for negative binomial or beta responses.

df

degree of freedom of t response.

coefs.p

a matrix of p-values of coefficients. The rows and columns are coefficients and simulations, respectively.

coefs.est

a matrix of coefficient estimates. The rows and columns are coefficients and simulations, respectively.

alpha

significance levels for calculating power.

Details

The function sim.x() simulates m variables or genotypes of m markers for n individuals.

The function sim.y() calculates coefficient values if coefs = NULL and the linear predictors eta = mu + x * coefs, simulates n normal phenotypes with mean eta and variance sigma^2, categorizes the normal phenotypes to binary or ordinal phenotypes, simulates survival outcome, count outcomes from Poisson or negative binomial, Student-t outcomes, and beta outcome.

The function sim.out() calculates statistical powers and estimates for all variables.

Value

sim.x() returns a n x m data frame of continuous values or genotypes 0, 1, 2.

sim.y() returns a list of normal outcome y.normal, binary or ordinal outcome y.ordinal, poisson outcome y.poisson, negative binomial outcome y.nb, t outcome y.t, beta outcome y.beta, survival outcome y.surv, linear predictor values eta, coefficients coefs, residual standard deviation sigma and heritabilities herit.

sim.out() returns a list of power and estimate for each variable.

Author(s)

Nengjun Yi, nyi@uab.edu

Examples

See examples in the functions bglm, bpolr, bcoxph.


nyiuab/BhGLM documentation built on June 12, 2024, 9:28 p.m.