R/perturb_stochastic.R
perturb_stochastic.Rd
Calculate stochastic elasticities given a time-series of matrix population models and corresponding population vectors, using the method described in Haridas et al. (2009).
perturb_stochastic(X_t, u_t)
A list of matrix population models
A list of corresponding population vectors
A list of three matrices:
matrix of stochastic elasticities
matrix of stochastic elasticities to mean transition rates
matrix of stochastic elasticities to the variance in transition rates
Haridas, C. V., Tuljapurkar, S., & Coulson, T. 2009. Estimating stochastic elasticities directly from longitudinal data. Ecology Letters, 12, 806-812. <doi:10.1111/j.1461-0248.2009.01330.x>
Other perturbation analysis:
perturb_matrix()
,
perturb_trans()
,
perturb_vr()
,
pop_vectors()
# generate list of random MPMs
N <- 20 # number of years
s <- 3 # matrix dimension
X <- list() # matrix population model at time t
u <- list() # population vector at time t
for (t in 1:N) {
X[[t]] <- matrix(runif(s^2), nrow = s, ncol = s)
}
# derive corresponding series of population vectors
u <- pop_vectors(X)
# calculate stochastic elasticities
perturb_stochastic(X, u)
#> $E
#> [,1] [,2] [,3]
#> [1,] 0.1131968 0.1160238 0.12261977
#> [2,] 0.1325760 0.1101893 0.10196380
#> [3,] 0.1137971 0.1159435 0.07368995
#>
#> $E_mu
#> [,1] [,2] [,3]
#> [1,] 0.1292196 0.1331185 0.13149498
#> [2,] 0.1308115 0.1099255 0.10556746
#> [3,] 0.1157530 0.1163644 0.08433978
#>
#> $E_sigma
#> [,1] [,2] [,3]
#> [1,] -0.016022818 -0.0170947104 -0.008875206
#> [2,] 0.001764544 0.0002638290 -0.003603657
#> [3,] -0.001955948 -0.0004209305 -0.010649827
#>