sim.pop | R Documentation |
Simulate a population sample and return a list with (i) a matrix of
size s x n
, s
specimens and n
characters, (ii) a
vector with the estimated population variances for each character,
and (iii) the estimated shrinkage correlation matrix if the true
correlation matrix is provided.
sim.pop(psample, n, c, R)
psample |
Numeric, number of specimens the simulated population sample should include. |
n |
Numeric, number of morphological traits to be simulated. |
c |
Numeric, vector with the variances for the species within a population (see details). |
R |
(Optional) matrix, correlation matrix. (see details). |
The parameter c
is the population noise and it is used to sample
n
characters for each of the psample
specimens from a
normal distribution x ~ N(0,c)
.
If the population noise is assumed to be the same for all the characters
within the species, then the length of c
is 1 and equals to the value
of this variance.
If it differs, then a vector of length n
has to
be provided specifying the variance for each of the characters
If a correlation matrix, R
, is provided, then it is added to the
population matrix. Note that the correlation matrix needs to be of class "matrix"
and symmetric. You can take a look at data-raw/sim.R.R
to follow
the commands used to generate this matrix, object R.sim
, which is used
in the examples.
$P |
Matrix with the simulated population sample |
$var |
Vector with the estimated variances |
$Rsh |
Estimated shrinkage correlation matrix, only returned if |
Sandra Alvarez-Carretero and Mario dos Reis
sim.morpho
, write.morpho
# A) Simulation setup: Simulate a population with
# psample = 20 specimens, and sample n = 100 characters with
# a low population noise, c = 0.25.
sim.pop( psample = 20, n = 100, c = 0.25 )
# B) Simulation setup: Simulate a population with
# psample = 20 specimens, and sample n = 100 characters with
# a low population noise, c = 0.25, and a low trait correlation
# rho = 0.50 (correlation matrix that follows
# the constant correlation model, i.e. all non-diagonal values
# equal to rho).
sim.pop( psample = 20, n = 100, c = 0.25, R = sim.R )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.