predict.sitar {sitar}R Documentation

Predict SITAR model

Description

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

Usage

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

Arguments

object

an object inheriting from class sitar.

newdata

an optional data frame to be used for obtaining the predictions, defaulting to the data used to fit object. It requires named columns for x, and for id if level = 1, matching the names in object. Variables with the reserved names x=.x or id=.id take precedence over the model x and id variables. Any covariates in a.formula, b.formula, c.formula or d.formula can also be included. By default their values are set to the mean, so when level = 0 the prediction represents the mean curve.

level

an optional integer vector giving the level(s) of grouping to be used in obtaining the predictions, level 0 corresponding to the population predictions. Defaults to level 1, and level = 0:1 fits both levels.

...

other optional arguments: asList, na.action and naPattern.

deriv

an optional integer specifying predictions corresponding to either the fitted curve or its derivative. deriv = 0 (default) specifies the distance curve, deriv = 1 the velocity curve and deriv = 2 the acceleration curve.

abc

an optional named vector containing values of a subset of a, b, c and d, default NULL. Ignored if level = 0. It gives predictions for a single subject with the specified values of a, b, c and d, where missing values are set to 0. Alternatively abc can contain the value for a single id.

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. Only relevant if deriv > 0 - see Details.

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.

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 units of y per x can be obtained by specifying xfun and/or yfun to back-transform them appropriately.

Value

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

Author(s)

Tim Cole tim.cole@ucl.ac.uk

See Also

ifun for a way to generate the functions xfun and yfun automatically from the sitar model call.

Examples


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=c(b=-1))
mplot(age, vel1, id, heights, col=id)
vel1 <- predict(m1, deriv=1, abc=c(b=1))
mplot(age, vel1, id, heights, col=id, add=TRUE)


[Package sitar version 1.4.0 Index]