Error in with(pars, { : argument "pars" is missing, with no default

Hello,
I ran the code below and got this error message "Error in with(pars, { : argument "pars" is missing, with no default"

I couldn't identify where the error came from. Please kindly let me know where the error came from. Thank you.

require(deSolve)
SIR.space = function(t, y, y1,pars) {
i = c(1:L)

Sv1 = y[i]
Iv1 = y[L + i]
Rv1 = y[2 * L + i]
Sh = y1[i]
Ih = y1[L + i]
Rh = y1[2 * L + i]
with(pars, {
Nv <- Sv1+Iv1+Rv1
Nh <- Sh+Ih+Rh
beta0 = beta0[i]
betah=betah[i]
epsilon = epsilon[i]
ph=ph[i]
betav=betav[i]=beta0*(1+epsilonsin(2pi*(t+phi)/365))
Bv=Bv[i]
dv=dv[i]
gv=gv[i]
gh=gh[i]
Bh=Bh[i]
dh=dh[i]
# Vector compartment
dSv = BvNv -(betav * I + m * G %% Ih) * Sv/Nh - dvSv1
dIv1 = (betav * I + m * G %
% Ih) * Sv/Nh - (gv - dv) * Iv1
dRv1 = gv * Iv1 - dvRv1
# human compartment
dSh = Bh
Nh -(betah * I + m * G %% Iv1) * Sh/Nv - dhSh
dIh = BhNh -(betah * I + m * G %% Iv1) * Sh/Nv - (gh - dh) * Ih
dRh = gh * Ih - dh*Rh
list(c(dSv1, dIv1, dRv1, dSh, dIh, dRh))
})
}

gravity = function(a,b, c, pop, distance) {
gravity = outer(pop^a, pop^b)/distance^c
diag(gravity) = 0
gravity
}
G = gravity(1, 1, 2, c(1:50), c(1:50))
Bh = 10000
Bv = 1000
gh = 0.2
gv = 0.0002
epsilon = 0.7
dv = 0.5
phi = 0.5
beta0 = 0.1
dh = 0.0047
betah = 1.5
m = 1/1000/sum(c(1:50))
parms = list(beta = beta, m = m, gamma = gamma, G = G)
L = length(c(1:50))
Sh = 1000000
Ih = 1
Rh = 0
Sv1 = 100000000
Iv1 = 1
Rv1 = 0

inits = c(Sv1 = Sv1, Iv1 = Iv1, Rv1 = Rv1, Sh = Sh, Ih = Ih, Rh = Rh)

require(deSolve)
times = 0:200
out = ode(inits, times, SIR.space, parms)
matplot(out[,50+(1:L)], type="l", ylab="Prevalence",
xlab="Day")

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.