Thanks Karin for your quick reply.


 I have tried using rbind function as you mentioned “yobs <- rbind(yobs1,
yobs2, yobs3)”

but now I am facing another error while working with the modCost function,
when I want use it in finding the sensitive function (sensFun) or model
fitting (modFit).


 #####

Cost<- function(p) {

out <- ode(y = y, func = derivs, parms = p , times = yobs$time)

return(modCost(obs=yobs, model=out, y="Y", err="err"))

}


 sensitive<- sensFun(Cost, pars) OR

fit<- modFit(Cost, pars)


 DINTDY-  T (=R1) illegalIn above message, R1 = 0       T not in
interval TCUR - HU (= R1) to TCUR (=R2)In above message, R1 = 6.32892,
R2 = 7.72296 DLSODA-  Trouble in DINTDY.  ITASK = I1, TOUT = R1In
above message, I1 = 1 In above message, R1 = 0 Error in lsoda(y,
times, func, parms, ...) :   illegal input detected before taking any
integration steps - see written message



 I never had such error before if I used each observation separately. And I
am also wondering how the cost function is working in calculating the
residuals error?


On Wed, Oct 23, 2013 at 9:24 AM, Karline Soetaert
<Karline.Soetaert@nioz.nl>wrote:

> Himanshu,
>
> You will have to pool them, for instance:
>
> yobs1 <- data.frame(
>  names= rep("Y",8),  time = 0:7, Y = runif(8),
>  err = c(0.1, 0.11, 0.10, 0.120, 0.16, 0.145, 0.153, 0.16)
> )
>
> yobs2 <- data.frame(
>  names= rep("Y",8),  time = 0:7, Y = runif(8),
>  err = c(0.1, 0.11, 0.10, 0.120, 0.16, 0.145, 0.153, 0.16)
> )
>
> yobs3 <- data.frame(
>  names= rep("Y",8), time = 0:7, Y = runif(8),
>  err = c(0.1, 0.11, 0.10, 0.120, 0.16, 0.145, 0.153, 0.16)
> )
>
> # Here they are pooled...
> yobs <- rbind(yobs1, yobs2, yobs3)
>
>
> modCost(obs=yobs, model=out, y="Y", err="err")
>
>
> karline
> -----Original Message-----
> From: r-sig-dynamic-models-bounces@r-project.org [mailto:
> r-sig-dynamic-models-bounces@r-project.org] On Behalf Of Himanshu
> Sent: dinsdag 22 oktober 2013 17:56
> To: r-sig-dynamic-models@r-project.org
> Subject: [R-sig-dyn-mod] data fitting problem with FME package
>
> Dear list,
>
>
>  I have some issue with the model fitting, I came across multiple
> observations problem and I am not sure how to fix this issue in FME package.
>
> My problem here is, I have suppose 3 sets of observations, say "yobs_1",
> "yobs_2", "yobs_3", if I use the pseudo code below seperately for each
> observation, I will get 3 different parameters sets for the 3 different
> datasets. So my question is, is there any way where I can input all the
> three data sets together (except pooling them together) and find out a
> single parameters sets?
>
>
>
>  Here is the pseudo code, I hope you understand my problem. Kindly let me
> know if there is some confusion.
>
>
>  Thanks a lot in advance!
>
>
>  library(deSolve)
>
> library(FME)
>
>  ## function derivs
>
>  derivs <- function(time, y, pars) {
>
> with (as.list(c(y, pars)), {
>
> dy = a1 * Y * (1 - Y/Ymax) - a2 * (Y + 0.001)
>
> dz = a3 * Y - a4 * Z;
>
> return(list(c(dy, dz)))
>
> })
>
> }
>
>  ## parameters
>
> pars <- c(a1 = 0.9, a2 = 0.7, a3 = 0.06, a4 = 0.02)
>
> Ymax <- c(0.8)
>
> ## initial values
>
> y <- c(Y = 0.2, Z = 0.1)
>
> ## time steps
>
>  times <- c(seq(0, 10, 0.1))
>
> ## numerical solution of ODE
>
>  out <- ode(y = y, parms = pars, times = times, func = derivs)
>
>  ## example observation data
>
> yobs <- data.frame(
>
> names= rep("Y",8),
>
> time = 0:7,
>
> Y = c(0.2, 0.195, 1.19, 2.487, 1.185, 0.683, 0.182, 0.018),
>
> err = c(0.1, 0.11, 0.10, 0.120, 0.16, 0.145, 0.153, 0.16)
>
> )
>
>   ## model cost function, see help file and vignette for details
>
> modelCost <- function(p) {
>
> out <- ode(y = y, func = derivs, parms = p, times = yobs$time)
>
> return(modCost(obs=yobs, model=out, y="y", err="err"))
>
> }
>
>  ## start values for the parameters
>
> startpars <- c(a1 = 1, a2 = 0.6, a3 = 0.1, a4 = 0.1)
>
>  low<-c(a1 =0.1, a2 = 0.1, a3 = 0.01, a4 = 0.01)
>
> up<-c(a1 = 3.0, a2 = 2.6, a3 = 2.1, a4 = 2.1)
>
> ## fit the model; nprint = 1 shows intermediate results
>
> fit <- modFit(f = modelCost, p = startpars,lower=low, upper=up, control =
> list(nprint = 1))
>
> --
> With Regards:
>
> Himanshu Manchanda  M.Sc.
> Doctorate Student,
> Leibniz Institute for Natural Product Research and Infection Biology e.V.
> Hans-Knöll-Institute (HKI)
> FSU, Jena
> Germany
> Contact: +49-160-96444678
>               +49-176 56526087
> email: bioinfo.himanshu@gmail.com
>
> P.S: All good things come to those who wait..!!
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-dynamic-models mailing list
> R-sig-dynamic-models@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-dynamic-models
>



-- 
With Regards:

Himanshu Manchanda  M.Sc.
Doctorate Student,
Leibniz Institute for Natural Product Research and Infection Biology e.V.
Hans-Knöll-Institute (HKI)
FSU, Jena
Germany
Contact: +49-160-96444678
              +49-176 56526087
email: bioinfo.himanshu@gmail.com

P.S: All good things come to those who wait..!!

	[[alternative HTML version deleted]]

