How can i do a sensitivity analysis with respect to the inital conditions in R?

24 views Asked by At

I would like to do a sensitivity analysis with respect to inial conditions. I have already made a sensitivity analysis for the parameters (see code). But now I would like to fix the parameters and vary the initial conditions but my code does not work. Do you have some ideas ?

For the sensitivity analysis about the parameters i use this code


 mod<-function(pars,time=seq(0,25,by=1)){

   derivs<-function(t,state,pars){ #return rate of change
    with(as.list(c(state,pars)),{

 
  

ds.dt = -alpha*s*i

di.dt=alpha*s*i-beta*i

dr.dt=beta*i

      (list(c(ds.dt,di.dt,dr.dt)))
    })
   }

 
    state  <- c(s=64000000,i=1,r=0)
    
return(ode(y=state,times=time,func=derivs,parms=pars,maxsteps = 1e5))
 }
 

parRanges<-data.frame(min=c(0.0001,0.0001),max=c(0.01,0.01) )

rownames(parRanges)<-c("alpha","beta")
parRanges 

tout<-seq(0,25,by=1)

pars  <- c( alpha=0.1,beta=0.1) 

Sens<-summary(sensRange(func=mod,parms=pars,dist="latin",sensvar=c("s","i","r"),parRange=parRanges,num=1000))
par(bg="white")
par(mfrow=c(2,2))
plot(Sens,main="Sensitivity",xlab="time,days",ylab="")

Now i would like to do sensitivity analysis but respect to the initial conditions, how can i proceed ?

Thank you by advance

0

There are 0 answers