Create a Lexis Object with Follow-up Time, Period, and Age Time Scales

Share:

Description

This is a simple wrapper around Lexis for creating a Lexis object with the time scales fot, per, and age.

Usage

1
2
Lexis_fpa(data, birth = NULL, entry = NULL, exit = NULL,
  entry.status = NULL, exit.status = NULL, subset = NULL, ...)

Arguments

data

a data.frame; mandatory

birth

the time of birth; A character string naming the variable in data or an expression to evaluate - see Flexible input

entry

the time at entry to follow-up; supplied the same way as birth

exit

the time at exit from follow-up; supplied the same way as birth

entry.status

passed on to Lexis if not NULL; supplied the same way as birth

exit.status

passed on to Lexis if not NULL; supplied the same way as birth

subset

a logical condition to subset by before passing data and arguments to Lexis

...

additional optional arguments passed on to Lexis

Value

A Lexis object with the usual columns that Lexis objects have, with time scale columns fot, per, and age. They are calculated as

fot = entry - entry (to ensure correct format, e.g. difftime)

per = entry

and

age = entry - birth

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
data("sire", package = "popEpi")

lex <- Lexis_fpa(sire, 
                 birth = "bi_date", 
                 entry = dg_date, 
                 exit = ex_date + 1L,
                 exit.status = "status")

## some special cases
myVar <- "bi_date"
l <- list(myVar = "bi_date")
sire$l <- sire$myVar <- 1

## conflict: myVar taken from data when "bi_date" was intended
lex <- Lexis_fpa(sire, 
                 birth = myVar, 
                 entry = dg_date, 
                 exit = ex_date + 1L,
                 exit.status = "status")

## no conflict with names in data
lex <- Lexis_fpa(sire, 
                 birth = l$myVar, 
                 entry = dg_date, 
                 exit = ex_date + 1L,
                 exit.status = "status")

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.