eode_lossf {ecode}R Documentation

Calculate Loss Function

Description

Calculate the quadratic loss function given an ODE system and observed population dynamics.

Usage

eode_lossf(x, pdat, step = 0.01)

Arguments

x

the ODE system under consideration. An object of "eode" class.

pdat

observed population dynamics. An object of "pdata" class.

step

interval of time for each step. Parameter of the function "eode_proj()".

Value

a value of loss function

Examples

dX_Cdt <- function(X_C, Y_C, X_A, Y_A, nu = 0.15, beta = 0.1, mu = 0.15, g = 0.04) {
  nu * (X_A + Y_A) - beta * X_C * (Y_C + Y_A) - (mu + g) * X_C
}

dY_Cdt <- function(X_C, Y_C, Y_A, beta = 0.1, mu = 0.15, g = 0.04, rho = 0.2) {
  beta * X_C * (Y_C + Y_A) - (mu + g + rho) * Y_C
}

dX_Adt <- function(X_C, Y_C, X_A, Y_A, beta = 0.1, g = 0.04) {
  g * X_C - beta * X_A * (Y_C + Y_A)
}

dY_Adt <- function(X_A, Y_C, Y_A, beta = 0.1, g = 0.04, rho = 0.2) {
  beta * X_A * (Y_C + Y_A) + g * Y_C - rho * Y_A
}

x <- eode(
  dX_Cdt = dX_Cdt, dY_Cdt = dY_Cdt, dX_Adt = dX_Adt, dY_Adt = dY_Adt,
  constraint = c("X_C>=0", "Y_C>=0", "X_A>=0", "Y_A>=0")
)
training_data <- pdata(x,
  init = data.frame(
    X_A = c(9, 19, 29, 39),
    Y_A = c(1, 1, 1, 1),
    X_C = c(5, 5, 5, 5),
    Y_C = c(0, 0, 0, 0)
  ),
  t = c(3, 3, 3, 3),
  lambda = data.frame(incidence = c(0.4, 0.8, 0.9, 0.95)),
  formula = "incidence = (Y_A + Y_C)/(X_A + X_C + Y_A + Y_C)"
)
eode_lossf(x, pdat = training_data)

[Package ecode version 0.1.0 Index]