simulation: Simulation of phenotypes and model components

Description Usage Arguments Details Examples

Description

These functions allow to draw samples from several models (spatial, genetic, competition, etc.) and to combine them to produce a simulated phenotype. The resulting dataset can then be fitted with breedR to compare the estimations with the true underlying parameters. breedR.sample.phenotype is the main function in the group, as it makes use of the rest to simulate a phenotype's components.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
breedR.sample.phenotype(
  fixed = NULL,
  random = NULL,
  genetic = NULL,
  spatial = NULL,
  residual.variance = 1,
  N = NULL
)

breedR.sample.AR(size, rho, sigma2, N = 1)

breedR.sample.splines(coord, nkn, sigma2, N = 1)

breedR.sample.BV(ped, Sigma, N = 1)

breedR.sample.pedigree(Nobs, Nparents, check.factorial = TRUE)

breedR.sample.ranef(dim, var, Nlevels, labels = NULL, N = Nlevels, vname = "X")

Arguments

fixed

a numeric vector of regression coefficients.

random

a list of random effects specifications, where each element is itself a list with elements nlevels and sigma2.

genetic

a list with the additive genetic effect specifications. See Details.

spatial

a list with the spatial effect specifications. See Details.

residual.variance

is a positive number giving the value of the residual variance.

N

number of simulated individuals. If spatial is specified, N is overridden by the product of spatial$grid.size. Otherwise it is required. If genetic is specified, N is the size of the offspring only.

size

numeric. A vector of length two with the number of rows and columns in the field trial

rho

numeric. A vector of length two with the autocorrelation parameters for the row and column autoregressive processes

sigma2

numeric. The marginal variance

coord

numeric. A two-column matrix(-like) with spatial coordinates.

nkn

numeric. A vector of length two with the number of (inner) knots in each dimension

ped

a pedigree object

Sigma

numeric. The additive genetic variance. Either a variance for a single additive genetic effect, or a positive-definite matrix with the covariance structure for a set of correlated genetic effects

Nobs

numeric. Number of individuals to sample

Nparents

numeric. Vector of length two. Number of dams and sires to randomly mate.

check.factorial

logical. If TRUE (default), it checks whether all the possible matings had taken place at least once. If not, it stops with an error.

dim

numeric. Dimension of the effect (e.g. n. of traits)

var

numeric matrix. (Co)variance matrix

Nlevels

numeric. Number of individuals values to sample

labels

character vector of labels for each level.

vname

string. A name for the resulting variables

Details

The design matrix for the fixed effects (if given) is a column of ones and a matrix of random uniform values in (0, 1). Therefore, the first element in fixed gives the overall intercept.

genetic is a list with the following elements:

Note that only one generation is simulated.

spatial is a list with the following elements:

breedR.sample.AR simulates a two-dimensional spatial process as the kronecker product of first-order autoregressive processes in each dimension.

breedR.sample.splines simulates a two-dimensional spatial process as the kronecker product of B-splines processes in each dimension.

breedR.sample.BV simulates a set of breeding values (BV) given a pedigree

breedR.sample.pedigree simulates a one-generation pedigree from random mating of independent founders. Note that if check.factorial is FALSE, you can have some founders removed from the pedigree.

breedR.sample.ranef simulates a random effect with a given variance.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
breedR.sample.phenotype(fixed   = c(mu = 10, x = 2),
                        random = list(u = list(nlevels = 3,
                                               sigma2  = 1)),
                        genetic = list(model    = 'add_animal',
                                       Nparents = c(10, 10),
                                       sigma2_a = 2,
                                       check.factorial = FALSE),
                        spatial = list(model     = 'AR',
                                       grid.size = c(5, 5),
                                       rho       = c(.2, .8),
                                       sigma2_s  = 1),
                        residual.variance = 1)

famuvie/breedR documentation built on Sept. 6, 2021, 4:50 a.m.