Practicals9 1.1 Reading
Total Page:16
File Type:pdf, Size:1020Kb
Statistical Analysis in the Lexis Diagram: Age-Period-Cohort models Max Planck Institut for Demographic Research, Rostock March 2009 www.biostat.ku.dk/~bxc/APC/MPIDR-2009 (Compiled Sunday 29th March, 2009 at 01:23) Bendix Carstensen Steno Diabetes Center, Gentofte, Denmark & Department of Biostatistics, University of Copenhagen [email protected] http://www.biostat.ku.dk/~bxc/ Eva Gelnarova Institute of Biostatistics and Analyses, Masaryk University, Brno Czech Republic [email protected] Contents 1 Introduction to computing and practicals9 1.1 Reading . .9 1.2 Introduction to exercises . .9 1.2.1 Datasets and how to access them. .9 1.2.2 R-functions . .9 1.2.3 Solutions . .9 1.3 Probability concepts in follow-up studies . 10 Bibliography 13 2 Practical exercises 15 2.1 Danish primeministers . 15 2.2 Reading and tabulating data . 18 2.3 Rates and survival . 20 2.4 Age-period model . 22 2.5 Age-cohort model . 24 2.6 Age-drift model . 25 2.7 Age-period-cohort model . 26 2.8 Age-period-cohort model for triangles . 27 2.9 Using apc.fit etc...................................... 31 2.10 Lung cancer: the sex difference . 33 2.11 Prediction of breast cancer rates . 34 3 Solutions to exercises 35 3.1 Danish primeministers . 35 3.2 Reading and tabulating data . 41 3.3 Rates and survival . 48 3.4 Age-period model . 53 3.5 Age-cohort model . 62 3.6 Age-drift model . 66 3.7 Age-period-cohort model . 70 3.8 Age-period-cohort model for triangles . 77 3.9 Using apc.fit etc...................................... 84 3.10 Lung cancer: the sex difference . 91 3.11 Prediction of breast cancer rates . 98 3 4 The Epi manual (1.0.11) 107 apc.fit ............................................ 107 apc.frame . 110 apc.lines........................................... 111 apc.plot ........................................... 113 bdendo............................................ 113 bdendo11 . 114 births ............................................ 114 blcaIT............................................ 115 brv.............................................. 115 cal.yr ............................................ 116 ccwc............................................. 117 ci.cum............................................ 118 ci.lin............................................. 120 ci.pd............................................. 121 contr.cum.......................................... 122 cutLexis........................................... 123 detrend ........................................... 125 diet ............................................. 126 DMconv........................................... 127 effx.match.......................................... 127 effx.............................................. 128 ewrates ........................................... 130 expand.data . 130 fit.add............................................ 131 fit.baseline.......................................... 132 fit.mult ........................................... 133 float ............................................. 134 ftrend ............................................ 135 gmortDK .......................................... 136 hivDK............................................ 137 Icens............................................. 137 lep.............................................. 139 Lexis.diagram . 139 Lexis.lines.......................................... 141 Lexis............................................. 142 Life.lines........................................... 145 lungDK ........................................... 146 merge.data.frame . 146 merge.Lexis . 147 mh.............................................. 148 mortDK........................................... 149 ncut ............................................. 150 nice ............................................. 151 nickel ............................................ 152 pctab ............................................ 152 plot.Lexis .......................................... 153 plotEst............................................ 154 plotevent .......................................... 156 projection.ip......................................... 157 rateplot ........................................... 157 Relevel............................................ 161 ROC............................................. 161 S.typh............................................ 162 splitLexis .......................................... 163 start.Lexis.......................................... 165 stattable.funs . 165 stat.table .......................................... 166 subset.Lexis . 168 summary.Lexis . 169 tabplot............................................ 170 thoro............................................. 171 timeBand . 172 timeScales.......................................... 173 transform.Lexis . 173 twoby2............................................ 174 W.Lexis........................................... 175 6 Course program Age-Period-Cohort models Preface The course in Age-Period-Cohort models at Max Planck Institute for Demographic Research was initiated by an invitation from Jutta Gambe to me. I accepted on the condition that I was allowed to draw on the assistance for preparation and tutoring of practicals from Eva Gelnarova, whom I met when she was a student at the course \Statistical Practise in Epidemiology with R" in Tartu, Estonia in the summer of 2008. This set of practical exercises were deveoped in collaboration between us during the first months of 2009. I did the final editing so any faults and errors are my responsibility. Bendix Carstensen Course program The daily program will have one lecture and one practical each morning and each afternoon. Lectures will be between 45 and 90 minutes; normally with one or two breaks. The practicals will follow the lecture to fill the 3-hour slot. Sometimes we may need to push over some of the practical computing to take a bit of the beginning of the next slot. Monday 23rd 09:00 { 09:15 Welcome and introduction. 09:15 { 12:15 Morning slot: { L1: Follow-up time and rates from register data (surv-rate) { Lexis machinery in Epi (lifetable) { Follow-up time and rates from population data (tab-mod) { P1: Danish prime ministers (pm) 13:15 { 16:15 Afternoon slot: { L2: Likelihood for rates: Cox and Poisson { Cox as limit of the Poisson (WntCma) { Poisson model for rates: Factor models { Practical handling of linear contrasts in R using ci.lin() (tab-mod) { P2: Rates and survival (rates) { Tabulation (tabulate) Max Planck Institut for Demographic Research, Rostock, March 2009 Course program 7 Tuesday 24th 09:00 { 09:30 Recap of Monday 09:30 { 12:15 Morning slot: { L3: The age-period and the age-cohort model. (AP-AC) { The Age-drift model { P3: Age-period model (age-per) { Age-cohort model (age-coh) { Age-drift model (age-drift) 13:15 { 16:15 Afternoon slot: { L4: The Age-period-cohort model { Parametrizations { P4: Age-period-cohort model (age-per-coh) Wednesday 25th 09:00 { 09:30 Recap of Tuesday 09:30 { 12:15 Morning slot: { L5: Data tabulated by age period and cohort. { Parametrization revisted: The general case. { P5: Age-period-cohort model for triangles (apc-tri) { L5: The implementation of apc.fit. { Parametrizations. { The residual parametrization. { P5: Using the apc-functions from Epi.(apc-fit) 13:15 { 16:15 Afternoon slot: { L6: Several rates compared with APC-models: { Estimation and reporting of effects. { Parametrization options for several rates. { P6: Lung cancer differences by sex (lung-sex) Thursday 26th 09:00 { 16:00 Study free: Working with the assignment. Friday 27th 09:00 { 09:30 Recap of Wednesday 09:30 { 12:15 Morning slot: { L7: Predictions based on APC models { Managing splines for prediction { P7: Predicting lung cancer (lung-pred) { Predicting breast cancer (breast-pred) 13:15 { 15:15 Afternoon slot: { L8: Overview of course: { What can the models be used for and what not. { P8: Assignments. 15:15 { 15:30 Wrapping up, closure, evaluation and farewell 8 Course program Age-Period-Cohort models Chapter 1 Introduction to computing and practicals 1.1 Reading It would be helpful if you had read the papers which cover the essentials of the models that we will cover: [4,2,3,1] 1.2 Introduction to exercises Most of the following exercises all require basic skills in computing, in R, in particular the use of the graphical facilities. 1.2.1 Datasets and how to access them. All the datasets for the exercises in this section are in the folder APC\data. This can be accessed through the homepage of the course, as: http://www.biostat.ku.dk/~bxc/APC/data. The datasets with .txt extension are plain text files where variable names are found in the first line. Such datasets can be read into R with the command read.table, and into SAS by using in %read_table macro supplied in the APC\sas\sasmacro folder. This can be accessed through the homepage of the course, as: http://www.biostat.ku.dk/~bxc/APC/sas/sasmacro. 1.2.2 R-functions All the relevant functions for this course (and several more) are supplied in the R-package Epi, which can be downloaded from CRAN (on the R-website). > library( Epi ) > library( help=Epi ) The latter command will list the package information, including names of all the functions available with brief descriptions. 1.2.3 Solutions This document also contains some suggestions for solutions of teh assignments. They should not be taken as the only let alone exhuastive solutions to the practicals. 9 10 Introduction to computing Age-Period-Cohort models It is a good idea to give it a shot to do the practicals before you look in the solutions. However,