Parameter transformation (implicit)

Share:

Description

Parameter transformation (implicit)

Usage

1
2
Pimpl(trafo, parameters = NULL, condition = NULL, keep.root = TRUE,
  positive = TRUE, compile = FALSE, modelname = NULL, verbose = FALSE)

Arguments

trafo

Named character vector defining the equations to be set to zero. Names correspond to dependent variables.

parameters

Character vector, the independent variables.

condition

character, the condition for which the transformation is generated

keep.root

logical, applies for method = "implicit". The root of the last evaluation of the parameter transformation function is saved as guess for the next evaluation.

positive

logical, returns projection to the (semi)positive range. Comes with a warning if the steady state has been found to be negative.

compile

Logical, compile the function (see funC0)

modelname

Character, used if compile = TRUE, sets a fixed filename for the C file.

verbose

Print compiler output to R command line.

Details

Usually, the equations contain the dependent variables, the independent variables and other parameters. The argument p of p2p must provide values for the independent variables and the parameters but ALSO FOR THE DEPENDENT VARIABLES. Those serve as initial guess for the dependent variables. The dependent variables are then numerically computed by multiroot. The Jacobian of the solution with respect to dependent variables and parameters is computed by the implicit function theorem. The function p2p returns all parameters as they are with corresponding 1-entries in the Jacobian.

Value

a function p2p(p, fixed = NULL, deriv = TRUE) representing the parameter transformation. Here, p is a named numeric vector with the values of the outer parameters, fixed is a named numeric vector with values of the outer parameters being considered as fixed (no derivatives returned) and deriv is a logical determining whether the Jacobian of the parameter transformation is returned as attribute "deriv".

See Also

Pexpl for explicit parameter transformations

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
########################################################################
## Example 1: Steady-state trafo
########################################################################
f <- c(A = "-k1*A + k2*B",
       B = "k1*A - k2*B")
P.steadyState <- Pimpl(f, "A")

p.outerValues <- c(k1 = 1, k2 = 0.1, A = 10, B = 1)
P.steadyState(p.outerValues)

########################################################################
## Example 2: Steady-state trafo combined with log-transform
########################################################################
f <- c(A = "-k1*A + k2*B",
       B = "k1*A - k2*B")
P.steadyState <- Pimpl(f, "A")

logtrafo <- c(k1 = "exp(logk1)", k2 = "exp(logk2)", A = "exp(logA)", B = "exp(logB)")
P.log <- P(logtrafo)

p.outerValue <- c(logk1 = 1, logk2 = -1, logA = 0, logB = 0)
(P.log)(p.outerValue)
(P.steadyState * P.log)(p.outerValue)

########################################################################
## Example 3: Steady-states with conserved quantitites
########################################################################
f <- c(A = "-k1*A + k2*B", B = "k1*A - k2*B")
replacement <- c(B = "A + B - total")
f[names(replacement)] <- replacement

pSS <- Pimpl(f, "total")
pSS(c(k1 = 1, k2 = 2, A = 5, B = 5, total = 3))

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.