[R-sig-dyn-mod] FME Fitting a multicompartmental model using the sum of several variables

Thomas Petzoldt thom@@@petzo|dt @end|ng |rom tu-dre@den@de
Tue Sep 17 15:21:58 CEST 2019


On 17.09.2019 at 15:02 Blanco Pérez, Juan Carlos wrote:
> Hi Jesus,
> Thank you for your solution. It seems a good alternative to using the modCost function of FME, which does not seem to work if all variables are not included.

1) modCost is very flexible and allows also such functionality. It is 
recommended to organize the data in "long format"

2) Instead of  another derivative, you can also to return an auxillary 
variable in the ode function that contains the sum:

  [...]
  r[1]=-k1*c["A"] #dcA/dt
  r[2]=k1*c["A"]-k2*c["B"] #dcB/dt
  r[3]=k2*c["B"] #dcC/dt

  list(r, sum=r[1]+r[2]+r[3])

As the docs tell us: "The return value of func should be a list, whose 
first element is a vector containing the derivatives of y with respect 
to time, and whose next elements are global values that are required at 
each point in times. The derivatives must be specified in the same 
order as the state variables y."

More about this in the examples and slides found at: 
http://desolve.r-forge.r-project.org

Thomas

PS: Please help the moderator and yourself and sign in to the mailing 
list to avoid manual moderation acknowledgment.


>
>
> -----Mensaje original-----
> De: R-sig-dynamic-models [mailto:r-sig-dynamic-models-bounces using r-project.org] En nombre de Jesus Maria Frias Celayeta
> Enviado el: martes, 17 de septiembre de 2019 12:24
> Para: Special Interest Group for Dynamic Simulation Models in R
> Asunto: Re: [R-sig-dyn-mod] FME Fitting a multicompartmental model using the sum of several variables
>
> Hi Juan,
>
> Using the example from
> https://www.r-bloggers.com/learning-r-parameter-fitting-for-models-involving-differential-equations/
>
> you could include the sum in your ode system like:
>
> rxnrate=function(t,c,parms){
>
>   # rate constant passed through a list called parms
>   k1=parms$k1
>   k2=parms$k2
>
>   # c is the concentration of species
>
>   # derivatives dc/dt are computed below
>   r=rep(0,length(c))
>   r[1]=-k1*c["A"] #dcA/dt
>   r[2]=k1*c["A"]-k2*c["B"] #dcB/dt
>   r[3]=k2*c["B"] #dcC/dt
>   r[4]= r[1]+r[2]+r[3] # sum of A,B,C
>
>   # the computed derivatives are returned as a list  # order of derivatives needs to be the same as the order of species in c
>   return(list(r))
>
> }
>
> all the best,
>
> Jesus
>
>
> ________________________________
> From: R-sig-dynamic-models <r-sig-dynamic-models-bounces using r-project.org> on behalf of Blanco P rez, Juan Carlos <juan.carlos.blanco.perez using xunta.gal>
> Sent: Tuesday 17 September 2019 10:35
> To: r-sig-dynamic-models using r-project.org <r-sig-dynamic-models using r-project.org>
> Subject: [R-sig-dyn-mod] FME Fitting a multicompartmental model using the sum of several variables
>
> I'm new to deSolve and FME.
> I'm trying to fit a two-compartment model but the observed data are the sum of the two compartments. Can this be done with FME?. I have tried to compute the sum from the ODE output but then the result is not longer a deSolve object and multiple errors appear.
>
> Juan
>
>
>          [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-dynamic-models mailing list
> R-sig-dynamic-models using r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-dynamic-models
>
> --
>
>
> *This email originated from TU Dublin. If you received this email in error, please delete it from your system. Please note that if you are not the named addressee, disclosing, copying, distributing or taking any action based on the contents of this email or attachments is prohibited. *******
>
>
> *Is   OT Baile  tha Cliath a th inig an r omhphost seo. M  fuair t  an r omhphost seo tr  earr id, scrios de do ch ras   le do thoil. Tabhair ar aird, mura t  an seola  ainmnithe, go bhfuil dianchosc ar aon nochtadh, aon ch ipe il, aon d ileadh n  ar aon ghn omh a dh anfar bunaithe ar an  bhar at  sa r omhphost n  sna hiat in seo.*
>
> This email originated from TU Dublin. If you received this email in error, please delete it from your system. Please note that if you are not the named addressee, disclosing, copying, distributing or taking any action based on the contents of this email or attachments is prohibited.
>
> Is   OT Baile  tha Cliath a th inig an r omhphost seo. M  fuair t  an r omhphost seo tr  earr id, scrios de do ch ras   le do thoil. Tabhair ar aird, mura t  an seola  ainmnithe, go bhfuil dianchosc ar aon nochtadh, aon ch ipe il, aon d ileadh n  ar aon ghn omh a dh anfar bunaithe ar an  bhar at  sa r omhphost n  sna hiat in seo.
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-dynamic-models mailing list
> R-sig-dynamic-models using r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-dynamic-models



More information about the R-sig-dynamic-models mailing list