simulation: Simulation of phenotypes and model components

simulationR Documentation

Simulation of phenotypes and model components

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

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:

  • model a character string, either 'add_animal' or 'competition'. In the former, a single breeding value per individual will be simulated, while in the latter direct and competition values are simulated.

  • Nparents passed to breedR.sample.pedigree.

  • sigma2_a numeric. For the add_animal model, the variance of the additive genetic effect. For the competition model, the 2\times 2 covariance matrix of direct and competition genetic effects. Passed to breedR.sample.BV as Sigma.

  • check.factorial passed to breedR.sample.pedigree

  • pec numeric. If present, and only under the competition model, it simulates a Permanent Environmental Competition effect with the given variance.

  • relations character. If present and equals half-sibs it will generate a pedigree with unknown sires, so that relationships in the offspring are either unrelated or half-sibs are possible. Otherwise, both parents are known and full-sibs are also possible.

Note that only one generation is simulated.

spatial is a list with the following elements:

  • model a character string, either 'AR' or 'splines'.

  • grid.size a numeric vector of length two with the number of rows and columns of trees. Note that the spacing between trees is equal in both dimensions.

  • rho/n.knots passed to breedR.sample.AR or to breedR.sample.splines as nkn.

  • sigma2_s passed to breedR.sample.AR or to breedR.sample.splines as sigma2.

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


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 Aug. 6, 2024, 9:10 p.m.