ylag: Generate subject-level lagged response

Description Usage Arguments Value Author(s) Examples

Description

Suppose you have longitudinal response y and it's subject id. This function generates lagged y for each subject.

Usage

1
ylag(id,y,lag,na=FALSE)

Arguments

id

subject id

y

response

lag

how many lags for y

na

logical; whether remain NAs in the response when lag >1. Default to FALSE and output 0s instead of NAs.

Value

return a vector of lagged y

Author(s)

Cong Xu, Zheng Li and Ming Wang

Examples

1
2
3
4
id <- rep(c(1:20),each=3)
y <- rnorm(length(id))
ylag(id,y,1) #lag=1
ylag(id,y,2,na=FALSE) #lag=2

wgeesel documentation built on May 2, 2019, 3:41 a.m.