Biostatistics III in R

Exercise 22. Estimating the effect of a time-varying exposure – the bereavement data

These data were used to study a possible effect of marital bereavement (loss of husband or wife) on all–cause mortality in the elderly. The dataset was extracted from a larger follow-up study of an elderly population and concerns subjects whose husbands or wives were alive at entry to the study. Thus all subjects enter as not bereaved but may become bereaved at some point during follow–up. The variable dosp records the date of death of each subject’s spouse and takes the value 1/1/2000 where this has not yet happened.


library('knitr')
read_chunk('../q22.R')
opts_chunk$set(cache=FALSE,dpi=20)

You may have to install the required packages the first time you use them. You can install a package by install.packages("package_of_interest") for each package you require.


(a) ##



(b) ##

i. The timescale is attained age, which would seem to be a reasonable choice. ii. Males have the higher mortality which is to be expected. iii. Age could potentially be a confounder. Males are slightly older at diagnosis (although we haven't studied pairwise differences).


(c) Breaking records into pre and post bereavement. ##


(d) ##

Now find the (crude) effect of bereavement.


(e) ##


(f) Controlling for age.##


(g) ##


(h) ##

We could split the post bereavement period into multiple categories (e.g., within one year and subsequent to one year following bereavement) and compare the risks between these categories.

(i) Analysis using Cox regression.##

Cox regression: effect of brv controlled for attained age:


(j) ##

Cox regression estimating the effect of brv for each sex, controlling for age:




Try the biostat3 package in your browser

Any scripts or data that you put into this service are public.

biostat3 documentation built on Oct. 29, 2024, 5:07 p.m.