Data Science Asked by Will Payne on June 1, 2021
I have been given this code below to modify to optimize the value of theta over vector (0.01,0.02, …, 0.99, 1.00) where R0=10 and D=14, any help at all would mean a lot. Thanks
errorSS<-function(epidemiology.data,N=1000000,R0,D,theta,N.time.steps=2100,delta.t=0.1){
gamma<-1/D
beta<-R0*gamma/N
S0<-theta*N
I0<-epidemiology.data$No.infected[1]
sample.index<-epidemiology.data$Time.index
S<-numeric(N.time.steps+1)
I<-numeric(N.time.steps+1)
S[1]<-S0 # Initial conditions
I[1]<-I0 # Initial conditions
for (i in 1:N.time.steps){
S[i+1]<-S[i]-beta*S[i]*I[i]*delta.t
I[i+1]<-I[i]+beta*S[i]*I[i]*delta.t-gamma*I[i]*delta.t
}
errorSS<-sum((epidemiology.data$No.infected-I[sample.index])^2)
return(errorSS)
}
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP