Tidy summarizes information about the components of a model. A model component might be a single term in a regression, a single hypothesis, a cluster, or a class. Exactly what tidy considers to be a model component varies cross models but is usually self-evident. If a model has several distinct types of components, you will need to specify which components to return.

# S3 method for pyears
tidy(x, ...)

Arguments

x

A pyears object returned from survival::pyears().

...

Additional arguments. Not used. Needed to match generic signature only. Cautionary note: Misspelled arguments will be absorbed in ..., where they will be ignored. If the misspelled argument has a default value, the default value will be used. For example, if you pass conf.lvel = 0.9, all computation will proceed using conf.level = 0.95. Additionally, if you pass newdata = my_tibble to an augment() method that does not accept a newdata argument, it will use the default value for the data argument.

Value

A tibble::tibble with one row for each time point and columns:

pyears

person-years of exposure

n

number of subjects contributing time

event

observed number of events

expected

expected number of events (present only if a ratetable term is present)

If the data.frame = TRUE argument is supplied to pyears, this is simply the contents of x$data.

See also

Examples

library(survival) temp.yr <- tcut(mgus$dxyr, 55:92, labels=as.character(55:91)) temp.age <- tcut(mgus$age, 34:101, labels=as.character(34:100)) ptime <- ifelse(is.na(mgus$pctime), mgus$futime, mgus$pctime) pstat <- ifelse(is.na(mgus$pctime), 0, 1) pfit <- pyears(Surv(ptime/365.25, pstat) ~ temp.yr + temp.age + sex, mgus, data.frame=TRUE) tidy(pfit)
#> # A tibble: 1,752 x 6 #> temp.yr temp.age sex pyears n event #> <fct> <fct> <fct> <dbl> <dbl> <dbl> #> 1 71 34 female 0.00274 1 0 #> 2 68 35 female 0.00274 1 0 #> 3 72 35 female 0.00274 1 0 #> 4 69 36 female 0.00274 1 0 #> 5 73 36 female 0.00274 1 0 #> 6 69 37 female 0.00274 1 0 #> 7 70 37 female 0.00274 1 0 #> 8 74 37 female 0.00274 1 0 #> 9 70 38 female 0.00274 1 0 #> 10 71 38 female 0.00274 1 0 #> # … with 1,742 more rows
glance(pfit)
#> # A tibble: 1 x 2 #> total offtable #> <dbl> <dbl> #> 1 8.32 0.727
# if data.frame argument is not given, different information is present in # output pfit2 <- pyears(Surv(ptime/365.25, pstat) ~ temp.yr + temp.age + sex, mgus) tidy(pfit2)
#> # A tibble: 37 x 402 #> pyears.34.female pyears.35.female pyears.36.female pyears.37.female #> <dbl> <dbl> <dbl> <dbl> #> 1 0 0 0 0 #> 2 0 0 0 0 #> 3 0 0 0 0 #> 4 0 0 0 0 #> 5 0 0 0 0 #> 6 0 0 0 0 #> 7 0 0 0 0 #> 8 0 0 0 0 #> 9 0 0 0 0 #> 10 0 0 0 0 #> # … with 27 more rows, and 398 more variables: pyears.38.female <dbl>, #> # pyears.39.female <dbl>, pyears.40.female <dbl>, pyears.41.female <dbl>, #> # pyears.42.female <dbl>, pyears.43.female <dbl>, pyears.44.female <dbl>, #> # pyears.45.female <dbl>, pyears.46.female <dbl>, pyears.47.female <dbl>, #> # pyears.48.female <dbl>, pyears.49.female <dbl>, pyears.50.female <dbl>, #> # pyears.51.female <dbl>, pyears.52.female <dbl>, pyears.53.female <dbl>, #> # pyears.54.female <dbl>, pyears.55.female <dbl>, pyears.56.female <dbl>, #> # pyears.57.female <dbl>, pyears.58.female <dbl>, pyears.59.female <dbl>, #> # pyears.60.female <dbl>, pyears.61.female <dbl>, pyears.62.female <dbl>, #> # pyears.63.female <dbl>, pyears.64.female <dbl>, pyears.65.female <dbl>, #> # pyears.66.female <dbl>, pyears.67.female <dbl>, pyears.68.female <dbl>, #> # pyears.69.female <dbl>, pyears.70.female <dbl>, pyears.71.female <dbl>, #> # pyears.72.female <dbl>, pyears.73.female <dbl>, pyears.74.female <dbl>, #> # pyears.75.female <dbl>, pyears.76.female <dbl>, pyears.77.female <dbl>, #> # pyears.78.female <dbl>, pyears.79.female <dbl>, pyears.80.female <dbl>, #> # pyears.81.female <dbl>, pyears.82.female <dbl>, pyears.83.female <dbl>, #> # pyears.84.female <dbl>, pyears.85.female <dbl>, pyears.86.female <dbl>, #> # pyears.87.female <dbl>, pyears.88.female <dbl>, pyears.89.female <dbl>, #> # pyears.90.female <dbl>, pyears.91.female <dbl>, pyears.92.female <dbl>, #> # pyears.93.female <dbl>, pyears.94.female <dbl>, pyears.95.female <dbl>, #> # pyears.96.female <dbl>, pyears.97.female <dbl>, pyears.98.female <dbl>, #> # pyears.99.female <dbl>, pyears.100.female <dbl>, pyears.34.male <dbl>, #> # pyears.35.male <dbl>, pyears.36.male <dbl>, pyears.37.male <dbl>, #> # pyears.38.male <dbl>, pyears.39.male <dbl>, pyears.40.male <dbl>, #> # pyears.41.male <dbl>, pyears.42.male <dbl>, pyears.43.male <dbl>, #> # pyears.44.male <dbl>, pyears.45.male <dbl>, pyears.46.male <dbl>, #> # pyears.47.male <dbl>, pyears.48.male <dbl>, pyears.49.male <dbl>, #> # pyears.50.male <dbl>, pyears.51.male <dbl>, pyears.52.male <dbl>, #> # pyears.53.male <dbl>, pyears.54.male <dbl>, pyears.55.male <dbl>, #> # pyears.56.male <dbl>, pyears.57.male <dbl>, pyears.58.male <dbl>, #> # pyears.59.male <dbl>, pyears.60.male <dbl>, pyears.61.male <dbl>, #> # pyears.62.male <dbl>, pyears.63.male <dbl>, pyears.64.male <dbl>, #> # pyears.65.male <dbl>, pyears.66.male <dbl>, pyears.67.male <dbl>, #> # pyears.68.male <dbl>, pyears.69.male <dbl>, pyears.70.male <dbl>, …
glance(pfit2)
#> # A tibble: 1 x 2 #> total offtable #> <dbl> <dbl> #> 1 8.32 0.727