[R-sig-dyn-mod] Solving systems of differential equations in matrix form with deSolve

Johannes Ranke joh@nne@@r@nke @end|ng |rom jrwb@de
Wed Apr 13 07:57:41 CEST 2022


Hello Nicola,

Am Dienstag, 12. April 2022, 17:04:58 CEST schrieb Nicola Gambaro:
> Dear all,
> 
> I have a model that is quite complicated to express as a list of single
> differential equations. It would be much easier to express it in matrix
> form, but I have not found an example of how deSolve can be used to do
> this.
> 
> Let us take as an example the simple linear system of ordinary differential
> equations
> 
> dY/dt = AY + F

in that case, why do you want to use deSolve? You can find a solution using the 
Eigenvalues and Eigenvectors of the matrix (function eigen() from R base) and 
get the constant matching your initial conditions using solve(), also from R 
base.

You can have a look at the respective code in my mkin package [1]. Eigenvalue 
based solution gives a nice performance boost for this type of system, 
compared deSolve with pure R [2].

Kind regards,

Johannes

[1] https://cgit.jrwb.de/mkin/tree/R/mkinpredict.R?h=main#n161 
[2] https://pkgdown.jrwb.de/mkin/articles/web_only/
compiled_models.html#comparison-with-other-solution-methods 

> where Y is the vector of the independent variables, A is the matrix of model
> parameters and F is the inhomogeneous part of the equations.
> 
> How do you go about using deSolve’s ode() function to solve this system?
> 
> Many thanks for your help in advance,
> Nicola
> 
> _______________________________________________
> R-sig-dynamic-models mailing list
> R-sig-dynamic-models using r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-dynamic-models

	[[alternative HTML version deleted]]



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