[R] Error in eval(expr, envir, enclos) : object 'N' not found
hansoffate
hansoffate at gmail.com
Sun Dec 6 04:47:31 CET 2009
I'm running an LSODA to generate some graphs, but I need to stop at a certain
point and use those values to generate another LSODA output. This is
working fine, but when I try to run the second LSODA, I get the "Error in
eval(expr, envir, enclos) : object 'N' not found". Any ideas what can be
causing this? I have no object 'N' anywhere in the script. I made an
identical version of models states, parameters, and everything just by
adding 2 after each one, and I'm still getting this error.
Thanks,
-Hans
::CODE::
require(odesolve);
###Params for running script ##
iniT=1E3; iniN=10; iniM=0; iniC=1E3;
num_days = 30; interval_size = .1; OF_prcnt = .10;
model <- function(t, state, pars)
{
with (as.list(c(state, pars)), {
dT=(a*T-a*T*b*T) - (c1*N*T) - (Kt*M*T)
dN=a1 - (f*N) + g * (T/(h+T)) * N - (p * N * T) - (Kn * M * N)
dC=a2 - (beta * C) - (Kc * M * C)
dM= -(gamma) * M + Vm
return(list(c(dT,dN,dC,dM)))
})
}
model2 <- function(t, state2, pars2)
{
with (as.list(c(state2, pars2)), {
dT=(a*T-a*T*b*T) - (c1*N*T) - (Kt*M*T)
dN=a1 - (f*N) + g * (T/(h+T)) * N - (p * N * T) - (Kn * M * N)
dC=a2 - (beta * C) - (Kc * M * C)
dM= -(gamma) * M + Vm
return(list(c(dT,dN,dC,dM)))
})
}
### First Half - Tumor growth to 10%
pars <- list( Tini=iniT, Nini=iniN, Mini=iniM, Cini=iniC,
a=4.31E-3, b=1.02E-14, c1=3.41E-10, Kt=8E-1,
f=4.12E-2, g=1.5E-2, h=2.02E1, beta=1.20E-2, gamma=9E-1,
Kc=6E-1, Kn=6E-1, p=2E-11, a1=1.2E4, a2=7.5E8, Vm=0 )
tout <- seq(0, num_days, by=interval_size)
state <- c(T = pars$Tini, N = pars$Nini, C = pars$Cini, M = pars$Mini)
out <- lsoda(state, tout, model, pars)
## Finding position at which OF function is reached
final_matrix = out;
loopsize = (num_days / interval_size) + 1
OF_tumor_size = iniT + (OF_prcnt * iniT)
## Sentinel Value to find at which row in the matrix reaches OF_tumor_size
OF_row=-1;
for(i in 1:loopsize) {
if( out[i,2] >= OF_tumor_size) {
OF_row=i;
break;
}
}
if(OF_row != -1) {
##Params setup
OF_iniT=out[OF_row,2]; OF_iniN=out[OF_row,3]; OF_iniC=out[OF_row,4];
OF_iniM=out[OF_row,5];
pars2 <- list( Tini=OF_iniT, Nini=OF_iniN, Mini=OF_iniM, Cini=OF_iniC,
a=4.31E-3, b=1.02E-14, c1=3.41E-10, Kt=8E-1,
f=4.12E-2, g=1.5E-2, h=2.02E1, beta=1.20E-2, gamma=9E-1,
Kc=6E-1, Kn=6E-1, p=2E-11, a1=1.2E4, a2=7.5E8, Vm=0 )
state2 <- c(T = pars2$Tini, N = pars2$Nini, C = pars2$Cini, M =
pars2$Mini)
out2 <- lsoda(state2, tout, model2, pars2)
}
--
View this message in context: http://n4.nabble.com/Error-in-eval-expr-envir-enclos-object-N-not-found-tp949512p949512.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list