Learn R Programming

dMod (version 0.3.1)

as.parframe: Coerce object to a parameter frame

Description

Coerce object to a parameter frame

Usage

as.parframe(x, ...)
"as.parframe"(x, sort.by = "value", ...)

Arguments

x
object to be coerced
...
other arguments
sort.by
character indicating by which colum the returned parameter frame should be sorted. Defaults to "value".

Value

object of class parframe.

Examples

Run this code
## Generate a prediction function
regfn <- c(y = "sin(a*time)")

g <- Y(regfn, parameters = "a")
x <- Xt(condition = "C1")

## Generate data
data <- datalist(
  C1 = data.frame(
    name = "y",
    time = 1:5,
    value = sin(1:5) + rnorm(5, 0, .1),
    sigma = .1
  )
)

## Initialize parameters and time 
pars <- c(a = 1)
times <- seq(0, 5, .1)

plot((g*x)(times, pars), data)

## Do many fits from random positions and store them into parlist
out <- as.parlist(lapply(1:50, function(i) {
  trust(normL2(data, g*x), pars + rnorm(length(pars), 0, 1), rinit = 1, rmax = 10)
}))

summary(out)

## Reduce parlist to parframe
parframe <- as.parframe(out)
plotValues(parframe)

## Reduce parframe to best fit
bestfit <- as.parvec(parframe)
plot((g*x)(times, bestfit), data)

## Plot array with all solutions
plotArray(parframe, g*x, times, data)

Run the code above in your browser using DataLab