Apologies. time is also the name of the argument, which is why I hastily thought it was missing.
As defined
times<-seq(0,25,1)
it is a numeric vector, and conforms to the first part of the requirement
times at which explicit estimates for y are desired.
I'm unsure of the second requirement
The first value in times must be the initial time.
whether 0 is intended by the authors to be valid.
However, in looking at the code for lsode, the error message is not returned there but from EDO_tumendo, perhaps
dK<-omega*N-alpha*c*K-gamma*(N^(2/3))*K #attention c est une fonction
This is confirmed by a toy example
omega <- 2
alpha <- 4
gamma <- 6
N <- 8
K <- 10
dK<-omega*N-alpha*c*K-gamma*(N^(2/3))*K #attention c est une fonction
#> Error in alpha * c: non-numeric argument to binary operator
Created on 2020-12-19 by the reprex package (v0.3.0.9001)
c is, as noted a function, and when used in an expression operates as a closure with a return value of NULL and that will cause the entire expression to fail.
If, however, we substitute a numeric parameter, the function succeeds
omega <- 2
alpha <- 4
gamma <- 6
N <- 8
K <- 10
c0 <- 3
dK<-omega*N-alpha*c0*K-gamma*(N^(2/3))*K #attention c est une fonction
dK
#> [1] -344
Created on 2020-12-19 by the reprex package (v0.3.0.9001)
That in turn will allow the code to run
##Chargement du package
library(deSolve)
EDO_tumendo<-function(t,x,param)
{
N<-x[1]
K<-x[2]
mu<-param["mu"]
nu<-param["nu"]
omega<-param["omega"]
alpha<-param["alpha"]
gamma<-param["gamma"]
r<-0.4
c0<-3
t0<-t[11]
c_tabnux<-c0*(t-t0)*exp(-r*(t-t0))
c_tab<-round(c_tabnux, 3)
if (t <= 10 | t >= 20) {
c<-0
} else if (t == 11) {
c<-c_tab[[11]]
#c_tab<-c0*(times-t0)*exp(-r*(times-t0))
#c<-c_tab[3]
} else if (t==12) {
c<-c_tab[[12]]
} else if (t==13) {
c<-c_tab[[13]]
} else if (t==14) {
c<-c_tab[[14]]
} else if (t==15) {
c<-c_tab[[15]]
} else if (t==16) {
c<-c_tab[[16]]
} else if (t==17) {
c<-c_tab[[17]]
} else if (t==18) {
c<-c_tab[[18]]
} else if (t==19) {
c<-c_tab[[19]]
}
dN<-(N*mu/nu)*(1-(N/K)^nu)
#list(dN)
dK<-omega*N-alpha*c0*K-gamma*(N^(2/3))*K #attention c est une fonction
#list(dK)
res <- c(dN, dK)
list(res)
}
##Valeur des paramètres
times<-seq(1,25,1)
mu<-0.28 # valeur issue de l'article 17 (noté lambda1)
nu<-0.25 #valeur optimale (issue de l'article étudié) (noté alpha)
alpha<-0.66
omega<-5.85 # valeur issue de l'article 17 (noté b)
gamma<-0.9 # valeur issue de l'article 17 (noté d)
x<-x_init<-c(N=0.1,K=0.625) #0.300cm3=300mm3 et 0.625cm3=625mm3 (cc=cm3)
param<-c(mu=mu,nu=nu,omega=omega,alpha=alpha,gamma=gamma)
res<-data.frame(lsoda(x_init,times,EDO_tumendo,param))
res
#> time N K
#> 1 1 0.1000000 0.6250000
#> 2 2 0.1359844 0.3636167
#> 3 3 0.1707942 0.4091447
#> 4 4 0.2121704 0.4970153
#> 5 5 0.2624615 0.6041236
#> 6 6 0.3233331 0.7302072
#> 7 7 0.3965068 0.8768590
#> 8 8 0.4837897 1.0455430
#> 9 9 0.5870210 1.2373025
#> 10 10 0.7079910 1.4526096
#> 11 11 0.8483422 1.6912555
#> 12 12 1.0094572 1.9522798
#> 13 13 1.1923431 2.2339527
#> 14 14 1.3975172 2.5338222
#> 15 15 1.6249140 2.8488043
#> 16 16 1.8738229 3.1753479
#> 17 17 2.1428662 3.5095817
#> 18 18 2.4300171 3.8475520
#> 19 19 2.7326692 4.1853565
#> 20 20 3.0477479 4.5193429
#> 21 21 3.3718352 4.8462068
#> 22 22 3.7013329 5.1630891
#> 23 23 4.0326143 5.4676410
#> 24 24 4.3621750 5.7579985
#> 25 25 4.6867503 6.0328088
Created on 2020-12-19 by the reprex package (v0.3.0.9001)
Whether that is the result intended, I can't say.