predict.gmusim: Predict the Shape Invariant Model with random effects...

Description Usage Arguments Details Value Author(s) Examples

Description

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

Usage

1
2
## S3 method for class 'gmusim'
predict(object, newdata, level = 1, ...)

Arguments

object

an object inheriting from class gmusim.

newdata

an optional data frame to be used for obtaining the predictions. It requires named columns for x, z and for id if level = 1, matching the names in object. Note that values of covariates z should be centralizated. By default their values are set to the mean so when level = 0 the prediction represents the mean curve. Note that factors are coded as instrumental variables for each level, corresponding to the fixed effect coefficients in the model, so their names need the level appending..

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.

Details

Note that if level = 1, this function calculates predicton for every measurment of individuals; if level = 0, it calculates mean value of individuals' measurements.

Value

A vector of the predictions.

Author(s)

Zhiqiang Cao zcaoae@connect.ust.hk, Man-Yu Wong mamywong@ust.hk

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
require(sitar)
data(heights)
x <- heights$age
y <- heights$height
men <- heights$men
id <- heights$id
df <- 5
#since negative value are censored, here use absolute value
z <- data.frame(z1=abs(men))
p <- 1
n <- length(x)
## fit sitar model with covariates
resu1 <- gmusim_both(x,y,z,p,n,id,df)
## predictions at level = 0
on.exit(detach(resu1))
eval(parse(text = "attach(resu1)"))
predict(resu1, newdata=data.frame(x=6:15,z1=rep(mean(men),10)), level=0)
## predictions at level = 1 for all subjects
newd <- data.frame(x=heights$age,z1=abs(men)-mean(abs(men)),id=id)
on.exit(detach(resu1))
eval(parse(text = "attach(resu1)"))
fitted.values <- predict(resu1, newdata=newd, level=1)

Zhiqiangcao/gmusim documentation built on May 10, 2019, 1:58 a.m.