calculate_errors {mpmsim} | R Documentation |
Calculate error (standard error or 95%CI) in elements of a matrix population model.
Description
Given two submatrices of a matrix population model (mat_U
and mat_F
, the
growth/survival matrix and the reproduction matrix respectively) and a sample
size, or matrix/matrices of sample sizes, this function calculates the
standard error or 95% confidence interval (95%CI) for each element of the
matrix. These calculations assume that mat_U
is the result of binomial
processes (i.e., the survival (0/1) of a sample of n individuals), while
mat_F
is the result of Poisson processes (i.e., counts of offspring from n
individuals), where n is the sample size.
Usage
calculate_errors(mat_U, mat_F, sample_size, type = "sem", calculate_A = TRUE)
Arguments
mat_U |
matrix of mean survival probabilities |
mat_F |
matrix of mean fecundity values |
sample_size |
either (1) a single matrix of sample sizes for each
element of the MPM, (2) a list of two named matrices (" |
type |
A character string indicating the type of error to calculate.
Must be one of " |
calculate_A |
A logical argument indicating whether the returned error
information should include the A matrix and its error. Defaults to |
Details
The output is a list containing the original matrices and matrices showing error estimates or confidence intervals.
Value
A list containing the original matrices and the error estimates (or upper and lower confidence intervals) for the U, F and (optionally) A matrices.
Author(s)
Owen Jones jones@biology.sdu.dk
See Also
add_mpm_error()
which simulates matrices with known values and
sample sizes.
Other errors:
add_mpm_error()
,
compute_ci()
,
compute_ci_U()
Examples
# Set up two submatrices
matU <- matrix(c(
0.1, 0,
0.2, 0.4
), byrow = TRUE, nrow = 2)
matF <- matrix(c(
0, 4,
0., 0.
), byrow = TRUE, nrow = 2)
# errors as 95% CI, with a sample size of 20 for all elements
calculate_errors(mat_U = matU, mat_F = matF, sample_size = 20, type = "CI95")
# errors as sem, with a sample size of 20 for all elements
calculate_errors(mat_U = matU, mat_F = matF, sample_size = 20, type = "sem")
# Sample size is a single matrix applied to both F and U matrices
ssMat <- matrix(10, nrow = 2, ncol = 2)
calculate_errors(
mat_U = matU, mat_F = matF, sample_size = ssMat, type =
"sem"
)
# Sample size is a list of two matrices, one for F and one for U.
ssMats <- list(
"mat_F_ss" = matrix(10, nrow = 2, ncol = 2),
"mat_U_ss" = matrix(10, nrow = 2, ncol = 2)
)
calculate_errors(
mat_U = matU, mat_F = matF, sample_size = ssMats, type =
"sem"
)