
Last chance! 50% off unlimited learning
Sale ends in
Plot a list of model predictions and a list of data points in a combined plot
plotCombined(prediction, data = NULL, ..., scales = "free",
facet = "wrap", transform = NULL)# S3 method for prdlist
plot(x, data = NULL, ..., scales = "free",
facet = "wrap", transform = NULL)
# S3 method for prdframe
plot(x, data = NULL, ..., scales = "free",
facet = "wrap", transform = NULL)
Named list of matrices or data.frames, usually the output of a prediction function as generated by Xs.
Named list of data.frames as being used in res, i.e. with columns name
, time
,
value
and sigma
.
Further arguments going to subset
.
The scales argument of facet_wrap
or facet_grid
, i.e. "free"
, "fixed"
,
"free_x"
or "free_y"
Either "wrap"
or "grid"
list of transformation for the states, see coordTransform.
prediction
A plot object of class ggplot
.
The data.frame being plotted has columns time
, value
, sigma
,
name
and condition
.
# NOT RUN {
## Observation function
fn <- eqnvec(
sine = "1 + sin(6.28*omega*time)",
cosine = "cos(6.28*omega*time)"
)
g <- Y(fn, parameters = "omega")
## Prediction function for time
x <- Xt()
## Parameter transformations to split conditions
p <- NULL
for (i in 1:3) {
p <- p + P(trafo = c(omega = paste0("omega_", i)), condition = paste0("frequency_", i))
}
## Evaluate prediction
times <- seq(0, 1, .01)
pars <- structure(seq(1, 2, length.out = 3), names = attr(p, "parameters"))
prediction <- (g*x*p)(times, pars)
## Plotting prediction
# plot(prediction)
plotPrediction(prediction)
plotPrediction(prediction, scales = "fixed")
plotPrediction(prediction, facet = "grid")
plotPrediction(prediction,
scales = "fixed",
transform = list(sine = "x^2", cosine = "x - 1"))
## Simulate data
dataset <- wide2long(prediction)
dataset <- dataset[seq(1, nrow(dataset), 5),]
dataset$value <- dataset$value + rnorm(nrow(dataset), 0, .1)
dataset$sigma <- 0.1
data <- as.datalist(dataset, split.by = "condition")
## Plotting data
# plot(data)
plotData(data)
## Plotting data and prediction with subsetting
# plot(prediction, data)
plotCombined(prediction, data)
plotCombined(prediction, data,
time <= 0.5 & condition == "frequency_1")
plotCombined(prediction, data,
time <= 0.5 & condition != "frequency_1",
facet = "grid")
# }
Run the code above in your browser using DataLab