メモ2

引き続きR、2コンパートメントモデル。

central compartment の濃度をy[1]
peripheral compartmentの濃度をy[2]
k10, k12, k21をそれぞれ k12=1.49 , k21=0.495 , k10=0.789と設定する
初期値をy[1] = 1000, y[2] = 0としてみる。
dy1/dt = k21y2 – k12y1 – k10y1
dy2/dt = k12y1 – k21y2
がそれぞれのコンパートメントでの収支

library(odesolve)

 twocmp <- function(t,y,p){
+ dy1 <- p["k21"]*y[2]-p["k12"]*y[1]-p["k10"]*y[1]
+ dy2 <- p["k12"]*y[1]-p["k21"]*y[2]
+ list(c(dy1,dy2))
+ }

parms <- c(k12=1.49,k21=0.495,k10=0.789)
times <- c(0,0.1*(1:240))

out <- lsoda(c(1000,0), times, twocmp, parms)
out.df <- data.frame(out)
plot(out.df)

Rplot
軸設定がおかしいのはスキルが無いため、、

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s