thanks a lot for the responses. vector name is solved now, but unfortunately initial problem continues to exist: i re-wrote the model a bit:

pars <- list(cl = 0.348,v=14.3,EC=4.1)
INTERVAL <-24
NDOSE <-3
DOSE <-5
eventdat <- data.frame(var = rep("a", NDOSE),time = seq(0,NDOSE*INTERVAL-INTERVAL,by=INTERVAL) ,value = rep(DOSE,NDOSE),method = rep("add",NDOSE))
INRB <-0.89


derivs <- function(t, state, pars) {
     EDK50 <-pars$EC*pars$cl
     dy1 <- - 2 * state[1]
     dy2 <- 2 * state[1] - (pars$cl/pars$v) * state[2] 
     DR <- (pars$cl/pars$v) * state[2] 
     EFF <-(1*(DR^1.15))/((EDK50^1.15)+(DR^1.15))
     dy3 <-(1-EFF)*0.1048951 - 0.1048951* state[3]
     dy4 <-0.1048951 * state[3] - 0.1048951 * state[4]
     dy5 <-0.1048951 * state[4]- 0.1048951 * state[5]
     dy6 <-(1-EFF)*0.02535926 - 0.02535926 * state[6]
     dy7 <-0.02535926 * state[6] - 0.02535926 * state[7]
     dy8 <-0.02535926 * state[7] - 0.02535926 * state[8]
     inr <-INRB + (20*(1-((state[5]+state[8])/2)))    
     return(list(c(dy1,dy2,dy3,dy4,dy5,dy6,dy7,dy8),inr=inr))

}

model <- function(pars, times=seq(0, NDOSE*INTERVAL, by = 0.01)) {
  state <- c(a = 0,b=0,c=1,d=1,e=1,f=1,g=1,h=1)
  return(ode(y = state, times = times, func = derivs, parms = pars,events = list(data = eventdat),method="lsoda",rtol = 1e-8,atol =1e-8,hmax=0.01))
}


plot(model(pars))
observed <- matrix (nc=2,byrow=2,data=c(0.00,0.89,30.00,1.1,55.00,1.2))
colnames(observed) <- c("time", "inr.e")

tout <- unique(sort(c(eventdat$time,observed[,"time"])))

obj <- function(x, parset = names(x)) {
 pars[parset] <- x
 out <- model(pars, tout)
 return(modCost(obs = observed, model = out))
}

prior <- function(p)
  return( sum(((p-c(0.348,14.3,4.1))/c( 0.103704,5,1.8))^2 ))

final <- modMCMC(p = c(cl=pars$cl,v=pars$v,EC=pars$EC), f = obj, prior=prior,lower=c(0.00000001,0.00000001,0.00000001),jump = NULL, niter = 100,updatecov=10, wvar0 = 1,var0=NULL,burninlength = 10)


summary(final)
plot(final)
pars2 <- as.list(final$bestpar)

out1 <- model(pars)
out2 <- model(pars2)

plot(out1, out2, obs=observed)
legend("topright", legend=c("start parameters", "fitted"), col=1:2, lty=1:2)


it seems as if the derivs function does work properly as I am getting back the expected results. When I started to break down the derivs function to see where the problem begins during the monte carlo runs I found that depending the magnitude of DR in the function, the modMCMC may give estimates where the resulting bestpar is different and shows a better fit then the starting parameter values in pars... If I was to replace- for the sake of providing an example of my point- DR in derivs with DR <- 0.1 * state[2], then while way sub-optimal, but at least  reassuring that this is a step closer to solution? Any thoughts on why that may be happening? Should it not be able to estimate optimal parameters for observed data at low (as is most likely based on the model) DR values?

appreciate the help,

Andras



On Monday, February 24, 2014 10:24 AM, Thomas Petzoldt <Thomas.Petzoldt@tu-dresden.de> wrote:
 
Hi,

removing names from a vector can also be forced by using:

unname(x)

see ?unname

that internally assigns NULL to names.

Thomas

_______________________________________________
R-sig-dynamic-models mailing list
R-sig-dynamic-models@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-dynamic-models
	[[alternative HTML version deleted]]

