I am using the simple code as below and I am getting an error: "Error in func(time, state, parms, ...) : unused arguments (state, parms)". It looks like this error arises whenever I use 'function(koff_WT)
' function otherwise the model runs fine .
Any suggestions what may be going wrong ?
library(deSolve)
kon_WT = 1e-4
kd_WT = 0.01
koff_WT = kon_WT*kd_WT
R_WT = 1000
Complex <- function(koff_WT) {
function (t,y,parms){
with(as.list(y,parms), {
dC_WT <- koff_WT*RL_WT -kon_WT*R_WT*C_WT
dRL_WT <- kon_WT*R_WT*C_WT - koff_WT*RL_WT #nM
dR_WT <- koff_WT*RL_WT -kon_WT*R_WT*C_WT
return(list(c(dC_WT, dRL_WT, dR_WT)))
})
}
}
yini <- c(C_WT = 0.1, RL_WT = 0, R_WT= R_WT)
times <- seq(0,40000,100)
Out <- ode(y = yini, times = times, func=Complex, parms=NULL)
Output <- data.frame(Out)
Result <- Complex(koff_WT =1) ; Result
Complex()
is a factory, i.e. a function that returns a function of the type that ode
is expecting. So you need to call ode
with func=Complex(...)
rather than func=Complex
.
Out <- ode(y = yini, times = times,
func=Complex(koff_WT=1), parms=NULL)