knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(mmbr, warn.conflicts = FALSE)

Define model parameters and state variables.

params <- new('LotkaVolterraParams',
  prey_percapita_growth = 1,
  predation_rate = 0.3,
  predation_efficiency = 0.6,
  predator_percapita_degradation = 0.5
)

init_state <- new('LotkaVolterraState',
  prey_population = 2,
  predator_population = 1
)

Numerical integration using Euler's method.

solution <- mmbr::solve(params, init_state, time_range = 30, step_size = 0.1)
head(solution, n = 5)

Plot time series data.

mmbr::tsplot(params, solution)


atmunr/mmbr documentation built on Oct. 6, 2020, 2:51 a.m.