predict.Ptmodels: Predict Power or Time

Description Usage Arguments Value Examples

Description

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

Usage

1
2
## S3 method for class 'Ptmodels'
predict(object, x, xtype = c("pwr", "time"), ...)

Arguments

object

an object of class "Ptmodels".

x

the value for which to make a prediction.

xtype

what is x? A power or a time value?

...

further arguments passed to or from other methods.

Value

a named numeric vector of predicted values. Names correspond to their respective models.

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
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))))

cycleRtools documentation built on May 2, 2019, 10:51 a.m.