Skip to content

How to build kinetic models with integrals using the POMP package #230

@believe-bing

Description

@believe-bing

Dear King,
I'm very sorry that I've opened a new issue here to ask for your help. Recently, I intend to use the pomp package to build a differential equation that enables blood glucose prediction (Model frame.pdf). In contrast to the previous infectious disease model, this differential equation contains integrals as follows:

Image

I can implement it in R in the following way: by saving both the previously generated time variable and the blood glucose concentration (Gpl) in the global variables t_saved and Gpl_saved, and then linearly interpolating them via the approx function (The data used in the example: Test_data.csv). The codes we used as follow:

`
t_saved <- get("t_saved", envir = .GlobalEnv)
Gpl_saved <- get("Gpl_saved", envir = .GlobalEnv)
unique_indices <- !duplicated(t_saved)
t_saved_unique <- t_saved[unique_indices]
Gpl_saved_unique <- Gpl_saved[unique_indices]

t_lowerbound <- t - t_integralwindow
if ((t > t_integralwindow) && (length(t_saved_unique) > 1)) {
Gpl_lowerbound <- approx(t_saved_unique, Gpl_saved_unique, xout = t_lowerbound, rule = 2)$y
} else {
Gpl_lowerbound <- Gpl_saved_unique[1]
}
assign("t_saved", c(t_saved, t), envir = .GlobalEnv)
assign("Gpl_saved", c(Gpl_saved, Gpl), envir = .GlobalEnv)

`
I tried to build the above model using POMP but failed, can you give me some advice? The codes we used to build model were In the docx. (POMP_Codes.docx)

Thanks again.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions