Parameter transformation function

Description

Generate functions that transform one parameter vector into another by means of a transformation, pushing forward the jacobian matrix of the original parameter. Usually, this function is called internally, e.g. by P. However, you can use it to add your own specialized parameter transformations to the general framework.

Usage

1
parfn(p2p, parameters = NULL, condition = NULL)

Arguments

p2p

a transformation function for one condition, i.e. a function p2p(p, fixed, deriv) which translates a parameter vector p and a vector of fixed parameter values fixed into a new parameter vector. If deriv = TRUE, the function should return an attribute deriv with the Jacobian matrix of the parameter transformation.

parameters

character vector, the parameters accepted by the function

condition

character, the condition for which the transformation is defined

Value

object of class parfn, i.e. a function p(..., fixed, deriv, conditions, env). The argument pars should be passed via the ... argument.

Contains attributes "mappings", a list of p2p functions, "parameters", the union of parameters acceted by the mappings and "conditions", the total set of conditions.

See Also

sumfn, P

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
34
35
36
# Define a time grid on which to make a prediction by peace-wise linear function.
# Then define a (generic) prediction function based on thid grid.
times <- 0:5
grid <- data.frame(name = "A", time = times, row.names = paste0("p", times))
x <- Xd(grid)

# Define an observable and an observation function
observables <- eqnvec(Aobs = "s*A")
g <- Y(g = observables, f = NULL, states = "A", parameters = "s")

# Collect parameters and define an overarching parameter transformation
# for two "experimental condtions".
dynpars <- attr(x, "parameters")
obspars <- attr(g, "parameters")
innerpars <- c(dynpars, obspars)

trafo <- structure(innerpars, names = innerpars)
trafo_C1 <- replaceSymbols(innerpars, paste(innerpars, "C1", sep = "_"), trafo)
trafo_C2 <- replaceSymbols(innerpars, paste(innerpars, "C2", sep = "_"), trafo)

p <- NULL
p <- p + P(trafo = trafo_C1, condition = "C1")
p <- p + P(trafo = trafo_C2, condition = "C2")

# Collect outer (overarching) parameters and 
# initialize with random values
outerpars <- attr(p, "parameters")
pars <- structure(runif(length(outerpars), 0, 1), names = outerpars)

# Predict internal/unobserved states
out1 <- (x*p)(times, pars)
plot(out1)

# Predict observed states in addition to unobserved
out2 <- (g*x*p)(times, pars)
plot(out2)

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