Compute 95% confidence intervals for derived estimates from the U submatrix of a matrix population model
Source:R/compute_ci_U.R
compute_ci_U.Rd
This function computes the 95% confidence interval for measures derived from
the U submatrix of a matrix population model using parametric bootstrapping.
In this approach a sampling distribution of the U submatrix is generated by
taking a large number of random independent draws using the sampling
distribution of each underlying transition rate. The approach rests on our
assumption that survival-related processes are binomial (see the function
add_mpm_error()
for details).
Arguments
- mat_U
A matrix that describes the growth and survival process.
- sample_size
either (1) a single matrix of sample sizes for each element of the U matrix, (2) a single value applied to the whole matrix
- FUN
A function to apply to each simulated matrix population model. This function must take, as input, a single U submatrix of a matrix population model (i.e., the U matrix). For functions that require the A matrix, use
compute_ci
.- ...
Additional arguments to be passed to
FUN
.- n_sim
An integer indicating the number of simulations to run. Default is 1000.
- dist.out
Logical. If TRUE, returns a list with both the quantiles and the simulated estimates. Default is FALSE.
Value
If dist.out is FALSE, a numeric vector of the 2.5th and 97.5th
quantiles of the estimated measures. If dist.out = TRUE
, a list with two
elements: quantiles
and estimates
. quantiles
is a numeric vector of
the 2.5th and 97.5th quantiles of the estimated measures, and estimates
is a numeric vector of the estimated measures.
Details
The main inputs is the U matrix, which describes the survival-related processes. The underlying assumption is that the U matrix is the average of a binomial process. The confidence interval will depend largely on the sample size used.
References
Chapter 12 in Caswell, H. (2001). Matrix Population Models. Sinauer Associates Incorporated.
See also
Other errors:
add_mpm_error()
,
calculate_errors()
,
compute_ci()
Author
Owen Jones jones@biology.sdu.dk
Examples
set.seed(42) # set seed for repeatability
# Data for use in example
matU <- matrix(c(
0.1, 0.0,
0.2, 0.4
), byrow = TRUE, nrow = 2)
# Example of use to calculate 95% CI of life expectancy
compute_ci_U(
mat_U = matU, sample_size = 10, FUN =
Rage::life_expect_mean
)
#> 2.5% 97.5%
#> 1.000000 2.334524
# Example of use to calculate 95% CI of generation time and show the
# distribution of those bootstrapped estimates
xx <- compute_ci_U(
mat_U = matU, sample_size = 100, FUN =
Rage::life_expect_mean, dist.out = TRUE
)
summary(xx$quantiles)
#> Min. 1st Qu. Median Mean 3rd Qu. Max.
#> 1.314 1.405 1.495 1.495 1.586 1.676
hist(xx$estimates)