Questions tagged [desolve]

deSolve is an R package with functions for solving first-order ordinary differential equations ('ODE'), partial differential equations ('PDE'), differential algebraic equations ('DAE'), and delay differential equations. This tag should be used for questions regarding how to build or debug statistical models done with functions that belong to deSolve.

Package deSolve includes functions for solving initial value problems of a system of first-order ordinary differential equations (ODE), of partial differential equations (PDE), of differential algebraic equations (DAE), and of delay differential equations. The package provides an interface to the of the ODEPACK FORTRAN collection and a C-implementation of solvers of the Runge-Kutta family with fixed or variable time steps. The package also contains routines designed for solving ODEs resulting from 1-D, 2-D and 3-D partial differential equations (PDE).

Official website (r-project.org)

Repositories

Vignettes

64 questions
0
votes
0 answers

deSolve lsoda step size issue: Internal T (=R1) and H (=R2) are such that in the machine, T + H = T on the next step (H = step size)

I am having trouble with a relatively straight-forward ODE simulation in deSolve. I have previously run simulations with for() loops in R, but wanted to switch to a solver to improve some tipping point analyses. When I try to run the basic…
Gabe
  • 1
0
votes
1 answer

Problems in making a simulation with "deSolve" for a biological system

I have a hypothesis about a biological system I'm working with, and I need to use the program "deSolve" to formulate differential equations and parameters, in order to simulate the system. But I don't know what's wrong in my code.. This is the…
Lina2
  • 1
  • 1
0
votes
0 answers

Sympy dsolve for composite function

In the screen capture below, the first form of the ode has a composite function y(x(t)), I would like to solve for this function y(x(t)), which dsolve can't do. If I re-write the equation in the form of x(t), without the composition dsolve works…
0
votes
1 answer

Using deSolve: The number of derivatives returned by func must equal the length of the initial conditions vector

I get this error The number of derivatives returned by func() (1) must equal the length of the initial conditions vector (3) Can some kindly suggest how resolve ? Thanks library(deSolve) # Define the ODE system diffeq <- function(t, y, params) { …
Ravua1992
  • 21
  • 4
0
votes
1 answer

Why isn't ode in R solving easy differential equations?

I want to use deSolve to solve coupled partial differential equations, and am trying to get used to the package by solving easy differential equations with ode. I know the solution to y' = sqrt(1-y^2) is sin(t + c), so I tested it with the starting…
0
votes
0 answers

Initial state starts at y(1), how to go backwards to find y(0)?

I have set up a differential equation using the deSolve package and ode-function in R. I have the values for y(1), however I need to find y(0). Is there any function in R that allows me to calculate backwards and find y(0) values - the actual…
Mandy94
  • 37
  • 4
0
votes
1 answer

Changing value of parameters in R's deSolve when root function is triggered

Short version As suggested in comments, I am leaving a summarized, short version of the problem I found here. The original complete explanation can be found below. In summary, I am currently using the deSolve package and am interested in…
Rafa
  • 157
  • 6
0
votes
0 answers

Terminal root in R ode solver is ignored the first time

I'm having an issue with solving a periodic diff eq model. The trajectory of the model is cyclic and I want to stop it when a defined of cycles have been run. For this purpose I run the following root function in deSolve::ode: rootfun <- function…
Bakaburg
  • 3,165
  • 4
  • 32
  • 64
0
votes
1 answer

Combining root and non-root event functions in R desolve

I am using R and the desolve package to implement a model with events occuring at both specific times and events occuring when certain condtions are true (i.e. root events). As some background code here demonstrates using root events which trigger…
will1329
  • 173
  • 2
  • 14
0
votes
1 answer

How do I solve and plot a system of ODEs with R?

I have a system of odes, I want to plot V1 and V2 against time t. My code for that is library("deSolve") library("reshape") library("tidyverse") parameters <- c(tau = 0.005, tau_r = 0.0025, mui=0, Ve=0.06, Vi=-0.01, s=0.015, mue=10000) state <-…
14thTimeLord
  • 363
  • 1
  • 14
0
votes
1 answer

Influx at specific time with changing time step in DeSolve

I am making a population distribution model with ODEs and DDEs in DeSolve with the method lsoda. In this model I want to have an influx of the population at a specific time (a specific day). A very simple example: dn1dt=influx - mortality The influx…
Laura
  • 35
  • 5
0
votes
1 answer

Potential indexing issue in ODE?

Following @tpetzoldt suggestion i'm opening this as a question following the previous discussion (Parameter values as a function of another vector. deSolve). What i'm trying to achieve is to be able to integrate the model at each timestep over a…
0
votes
1 answer

How to implement a system in deSolve, R, with N equations a N+m parameters?

I am coding a SIR model in a metapopulation in R, I want to integrate the systema and for that I am using de deSolve with C compiled code, I have used this before but in the case having a few parameters, now I would have Nxm parameters where N is…
0
votes
1 answer

Realistic age structured model using ODE from the deSolve package

I am trying to simulate a realistic age structured model where all individuals could shift into the following age group at the end of the time step (and not age continuously at a given rate) using ODE from the deSolve package. Considering for…
Andyga
  • 15
  • 4
0
votes
2 answers

deSolve ODE Integration Error, am I using the wrong function?

I'm attempting to solve a set of equations related to biological processes. One equation (of about 5) is for a pharmacokinetic (PK) curve of the form C = Co(exp(k1*t)-exp(k2*t). The need is to simultaneously solve the derivative of this equation…
Justin K
  • 3
  • 2