# N2Y: Create risk time ("Person-Years") in Lexis triangles from... In Epi: A Package for Statistical Analysis in Epidemiology

## Description

Data on population size at equidistant dates and age-classes are used to estimate person-time at risk in Lexis-triangles, i.e. classes classified by age, period AND cohort (date of birth). Only works for data where age-classes have the same width as the period-intervals.

## Usage

 1 2 3 N2Y( A, P, N, data = NULL, return.dfr = TRUE)

## Arguments

 A Name of the age-variable, which should be numeric, corresponding to the left endpoints of the age intervals. P Name of the period-variable, which should be numeric, corresponding to the date of population count. N The population size at date P in age class A. data A data frame in which arguments are interpreted. return.dfr Logical. Should the results be returned as a data frame (default TRUE) or as a table.

## Details

The calculation of the risk time from the population figures is done as described in: B. Carstensen: Age-Period-Cohort models for the Lexis diagram. Statistics in Medicine, 26: 3018-3045, 2007.

The number of periods in the result is one less than the number of dates (nP=length(table(P))) in the input, so the number of distinct values is 2*(nP-1), because the P in the output is coded differently for upper and lower Lexis triangles.

The number of age-classes is the same as in the input. In the paper "Age-Period-Cohort models for the Lexis diagram" I suggest that the risk time in the lower triangles in the first age-class and in the upper triangles in the last age-class are computed so that the total risk time in the age-class corresponds to the average of the two population figures for the age-class at either end of the period. This is the method used.

## Value

A data frame with variables A, P and Y, representing the mean age and period in the Lexis triangles and the person-time in them, respectively. The person-time is in units of the distance between population count dates.

If res.dfr=FALSE a three-way table classified by the left end point of the age-classes and the periods and a factor wh taking the values up and lo corresponding to upper (early cohort) and lower (late cohort) Lexis triangles.

## Author(s)

Bendix Carstensen, BendixCarstensen.com

## References

B. Carstensen: Age-Period-Cohort models for the Lexis diagram. Statistics in Medicine, 26: 3018-3045, 2007.