Skip to content

Commit

Permalink
Built site for gh-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
willvieira committed Dec 6, 2023
1 parent 1f8d91a commit d5403e9
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .nojekyll
Original file line number Diff line number Diff line change
@@ -1 +1 @@
92aee76e
e977529f
6 changes: 3 additions & 3 deletions guide_IPM.html

Large diffs are not rendered by default.

Binary file modified guide_IPM_files/figure-html/fig-sizeDist-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions marginal_lambda.html
Original file line number Diff line number Diff line change
Expand Up @@ -371,10 +371,10 @@ <h2 class="anchored" data-anchor-id="results">Results</h2>
<section id="spatial-distribution-of-sensitivity-to-the-covariates" class="level2">
<h2 class="anchored" data-anchor-id="spatial-distribution-of-sensitivity-to-the-covariates">Spatial Distribution of sensitivity to the covariates</h2>
<p>So far, we have discussed the sensitivity of <span class="math inline">\(\lambda\)</span> to competition and climate using averages across species and temperature range positions. Below, we summarize the raw observed sensitivity to competition, climate, and their ratio for each species-plot observation. For plots with more than one observation, we averaged each of the three metrics across the observations.</p>
<div class="cell" data-hash="marginal_lambda_cache/html/funcPrint_0635ca8cdb3ea55524e88cda264c5704">
<div class="cell" data-hash="marginal_lambda_cache/html/funcPrint_bcdf91c13c01cd8a3e88cc452b2e7865">

