Skip to contents

This function emulates the xtdescribe function in Stata.

Usage

xtdescribe(x, id_col = 1, time_col = 2, n_patterns = 9)

Arguments

x

data.frame: Longitudinal data with ID and time variables.

id_col

Integer: The column position of the ID variable.

time_col

Integer: The column position of the time variable.

n_patterns

Integer: The number of patterns to display.

Value

data.frame: Summary of participation patterns, returned invisibly.

Author

EDG

Examples

# Load example longitudinal dataset
data(xt_example)

# Describe the longitudinal structure
xtdescribe(xt_example)
#> patient_id: 1, 2, ..., 10                         n = 10
#>       year: 2020, 2021, ..., 2024                         T = 5
#>             Delta (year) = 1 unit
#>             Span (year) = 5 periods
#>             (patient_id*year uniquely identifies each observation)
#> 
#> Distribution of T_i:	min	5%	25%	50%	75%	95%	max
#>                     	1	1	2	3	4	5	5
#>  Freq. Percent   Cum.          Pattern
#>      2      20     20            1.1.1
#>      2      20     40            11111
#>      1      10     50            ....1
#>      1      10     60            ...11
#>      1      10     70            .1111
#>      1      10     80            1....
#>      1      10     90            11...
#>      1      10    100            1111.
#>     NA    <NA>   <NA>             <NA>
#>      0       0 100.00 (other patterns)
#>     10  100.00                   XXXXX