Description Usage Arguments Value Examples
Given a Ptmodels object
, the predict.Ptmodels will produce a named
numeric vector of either time (seconds) or power (watts) values according to
the x
and y
arguments
1 2 |
object |
an object of class "Ptmodels". |
x |
the value for which to make a prediction. |
xtype |
what is |
... |
further arguments passed to or from other methods. |
a named numeric vector of predicted values. Names correspond to their respective models.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | data(Pt_prof) # Example power-time profile.
P <- Pt_prof$pwr
tsec <- Pt_prof$time
mdls <- Pt_model(P, tsec) ## Model.
print(mdls)
## What is the best predicted 20 minute power?
predict(mdls, x = 60 * 20, xtype = "time")
## How sustainable is 500 Watts?
predict(mdls, x = 500, xtype = "P") / 60 # Minutes.
## Create some plots of the models.
par(mfrow = c(2, 2), mar = c(3.1, 3.1, 1.1, 1.1))
plotargs <- alist(x = tsec, y = P, cex = 0.2, ann = FALSE, bty = "l")
mapply(function(f, m) {
do.call(plot, plotargs)
curve(f(x), col = "red", add = TRUE)
title(main = paste0(rownames(m),"; RSE = ", round(m$RSE, 2)))
legend("topleft", legend = m$formula, bty = "n")
return()
}, f = mdls$Pfn, m = split(mdls$table, seq_len(nrow(mdls$table))))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.