Learn R Programming

sitar (version 1.0.4)

predict.sitar: Predict SITAR model

Description

Predict method for sitar objects, based on predict.lme.

Usage

## S3 method for class 'sitar':
predict(object, newdata, level=1, ..., deriv=0, abc=NULL, xfun=I, yfun=I)

Arguments

object
an object inheriting from class sitar.
newdata
an optional data frame to be used for obtaining the predictions. It requires named columns for x, and for id if level = 1, matching the names in object. Any covariates in a.formula, b.
level
an optional integer giving the level of grouping to be used in obtaining the predictions, level 0 corresponding to the population predictions. Defaults to level 1.
...
other optional arguments, including na.action and naPattern.
deriv
an optional integer specifying predictions corresponding to either the fitted curve or its first derivative (i.e. velocity), where deriv = 0 (default) specifies the distance curve and deriv = 1 the velocity curve.
abc
an optional named vector or single-row data frame containing values of a subset of a, b and c, default NULL. If it is set, level is ignored. It gives predictions for a subject with the speci
xfun
an optional function to apply to x to convert it back to the original scale, e.g. if x = log(age) then xfun = exp.
yfun
an optional function to apply to y to convert it back to the original scale, e.g. if y = sqrt(height) then yfun = function(z) z^2.

Value

  • A vector of the predictions, or a list of vectors if asList = TRUE or length(level) > 1.

Details

When deriv = 1 the returned velocity is in units of yfun(y) per xfun(x). So if x and/or y are transformed, velocity in the raw units can be obtained by specifying xfun and/or yfun to back-transform them appropriately.

Examples

Run this code
data(heights)
## fit model
m1 <- sitar(x=age, y=height, id=id, data=heights, df=5)

## predictions at level 0
predict(m1, newdata=data.frame(age=9:16), level=0)

## predictions at level 1 for subject 5
predict(m1, newdata=data.frame(age=9:16, id=5), level=1)

## velocity predictions for subjects with early and late puberty
vel1 <- predict(m1, deriv=1, abc=data.frame(b=-1))
mplot(age, vel1, id, heights, col=id)
vel1 <- predict(m1, deriv=1, abc=data.frame(b=1))
mplot(age, vel1, id, heights, col=id, add=TRUE)

Run the code above in your browser using DataLab