Chapter 9.1 Systems of differential equations

Sistem persamaan diferensial dengan lebih dari satu variabel keadaan dapat ditangani juga. Sebagai ilustrasi, berikut adalah model SIR penyebaran epidemi, di mana keadaan adalah jumlah S yang rentan dan jumlah infektif I dalam populasi. Rentan menjadi infektif dengan bertemu infektif, infektif pulih dan meninggalkan sistem. Ada satu persamaan untuk perubahan S dan persamaan yang sesuai untuk perubahan I. I awal = 1, sesuai dengan awal epidemi.

library(mosaicCalc)
## Loading required package: mosaic
## Registered S3 method overwritten by 'mosaic':
##   method                           from   
##   fortify.SpatialPolygonsDataFrame ggplot2
## 
## The 'mosaic' package masks several functions from core packages in order to add 
## additional features.  The original behavior of these functions should not be affected by this.
## 
## Attaching package: 'mosaic'
## The following objects are masked from 'package:dplyr':
## 
##     count, do, tally
## The following object is masked from 'package:Matrix':
## 
##     mean
## The following object is masked from 'package:ggplot2':
## 
##     stat
## The following objects are masked from 'package:stats':
## 
##     binom.test, cor, cor.test, cov, fivenum, IQR, median, prop.test,
##     quantile, sd, t.test, var
## The following objects are masked from 'package:base':
## 
##     max, mean, min, prod, range, sample, sum
## Loading required package: mosaicCore
## 
## Attaching package: 'mosaicCore'
## The following objects are masked from 'package:dplyr':
## 
##     count, tally
## 
## Attaching package: 'mosaicCalc'
## The following object is masked from 'package:stats':
## 
##     D
library(mosaic)
library(mosaicCore)
library(mosaicData)
"soln <- integrateODE(dx ~ r * x * (1 - x / K),
                     x = 1, K = 10, r = 0.5,
                     tdur = list(from=0, to=20))"
## [1] "soln <- integrateODE(dx ~ r * x * (1 - x / K),\n                     x = 1, K = 10, r = 0.5,\n                     tdur = list(from=0, to=20))"

Objek yang dibuat oleh integrateODE()adalah fungsi waktu. Atau, lebih tepatnya, ini adalah sekumpulan solusi, satu untuk setiap variabel keadaan. Dalam persamaan logistik, hanya ada satu variabel keadaan x .

"soln$x(0:5)"
## [1] "soln$x(0:5)"
"slice_plot(soln$x(t) ~ t, domain(t=0:20))"
## [1] "slice_plot(soln$x(t) ~ t, domain(t=0:20))"

9.2 Systems of differential equations Sistem persamaan diferensial dengan lebih dari satu variabel keadaan dapat ditangani juga. Sebagai ilustrasi, berikut adalah model SIR penyebaran epidemi, di mana negara adalah jumlah yang rentan S dan jumlah infektif Saya dalam populasi. Rentan menjadi infektif dengan bertemu infektif, infektif pulih dan meninggalkan sistem. Ada satu persamaan untuk perubahan dalam S dan persamaan yang sesuai untuk perubahan dalam Saya . Inisial Saya = 1 , sesuai dengan awal epidemi.

"epi <- integrateODE(dS ~ -a * S * I,
                    dI ~ a * S * I - b * I,
                    a = 0.0026, b = 0.5, S=762, I = 1,
                    tdur = 20)"
## [1] "epi <- integrateODE(dS ~ -a * S * I,\n                    dI ~ a * S * I - b * I,\n                    a = 0.0026, b = 0.5, S=762, I = 1,\n                    tdur = 20)"
"slice_plot(epi$S(t) ~ t, domain(t=0:20)) %>%
  slice_plot(epi$I(t) ~ t, color = red)"
## [1] "slice_plot(epi$S(t) ~ t, domain(t=0:20)) %>%\n  slice_plot(epi$I(t) ~ t, color = red)"