2014-07-17 2 views
0

내가 R.deSolve - 대량 처리를 나타냅니다 -의 파라미터 이벤트

모델은 다음 커뮤니티 내에서 감염의 전송을 설명하고의 deSolve 패키지를 사용하여 SIR 모델을 쓰고 있어요 외부 이벤트의 도입을 허용 전체 공동체의

이들은 특정 시간에 발생하는 이벤트로 모델링됩니다.

변속기 모델 그 자체는 기본 모집단 크기와 매개 변수 (plist 및 initlist)에 대한 값의 범위를 사용하여 많은 수의 시뮬레이션을 실행하도록 코드를 작성할 수있었습니다.

외부 이벤트 (Total Community Treatment) 매개 변수에 대해 동일한 작업을 수행하고 싶습니다. 현재

는 감염되기 쉬운 인구의 외부 이벤트의 영향은 다음과 같습니다 S < - S + 0.95 * L + 0.95 * I1 + 0.95 * I2

하지만 범위를 지정할 수 있도록하고 싶습니다 예를 들어 0.85-0.99의 값을 가지며 모델이 모든 가능성 범위에서 여러 시뮬레이션을 실행하게하십시오. , cbind (TCT = runif (100 분 = 0.88 -

제가

S <- S + TCT*L + TCT*I1 + TCT*I2 

하고는 PLIST 같은

같은 PLIST < 그것을 포함한 PLIST 예에서 이러한 추가적인 파라미터를 포함하려 최대 = 0.99) ........ 등)

그러나 나는 얻을 매개 변수 예를 들어, TCT는

전체 코드 아래에 존재하지 않는 및 제안 WELCOM 말하는 오류 에드.

library(deSolve) 

#generate an empty list for the data to be put into 

simulationlist <- list() 

#define the transmission model 

SI1I2L <- function(t, y, parms) { 

    with(as.list(c(parms,y)),{ 
    dS <- - Beta*S*I1 - Beta*S*I2 + treat*I1 + treat*I2 +latenttreat*L 
    dI1 <- + Beta*S*I1 + Beta*S*I2 - treat*I1 -second*I1 - latent*I1 
    dI2 <- + second*I1 - latent*I2 - treat*I2 + relapse*L 
    dL <- +latent*I1 + latent*I2 - relapse*L - latenttreat*L 

    der <- c(dS, dI1,dI2, dL) 
    list(der)  
    }) 

} 

#define Total Community Treatment Parameters 

eventtct <- function(t, y, parms){ 
    with (as.list(y),{ 
    S <- S + 0.95*L + 0.95*I1 + 0.95*I2 
    I1 <- I1*0.05 
    I2 <- I2*0.05 
    L <- L*0.05 
    return(c(S,I1,I2,L)) 
    }) 
} 

#Set the time frame for the model 
dt <- seq(0,100,1)  

#Define the spectrum of Parameters for transmission with Min/Max values and number of variations 
plist <- cbind(Beta = runif(100,min = 0.00000167, max = 0.0000043),second = runif(100,min= 0.0278,max = 0.0556),latent = runif(100,min=0.004, max=0.009), treat = runif(100, min=0.01, max =0.03),latenttreat = runif(100,min=0.004,max=0.009),relapse = runif(100,min=0.012,max=0.028)) 
for (i in 1:nrow(plist)) 
#Define the spectrum of inital values for population size 

initlist <- cbind(S = runif(100,min = 110681, max = 118636),I1 = runif(100,min=798, max=2926),I2 = runif(100,min=266,max=1463),L=runif(100,min=13300, max=27930)) 
for (i in 1:nrow(initlist)) 

#run multiple simulations 
simulationlist[[i]] <- as.data.frame(lsoda(initlist[i,], dt, SI1I2L, parms=plist[i,],events = list(func = eventtct, time = c(2,12)))) 

답변

1

내 솔루션을 테스트하십시오. 는

#### Clear currrent lists from memory 
    rm(list=ls()) 
    library(deSolve) 

    #generate an empty list for the data to be put into 

    simulationlist <- list() 

    #define the transmission model 

    SI1I2L <- function(t, y, parameters) { 
     with(as.list(c(parameters,y)),{ 
     dS <- - Beta*S*I1 - Beta*S*I2 + treat*I1 + treat*I2 +latenttreat*L 
     dI1 <- + Beta*S*I1 + Beta*S*I2 - treat*I1 -second*I1 - latent*I1 
       dI2 <- + second*I1 - latent*I2 - treat*I2 + relapse*L 
     dL <- +latent*I1 + latent*I2 - relapse*L - latenttreat*L 

     der <- c(dS, dI1,dI2, dL) 
     list(der)  
     }) 

    } 
    n=10; 
    #define Total Community Treatment Parameters 
    TCTlist = runif(n,min = 0.88, max = 0.99); 
    #eventtct <- function(t, y, parms){ 
    eventtct <- function(t,y,parameters){ 
     with (as.list(y,parameters),{ 
    # eval(TCT=parameters[7]) 
     S <- S + TCT*L + TCT*I1 + TCT*I2 
     I1 <- I1*(1-TCT) 
     I2 <- I2*(1-TCT) 
     L <- L*(1-TCT) 
     return(c(S,I1,I2,L)) 
     }) 
    } 

    #Set the time frame for the model 
    dt <- seq(0,100,1)  




    #Define the spectrum of Parameters for transmission with Min/Max values and number of  variations 
    plist <- cbind(Beta = runif(n,min = 0.00000167, max = 0.0000043),second = runif(n,min= 0.0278,max = 0.0556),latent = runif(n,min=0.004, max=0.009), treat = runif(n, min=0.01, max =0.03),latenttreat = runif(n,min=0.004,max=0.009),relapse = runif(n,min=0.012,max=0.028)) 
    for (i in 1:n) 
     #Define the spectrum of inital values for population size 

     initlist <- cbind(S = runif(n,min = 110681, max = 118636),I1 = runif(n,min=798, max=2926),I2 = runif(n,min=266,max=1463),L=runif(n,min=13300, max=27930)) 


    for (i in 1:n){ 
     #run multiple simulations 
     parameters = c(plist[i,],TCT=TCTlist[i]); 
     eventsfunction = list(eventtct, time = c(2,12)); 
     simulationlist[[i]] <- as.data.frame(ode(initlist[i,], time=dt, func=SI1I2L,   parms=parameters,events =eventsfunction)) 
    } 
+0

가장 중요한 변화가 파라미터가 "Y"다음에 추가 ","어디 as.list()에 eventtct "의 부호의이 부분에 작동 생각한다. – Daniel

관련 문제