Description Usage Arguments Details Value Examples
For parameter estimation and optimization, an objective function
is needed. normL2
returns an objective function for the L2 norm of
data and model prediction. The resulting objective function can be used for
optimization with the trust optimizer, see mstrust.
1 |
data |
object of class datalist |
x |
object of class prdfn |
errmodel |
object of class obsfn. |
times |
numeric vector, additional time points where the prediction function is
evaluated. If NULL, time points are extacted from the datalist solely. If the prediction
function makes use of events, hand over event |
attr.name |
character. The constraint value is additionally returned in an attributed with this name |
Objective functions can be combined by the "+" operator, see sumobjfn.
Object of class obsfn
, i.e. a function
obj(..., fixed, deriv, conditions, env)
that returns an objective list,
objlist.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | ## Generate a prediction function
times <- 0:5
grid <- data.frame(name = "A", time = times, row.names = paste0("p", times))
x <- Xd(grid, condition = "C1")
pars <- structure(rep(0, nrow(grid)), names = row.names(grid))
## Simulate data
data.list <- lapply(1:3, function(i) {
prediction <- x(times, pars + rnorm(length(pars), 0, 1))
cbind(wide2long(prediction), sigma = 1)
})
data <- as.datalist(do.call(rbind, data.list))
## Generate objective function based on data and model
## Then fit the data and plot the result
obj <- normL2(data, x)
myfit <- trust(obj, pars, rinit = 1, rmax = 10)
plot(x(times, myfit$argument), data)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.