| Type: | Package |
| Title: | Demographic Vulnerability Metrics for Matrix Population Models |
| Version: | 0.1.0 |
| Description: | Simulates temporally structured perturbations in matrix population models and computes population reduction and integrated demographic vulnerability across perturbation regimes. Perturbations can be applied to adult survival, juvenile survival, fecundity, all demographic entries, or user-defined matrix elements. The package provides tools to simulate individual perturbation trajectories, evaluate perturbation grids, and summarize demographic vulnerability in structured populations. |
| License: | MIT + file LICENSE |
| Encoding: | UTF-8 |
| RoxygenNote: | 8.0.0 |
| Suggests: | ggplot2, knitr, rmarkdown, testthat (≥ 3.0.0) |
| VignetteBuilder: | knitr |
| Config/testthat/edition: | 3 |
| URL: | https://github.com/agimenezromero/demovuln-r |
| BugReports: | https://github.com/agimenezromero/demovuln-r/issues |
| NeedsCompilation: | no |
| Packaged: | 2026-05-22 11:12:33 UTC; alex |
| Author: | Àlex Giménez-Romero
|
| Maintainer: | Àlex Giménez-Romero <alex.gimenez@csic.es> |
| Repository: | CRAN |
| Date/Publication: | 2026-05-28 13:40:07 UTC |
Apply a proportional perturbation to a projection matrix
Description
Apply a proportional perturbation to a projection matrix
Usage
apply_perturbation(
model,
target,
magnitude,
survival_affects_fecundity = TRUE,
custom_mask = NULL
)
Arguments
model |
A |
target |
One of |
magnitude |
Proportional reduction applied to the selected entries.
Must lie in |
survival_affects_fecundity |
Logical. If |
custom_mask |
Optional logical matrix used when |
Value
Perturbed projection matrix.
Build a perturbation target mask
Description
Return a logical matrix selecting the entries affected by a perturbation.
Usage
build_target_mask(
model,
target,
survival_affects_fecundity = TRUE,
custom_mask = NULL
)
Arguments
model |
A |
target |
One of |
survival_affects_fecundity |
Logical. If |
custom_mask |
Optional logical matrix used when |
Value
Logical matrix with the same dimensions as the projection matrix.
Compute integrated demographic vulnerability
Description
Compute integrated demographic vulnerability
Usage
compute_vulnerability(table, column = "population_reduction")
Arguments
table |
Data frame returned by |
column |
Name of the column containing percent population reduction. |
Value
Mean percent population reduction, ignoring missing values.
Dominant eigenvalue of a projection matrix
Description
Dominant eigenvalue of a projection matrix
Usage
dominant_eigenvalue(A)
Arguments
A |
Numeric square projection matrix. |
Value
The real part of the eigenvalue with largest modulus.
Enumerate perturbation-grid scenarios
Description
Enumerate perturbation-grid scenarios
Usage
grid_scenarios(grid, skip_infeasible = TRUE)
Arguments
grid |
A |
skip_infeasible |
Logical. If |
Value
Data frame with columns magnitude, duration, period, and
feasible.
Matrix population model
Description
Create a matrix population model and define the demographic targets used by perturbation functions.
Usage
matrix_population_model(
A,
fecundity_mask = NULL,
fecundity_rows = 1L,
adult_stages = NULL,
juvenile_stages = NULL,
name = NULL
)
Arguments
A |
Numeric square projection matrix. Columns are source stages at time
|
fecundity_mask |
Optional logical matrix with the same dimensions as |
fecundity_rows |
Integer vector identifying rows interpreted as newborn or reproductive-output rows. Defaults to the first row. |
adult_stages |
Optional integer vector with source-stage columns interpreted as adult or reproductive stages. |
juvenile_stages |
Optional integer vector with source-stage columns interpreted as juvenile or pre-reproductive stages. |
name |
Optional model or species label. |
Value
An object of class demovuln_model.
Perturbation grid
Description
Perturbation grid
Usage
perturbation_grid(magnitudes, durations, periods)
Arguments
magnitudes |
Numeric vector of proportional reductions. |
durations |
Integer vector of perturbation durations. |
periods |
Integer vector of perturbation periods. |
Value
An object of class demovuln_grid.
Build a perturbation grid from frequencies
Description
Build a perturbation grid from frequencies
Usage
perturbation_grid_from_frequencies(
magnitudes,
durations,
frequencies,
generation_time = 1,
rounding = c("nearest", "floor", "ceil")
)
Arguments
magnitudes |
Numeric vector of proportional reductions. |
durations |
Integer vector of perturbation durations. |
frequencies |
Numeric vector of event frequencies, interpreted as events
per |
generation_time |
Number of projection intervals corresponding to one reference generation or time unit. |
rounding |
One of |
Value
An object of class demovuln_grid.
Compute percent population reduction
Description
Compute percent population reduction
Usage
population_reduction(final_population, baseline_final_population)
Arguments
final_population |
Final population size under perturbed dynamics. |
baseline_final_population |
Final population size under unperturbed baseline dynamics. |
Value
Percent population reduction relative to the baseline.
Simulate a perturbation grid
Description
Simulate a perturbation grid
Usage
run_grid(
model,
target,
grid,
t_max,
recovery_steps = 0L,
start = 0L,
initial_state = NULL,
normalize_by_lambda = TRUE,
survival_affects_fecundity = TRUE,
custom_mask = NULL,
return_trajectories = FALSE,
skip_infeasible = TRUE,
force_during_recovery = FALSE
)
Arguments
model |
A |
target |
One of |
grid |
A |
t_max |
Number of projection intervals in the perturbation-forcing window. |
recovery_steps |
Number of additional unperturbed projection intervals. |
start |
Projection interval at which the first perturbation event starts. |
initial_state |
Optional initial population vector. |
normalize_by_lambda |
Logical. If |
survival_affects_fecundity |
Logical. If |
custom_mask |
Optional logical matrix used when |
return_trajectories |
Logical. If |
skip_infeasible |
Logical. If |
force_during_recovery |
Logical. If |
Value
An object of class demovuln_grid_result.
Simulate dynamics under a temporally structured perturbation
Description
Simulate dynamics under a temporally structured perturbation
Usage
simulate_dynamics(
model,
target = "adult_survival",
magnitude,
duration,
period,
t_max,
recovery_steps = 0L,
start = 0L,
initial_state = NULL,
normalize_by_lambda = TRUE,
survival_affects_fecundity = TRUE,
custom_mask = NULL,
return_stage_vectors = FALSE,
force_during_recovery = FALSE
)
Arguments
model |
A |
target |
One of |
magnitude |
Proportional reduction applied to the selected entries. |
duration |
Number of consecutive projection intervals during which each perturbation event is active. |
period |
Number of projection intervals between perturbation onsets. |
t_max |
Number of projection intervals in the perturbation-forcing window. |
recovery_steps |
Number of additional unperturbed projection intervals after the forcing window. |
start |
Projection interval at which the first perturbation event starts.
The default |
initial_state |
Optional initial population vector. If omitted, the stable stage distribution of the unperturbed model is used. |
normalize_by_lambda |
Logical. If |
survival_affects_fecundity |
Logical. If |
custom_mask |
Optional logical matrix used when |
return_stage_vectors |
Logical. If |
force_during_recovery |
Logical. If |
Value
An object of class demovuln_simulation.
Stable stage distribution
Description
Stable stage distribution
Usage
stable_stage_distribution(model)
Arguments
model |
A |
Value
Numeric vector normalized to sum to one.