</div>
<div class="cell" data-hash="marginal_lambda_cache/html/print_plots_7c54c9f6f32927864239ebe983b9962f">
<div class="cell" data-hash="marginal_lambda_cache/html/print_plots_cd0782955c36b32e62ab6512d9f9b9d8">
<div class="cell-output-display">
<p><img src="marginal_lambda_files/figure-html/print_plots-1.png" class="img-fluid" width="816"></p>
</div>
Expand Down
2 changes: 1 addition & 1 deletion search.json
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@
"href": "guide_IPM.html#run-the-ipm",
"title": "15  A guide to use the forest-IPM code",
"section": "Run the IPM",
"text": "Run the IPM\nThe primary function of the forest IPM is the mkKernel().\n\nK_abibal = mkKernel(\n Nvec_intra = N_sp,\n Nvec_inter = N_het,\n delta_time = delta_time,\n plotSize = plotSize,\n Temp = Temp,\n Prec = Prec,\n pars = pars_abibal,\n plot_random = plot_random\n)\n\nThe K_abibal object is a list of the \\(P\\), \\(F\\), and \\(K\\) matrices of dimension \\(z^2\\) as described in Equation 14.2. This kernel object is the core output of the IPM model, serving as the foundation for projecting populations over time or calculating the asymptotic population growth rate (\\(\\lambda\\)) and other metrics.\nWe can extract the asymptotic population growth rate (\\(\\lambda\\)) using the leading eigen value of the matrix \\(k\\):\n\n(max(Re(eigen(K_abibal$K)$values)))\n\n[1] 1.211457\n\n\nGiven that our matrix is density-dependent, we can project the population vector over time by continuously updating the Kernel at each time step to account for the evolving size distribution of individuals. In the following code, we demonstrate a simple loop to trace the evolving population over time while assuming that there is only conspecific density-dependence (N_het = 0). Note that this code is slow and can take 5-10 minutes to run due to the slow eigen() computation.\n\nset.seed(0.0)\n\n# Initial population size (small)\nN_sp <- init_pop(\n params = pars_abibal,\n L = 127,\n h = 1,\n N = 1\n)\n\n# define no heterospecific competition\nN_het <- init_pop(\n params = pars_abibal,\n L = 127,\n h = 1,\n N = 0\n)\n\n# generate initial Kernel\nK0 = mkKernel(\n Nvec_intra = N_sp,\n Nvec_inter = N_het,\n delta_time = delta_time,\n plotSize = plotSize,\n Temp = Temp,\n Prec = Prec,\n pars = pars_abibal,\n plot_random = plot_random\n)\n\n\ntime_max = 200\n# vector to save lambda over time\nlambdas = max(Re(eigen(K0$K)$values))\n# matrix to save size distribution\nntmat = matrix(0, nrow = length(N_sp$Nvec), ncol = time_max)\nntmat[, 1] <- N_sp$Nvec\n\nfor(Time in 2:time_max)\n{\n # update the state\n ntmat[, Time] <- K0$K %*% ntmat[, Time - 1]\n N_sp$Nvec <- ntmat[, Time]\n\n # update the kernel\n K0 <- mkKernel(\n Nvec_intra = N_sp,\n Nvec_inter = N_het,\n delta_time = delta_time,\n plotSize = plotSize,\n Temp = Temp,\n Prec = Prec,\n pars = pars_abibal,\n plot_random = plot_random\n )\n\n # calculate pop growth rate\n lambdas[Time] = max(Re(eigen(K0$K)$values))\n\n cat(' Time step', Time, 'of', time_max, '(', round(Time/time_max * 100, 1), '%)\\r')\n}\n\n\n\n\nFor each time iteration, we saved the focal species’ size (\\(z\\)) distribution and the population growth rate (\\(\\lambda\\)). We can visualize how each measure involved time for these species-specific conditions. In Figure 15.2 and Figure 15.3, we can visualize how \\(\\lambda\\) and the size density distribution evolve.\n\n\nCode\nntmat |>\n as_tibble() |>\n pivot_longer(cols = everything(), values_to = 'Density') |>\n mutate(Time = parse_number(name)) |>\n group_by(Time) |>\n reframe(N = sum(Density)) |>\n left_join(\n lambdas |>\n enframe(name = 'Time') |>\n rename(lambda = value)\n ) |>\n pivot_longer(cols = c(N, lambda)) |>\n mutate(\n name = factor(name, levels = c('N', 'lambda'), labels = c(expression(textstyle('Population size')), expression(lambda)))\n ) |>\n ggplot() +\n aes(Time, value) +\n facet_wrap(\n ~name,\n scales = 'free_y',\n labeller = label_parsed\n ) +\n geom_path(linewidth = 1.2) +\n theme_classic() +\n labs(\n y = NULL\n )\n\n\n\n\n\nFigure 15.2: Population size (left panel) and population growth rate (right panel) over time.\n\n\n\n\n\n\nCode\nsuppressPackageStartupMessages(library(plotly))\n\nntmat |>\n as.data.frame() |>\n pivot_longer(cols = everything(), values_to = 'Density') |>\n mutate(Time = parse_number(name)) |>\n group_by(Time) |>\n mutate(x = 127:(n() + 126)) |>\n ggplot() +\n aes(x, Density) +\n aes(group = name) +\n aes(frame = Time) +\n geom_path() +\n theme_classic() +\n xlab('Size (mm)') ->\np\n\nggplotly(p) |>\n animation_opts(frame = 50) |>\n animation_slider(\n hide = FALSE,\n currentvalue = list(prefix = \"Time step: \", font = list(color = 'black'))\n ) |>\n animation_button(\n x = 0.9, xanchor = 'left', y = 1, yanchor = 'top'\n ) \n\n\n\n\n\nFigure 15.3: Population size distribution over time.\n\n\n\nWe can also see how these two quantities interact over time.\n\n\nCode\nntmat |>\n as.data.frame() |>\n pivot_longer(cols = everything()) |>\n group_by(name) |>\n reframe(N = sum(value)) |>\n mutate(Time = parse_number(name)) |>\n arrange(Time) |>\n bind_cols(lambda = lambdas) |>\n ggplot() +\n aes(N, lambda) +\n aes(color = Time) +\n geom_path(linewidth = 1.2) +\n theme_classic() +\n labs(x = 'Population size', y = expression(lambda)) +\n geom_hline(yintercept = 1, alpha = 0.2)\n\n\n\n\n\nFigure 15.4: Correlation between population growth rate and total population size over time."
"text": "Run the IPM\nThe primary function of the forest IPM is the mkKernel().\n\nK_abibal = mkKernel(\n Nvec_intra = N_sp,\n Nvec_inter = N_het,\n delta_time = delta_time,\n plotSize = plotSize,\n Temp = Temp,\n Prec = Prec,\n pars = pars_abibal,\n plot_random = plot_random\n)\n\nThe K_abibal object is a list of the \\(P\\), \\(F\\), and \\(K\\) matrices of dimension \\(z^2\\) as described in Equation 14.2. This kernel object is the core output of the IPM model, serving as the foundation for projecting populations over time or calculating the asymptotic population growth rate (\\(\\lambda\\)) and other metrics.\nWe can extract the asymptotic population growth rate (\\(\\lambda\\)) using the leading eigen value of the matrix \\(k\\):\n\n(max(Re(eigen(K_abibal$K)$values)))\n\n[1] 1.209194\n\n\nGiven that our matrix is density-dependent, we can project the population vector over time by continuously updating the Kernel at each time step to account for the evolving size distribution of individuals. In the following code, we demonstrate a simple loop to trace the evolving population over time while assuming that there is only conspecific density-dependence (N_het = 0). Note that this code is slow and can take 5-10 minutes to run due to the slow eigen() computation.\n\nset.seed(0.0)\n\n# Initial population size (small)\nN_sp <- init_pop(\n params = pars_abibal,\n L = 127,\n h = 1,\n N = 1\n)\n\n# define no heterospecific competition\nN_het <- init_pop(\n params = pars_abibal,\n L = 127,\n h = 1,\n N = 0\n)\n\n# generate initial Kernel\nK0 = mkKernel(\n Nvec_intra = N_sp,\n Nvec_inter = N_het,\n delta_time = delta_time,\n plotSize = plotSize,\n Temp = Temp,\n Prec = Prec,\n pars = pars_abibal,\n plot_random = plot_random\n)\n\n\ntime_max = 200\n# vector to save lambda over time\nlambdas = max(Re(eigen(K0$K)$values))\n# matrix to save size distribution\nntmat = matrix(0, nrow = length(N_sp$Nvec), ncol = time_max)\nntmat[, 1] <- N_sp$Nvec\n\nfor(Time in 2:time_max)\n{\n # update the state\n ntmat[, Time] <- K0$K %*% ntmat[, Time - 1]\n N_sp$Nvec <- ntmat[, Time]\n\n # update the kernel\n K0 <- mkKernel(\n Nvec_intra = N_sp,\n Nvec_inter = N_het,\n delta_time = delta_time,\n plotSize = plotSize,\n Temp = Temp,\n Prec = Prec,\n pars = pars_abibal,\n plot_random = plot_random\n )\n\n # calculate pop growth rate\n lambdas[Time] = max(Re(eigen(K0$K)$values))\n\n cat(' Time step', Time, 'of', time_max, '(', round(Time/time_max * 100, 1), '%)\\r')\n}\n\n\n\n\nFor each time iteration, we saved the focal species’ size (\\(z\\)) distribution and the population growth rate (\\(\\lambda\\)). We can visualize how each measure involved time for these species-specific conditions. In Figure 15.2 and Figure 15.3, we can visualize how \\(\\lambda\\) and the size density distribution evolve.\n\n\nCode\nntmat |>\n as_tibble() |>\n pivot_longer(cols = everything(), values_to = 'Density') |>\n mutate(Time = parse_number(name)) |>\n group_by(Time) |>\n reframe(N = sum(Density)) |>\n left_join(\n lambdas |>\n enframe(name = 'Time') |>\n rename(lambda = value)\n ) |>\n pivot_longer(cols = c(N, lambda)) |>\n mutate(\n name = factor(name, levels = c('N', 'lambda'), labels = c(expression(textstyle('Population size')), expression(lambda)))\n ) |>\n ggplot() +\n aes(Time, value) +\n facet_wrap(\n ~name,\n scales = 'free_y',\n labeller = label_parsed\n ) +\n geom_path(linewidth = 1.2) +\n theme_classic() +\n labs(\n y = NULL\n )\n\n\n\n\n\nFigure 15.2: Population size (left panel) and population growth rate (right panel) over time.\n\n\n\n\n\n\nCode\nsuppressPackageStartupMessages(library(plotly))\n\nntmat |>\n as.data.frame() |>\n pivot_longer(cols = everything(), values_to = 'Density') |>\n mutate(Time = parse_number(name)) |>\n group_by(Time) |>\n mutate(x = 127:(n() + 126)) |>\n ggplot() +\n aes(x, Density) +\n aes(group = name) +\n aes(frame = Time) +\n geom_path() +\n theme_classic() +\n xlab('Size (mm)') ->\np\n\nggplotly(p) |>\n animation_opts(frame = 50) |>\n animation_slider(\n hide = FALSE,\n currentvalue = list(prefix = \"Time step: \", font = list(color = 'black'))\n ) |>\n animation_button(\n x = 0.9, xanchor = 'left', y = 1, yanchor = 'top'\n ) \n\n\n\n\n\nFigure 15.3: Population size distribution over time.\n\n\n\nWe can also see how these two quantities interact over time.\n\n\nCode\nntmat |>\n as.data.frame() |>\n pivot_longer(cols = everything()) |>\n group_by(name) |>\n reframe(N = sum(value)) |>\n mutate(Time = parse_number(name)) |>\n arrange(Time) |>\n bind_cols(lambda = lambdas) |>\n ggplot() +\n aes(N, lambda) +\n aes(color = Time) +\n geom_path(linewidth = 1.2) +\n theme_classic() +\n labs(x = 'Population size', y = expression(lambda)) +\n geom_hline(yintercept = 1, alpha = 0.2)\n\n\n\n\n\nFigure 15.4: Correlation between population growth rate and total population size over time."
},
{
"objectID": "sens_analysis.html#simulation-summary",
Expand Down

0 comments on commit d5403e9

Please sign in to comment.