Skip to contents

Modular functions for the population simulator for performing correlated environmentally stochastic adjustments to transition rates.

Usage

population_env_stoch(
  populations,
  fecundity_matrix,
  fecundity_max,
  survival_matrix,
  standard_deviation,
  correlation
)

Arguments

populations

Number of populations.

fecundity_matrix

Matrix of transition fecundity rates (Leslie/Lefkovitch matrix with non-zero fecundities only).

fecundity_max

Maximum transition fecundity rate (in Leslie/Lefkovitch matrix).

survival_matrix

Matrix of transition survival rates (Leslie/Lefkovitch matrix with non-zero survivals only).

standard_deviation

Standard deviation matrix for applying environmental stochasticity to transition rates.

correlation

List containing either an environmental correlation matrix (correlation_matrix), a pre-calculated transposed (Cholesky) decomposition matrix (t_decomposition_matrix), or a compact transposed (Cholesky) decomposition matrix (t_decomposition_compact_matrix) and a corresponding map of population indices (t_decomposition_compact_map), as per SpatialCorrelation class attributes.

Value

Environmental stochasticity calculation function: function(fecundity_array, survival_array, occupied_indices), where:

fecundity_array

3D array of fecundity rates (stages rows by stages columns by populations deep).

survival_array

3D array of survival rates (stages rows by stages columns by populations deep).

occupied_indices

Array of indices for those populations occupied.

returns

List containing stochastically varied fecundity and survival arrays.

Examples

fecundity_matrix <- array(c(0, 0, 0, 3, 0, 0, 4, 0, 0), c(3, 3))
survival_matrix <- array(c(0, 0.5, 0, 0, 0, 0.7, 0, 0, 0.8), c(3, 3))
standard_deviation <- (fecundity_matrix + survival_matrix) * 0.3
variation_array <- array(rep(seq(0.85, 1.15, 0.05), each = 9), c(3, 3, 7))
fecundity_array <- array(fecundity_matrix, c(3, 3, 7)) * variation_array
survival_array <- array(survival_matrix, c(3, 3, 7)) * variation_array
stage_abundance <- matrix(c(
   7, 13, 0, 26, 0, 39, 47,
   2, 0, 6, 8, 0, 12, 13,
   0, 3, 4, 6, 0, 9, 10
), nrow = 3, ncol = 7, byrow = TRUE)
occupied_indices <- (1:7)[-5]
env_stoch_function <- population_env_stoch(
  populations = 7, fecundity_matrix, fecundity_max = NULL, survival_matrix,
  standard_deviation, correlation = NULL
)
env_stoch_function(fecundity_array, survival_array, occupied_indices)
#> $fecundity_array
#> , , 1
#> 
#>      [,1]     [,2]     [,3]
#> [1,]    0 2.186898 2.915864
#> [2,]    0 0.000000 0.000000
#> [3,]    0 0.000000 0.000000
#> 
#> , , 2
#> 
#>      [,1]     [,2]    [,3]
#> [1,]    0 2.257598 3.01013
#> [2,]    0 0.000000 0.00000
#> [3,]    0 0.000000 0.00000
#> 
#> , , 3
#> 
#>      [,1]     [,2]     [,3]
#> [1,]    0 3.947067 5.262756
#> [2,]    0 0.000000 0.000000
#> [3,]    0 0.000000 0.000000
#> 
#> , , 4
#> 
#>      [,1]     [,2]     [,3]
#> [1,]    0 3.078633 4.104844
#> [2,]    0 0.000000 0.000000
#> [3,]    0 0.000000 0.000000
#> 
#> , , 5
#> 
#>      [,1] [,2] [,3]
#> [1,]    0 3.15  4.2
#> [2,]    0 0.00  0.0
#> [3,]    0 0.00  0.0
#> 
#> , , 6
#> 
#>      [,1]     [,2]     [,3]
#> [1,]    0 2.167926 2.890569
#> [2,]    0 0.000000 0.000000
#> [3,]    0 0.000000 0.000000
#> 
#> , , 7
#> 
#>      [,1]     [,2]     [,3]
#> [1,]    0 2.635184 3.513578
#> [2,]    0 0.000000 0.000000
#> [3,]    0 0.000000 0.000000
#> 
#> 
#> $survival_array
#> , , 1
#> 
#>           [,1]      [,2]      [,3]
#> [1,] 0.0000000 0.0000000 0.0000000
#> [2,] 0.3756352 0.0000000 0.0000000
#> [3,] 0.0000000 0.5416915 0.6429154
#> 
#> , , 2
#> 
#>           [,1]      [,2]      [,3]
#> [1,] 0.0000000 0.0000000 0.0000000
#> [2,] 0.3846685 0.0000000 0.0000000
#> [3,] 0.0000000 0.5540691 0.6619634
#> 
#> , , 3
#> 
#>           [,1]      [,2]      [,3]
#> [1,] 0.0000000 0.0000000 0.0000000
#> [2,] 0.6637317 0.0000000 0.0000000
#> [3,] 0.0000000 0.9140909 0.9915572
#> 
#> , , 4
#> 
#>           [,1]      [,2]      [,3]
#> [1,] 0.0000000 0.0000000 0.0000000
#> [2,] 0.5378074 0.0000000 0.0000000
#> [3,] 0.0000000 0.7912284 0.9481373
#> 
#> , , 5
#> 
#>       [,1]  [,2] [,3]
#> [1,] 0.000 0.000 0.00
#> [2,] 0.525 0.000 0.00
#> [3,] 0.000 0.735 0.84
#> 
#> , , 6
#> 
#>           [,1]      [,2]      [,3]
#> [1,] 0.0000000 0.0000000 0.0000000
#> [2,] 0.3269199 0.0000000 0.0000000
#> [3,] 0.0000000 0.4023555 0.3788834
#> 
#> , , 7
#> 
#>          [,1]      [,2]      [,3]
#> [1,] 0.000000 0.0000000 0.0000000
#> [2,] 0.430251 0.0000000 0.0000000
#> [3,] 0.000000 0.6112181 0.9956671
#> 
#>