Learn R Programming

sitar (version 1.0.4)

xyadj: Adjust x and y variables for SITAR random effects

Description

xyadj Adjusts x and y values for subject-specific random effects from a SITAR model.

Usage

xyadj(x, y=NULL, id, object, abc=NULL, tomean=TRUE)

Arguments

x
a vector of x coordinates.
y
a vector of y coordinates (default NULL).
id
a factor denoting the subject levels corresponding to x and y.
object
a SITAR model.
abc
a data frame containing random effects for (a subset of) a, b and c (default ranef(object)).
tomean
a logical defining the direction of adjustment. TRUE (default) indicates that individual curves are translated and rotated to match the mean curve, while FALSE indicates the reverse, the mean curve being translated and rotated to match an individual curve

Value

  • The list of adjusted values:
  • xnumeric vector.
  • ynumeric vector the same length as x, or NULL.

Details

When tomean = TRUE the x and y values are adjusted to $$(x - xoffset - b - b) * exp(c) + xoffset + b$$ $$y - a$$ When tomean = FALSE they are adjusted to $$(x - xoffset - b) / exp(c) + xoffset + b + b$$ $$y + a$$ In each case missing values of xoffset or the fixed or random effects are treated as zero.

When abc consists of a single row, it is applied to all x,y pairs irrespective of id.

Examples

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

## plot unadjusted data as growth curves
plot(m1, opt='u')

## overplot with adjusted data as points
with(heights, points(xyadj(age, height, id, m1), col='red', pch=19))

Run the code above in your browser using DataLab