Learn R Programming

sitar (version 1.0.4)

plot.sitar: Plot SITAR model

Description

plot and lines methods for objects of class sitar, providing various flavours of plot of the fitted growth curves.

Usage

## S3 method for class 'sitar':
plot(x, opt = "dv", labels, apv = FALSE, xfun = NULL, yfun = NULL,
subset = NULL, abc = NULL, add = FALSE, nlme = FALSE, ...)
## S3 method for class 'sitar':
lines(x, ...)

Arguments

x
object of class sitar.
opt
character string containing a subset of letters corresponding to the options: 'd' for fitted Distance curve, 'v' for fitted Velocity curve, 'e' for fitted fixed Effects distance curve, 'D' for individual fitted Distance curves, 'V' for individual fitted V
labels
optional character vector containing plot labels for x, y and y velocity from the original SITAR model. The first two elements can alternatively be provided via par parame
apv
optional logical specifying whether or not to calculate the age at peak velocity from the velocity curve. If TRUE, age at peak velocity is calculated as the age when the second derivative of the fitted curve changes sign (after applying xfun
xfun
optional function to be applied to the x variable prior to plotting. Defaults to NULL, which translates to ifun(x$call.sitar$x) and inverts any transformation applied to x in the original SITAR model call. To plot on the transformed scale set
yfun
optional function to be applied to the y variable prior to plotting. Defaults to NULL, which translates to ifun(x$call.sitar$y) and inverts any transformation applied to y in the original SITAR model call. To plot on the transformed scale set
subset
optional logical vector of length x defining a subset of data rows to be plotted.
abc
vector of named values of random effects a, b and c used to define an individual growth curve, e.g. abc=c(a=1, c=-0.1). Alternatively a single character string defining an id level whose random effect values are used. If abc is s
add
optional logical defining if the plot is pre-existing (TRUE) or new (FALSE). TRUE is equivalent to using lines.
nlme
optional logical which set TRUE plots the model as an nlme object, using plot.nlme arguments.
...
Further graphical parameters (see par) may also be supplied as arguments, e.g. axis labels xlab and ylab, line type lty, line width lwd, and color col. For the velocity (y2) plo

Value

  • Returns invisibly a list of three objects:
  • sssmooth.spline object corresponding to the fitted distance curve.
  • usrvalue of par('usr') for the main plot.
  • usr2the value of par('usr') for the velocity (y2) plot.
  • apvif argument apv is TRUE a named list giving the age at peak velocity (apv) and peak velocity (pv) from the fitted velocity curve.

Details

For option 'dv' (the default) the velocity curve plot (with right axis) can be annotated with par parameters given as a named list called y2par. To suppress the legend that comes with it set xlegend = NULL.

See Also

lines.sitar, mplot, plotclean, y2plot, ifun

Examples

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

## draw fitted distance and velocity curves
## with velocity curve in blue
## adding age at peak velocity
plot(m1, y2par=list(col='blue'), apv=TRUE)

## draw individually coloured growth curves adjusted for random effects
## using same x-axis limits as for previous plot
plot(m1, opt='a', col=id, xlim=xaxsd())

## add mean curve in red
lines(m1, opt='d', col='red', lwd=2)

## add mean curve for a, b, c = -1 SD
lines(m1, opt='d', lwd=2, abc=-sqrt(diag(getVarCov(m1))))

Run the code above in your browser using DataLab