Skip to main content
improved text
Source Link
jmarkov
  • 794
  • 4
  • 11

In this situationConsidering that you super long exposure data before the start of the study, you might be interested in using different exposure averages instead of single years. For instance, you want to assign 5-year or 10-year exposure average. Then you just need to define a 5-year average by row. For example for time 2010 you can assign averages of values from 2006 to 2010. There are some nice papers that looked how risk estimates change when you use averages for different exposure time frame (e.g. here) You can do thatcreate averages across multiple years in R (with data.table) with something like this:

exposuredata<- exposuredata[, 5yrave:=rowMeans(Reduce(cbind, shift(exposureexposure_value, 0:5))), by=ID]

JustI do not recommend using age as main time scale as you wish to do, rather I would control for it in the model using a spline term maybe. (something like ns(age, df=5)). However, in your splitdata dataset age needs to be calculated as difference between the birthdate and new_exitdata at each time point. There are other ways to control for it, such as stratifying by year of birth, but just ask if you need!

Also, remember that the selection of the covariate must relatively careful. Because I imagine your exposure is from outdoor predictions, then using area-level covariates (such as neighborhood deprivation) is recommded to account for confounding.

I think this is enough for now and I tried not too specific, but if you need details or clarifications on sometihng, ask and I can edit the answer. Also, there might be a few mistakes in the text, please just gently point them out. Cheers

In this situation you might be interested in using different exposure averages instead of single years. For instance, you want to assign 5-year exposure average. Then you just need to define a 5-year average by row. For example for time 2010 you can assign averages of values from 2006 to 2010. There are some nice papers that looked how risk estimates change when you use averages for different exposure time frame (e.g. here) You can do that in R (with data.table) with something like this:

exposuredata<- exposuredata[, 5yrave:=rowMeans(Reduce(cbind, shift(exposure, 0:5))), by=ID]

Just remember that the selection of the covariate must relatively careful. Because I imagine your exposure is from outdoor predictions, then using area-level covariates (such as neighborhood deprivation) is recommded to account for confounding.

I think this is enough for now and I tried not too specific, but if you need details on sometihng, I can edit the answer. Cheers

Considering that you super long exposure data before the start of the study, you might be interested in using different exposure averages instead of single years. For instance, you want to assign 5-year or 10-year exposure average. Then you just need to define a 5-year average by row. For example for time 2010 you can assign averages of values from 2006 to 2010. There are some nice papers that looked how risk estimates change when you use averages for different exposure time frame (e.g. here) You can create averages across multiple years in R (with data.table) with something like this:

exposuredata<- exposuredata[, 5yrave:=rowMeans(Reduce(cbind, shift(exposure_value, 0:5))), by=ID]

I do not recommend using age as main time scale as you wish to do, rather I would control for it in the model using a spline term maybe. (something like ns(age, df=5)). However, in your splitdata dataset age needs to be calculated as difference between the birthdate and new_exitdata at each time point. There are other ways to control for it, such as stratifying by year of birth, but just ask if you need!

Also, remember that the selection of the covariate must relatively careful. Because I imagine your exposure is from outdoor predictions, then using area-level covariates (such as neighborhood deprivation) is recommded to account for confounding.

I think this is enough for now and I tried not too specific, but if you need details or clarifications on sometihng, ask and I can edit the answer. Also, there might be a few mistakes in the text, please just gently point them out. Cheers

correct syntax
Source Link
jmarkov
  • 794
  • 4
  • 11
  1. Your "basic" cohort and outcome tables will need to look like Table 1a and 1b (you don't need Table 1c as you already have your exposure table). In Table 1a you have the basic cohort information, while in Table 1b you have the outcome. In Table 1a the "Last follow-up date" refers to the date your observation leaves the follow-up, that is due to censoring (observation , death or administrative end of the follow-up, which in your case is 31/12/2021).

    Also, I assume your exposure data (exposuredata dataset) looks more or less like this:

Table 2: |ID|Enrolment date|Last follow-up date|ICD| outcome date| |---|---|---|---|---| |1|...|...|I25.1|...|

IDEnrolment dateLast follow-up dateICDoutcome date
1......I25.1...
     exposuredata<- exposuredata[, 5yrave:=rowMeans(Reduce(cbind, shift(exposure, 0:5))), by=ID] 

exposuredata<- exposuredata[, 5yrave:=rowMeans(Reduce(cbind, shift(exposure, 0:5))), by=ID]

`model<-coxph(Surv(enterdate,new_exitdate, event) ~ exposure + covariates, data)model<-coxph(Surv(enterdate,new_exitdate, event) ~ exposure + covariates, data)

  1. Your "basic" cohort and outcome tables will need to look like Table 1a and 1b (you don't need Table 1c as you already have your exposure table). In Table 1a you have the basic cohort information, while in Table 1b you have the outcome. In Table 1a the "Last follow-up date" refers to the date your observation leaves the follow-up, that is due to censoring (observation , death or administrative end of the follow-up, which in your case is 31/12/2021).

    Also, I assume your exposure data looks more or less like this:

Table 2: |ID|Enrolment date|Last follow-up date|ICD| outcome date| |---|---|---|---|---| |1|...|...|I25.1|...|

     exposuredata<- exposuredata[, 5yrave:=rowMeans(Reduce(cbind, shift(exposure, 0:5))), by=ID] 

`model<-coxph(Surv(enterdate,new_exitdate, event) ~ exposure + covariates, data)

  1. Your "basic" cohort and outcome tables will need to look like Table 1a and 1b (you don't need Table 1c as you already have your exposure table). In Table 1a you have the basic cohort information, while in Table 1b you have the outcome. In Table 1a the "Last follow-up date" refers to the date your observation leaves the follow-up, that is due to censoring (observation , death or administrative end of the follow-up, which in your case is 31/12/2021).

    Also, I assume your exposure data (exposuredata dataset) looks more or less like this:

Table 2:

IDEnrolment dateLast follow-up dateICDoutcome date
1......I25.1...

exposuredata<- exposuredata[, 5yrave:=rowMeans(Reduce(cbind, shift(exposure, 0:5))), by=ID]

model<-coxph(Surv(enterdate,new_exitdate, event) ~ exposure + covariates, data)

Source Link
jmarkov
  • 794
  • 4
  • 11

The PhD I am currently working on focuses specifically on this topic so I think I can give you some good tips.

Important point:

If your outcome is incidence of cardiovascular diseases, then you do not need to define competing risks for death! It will be just a time-dependent Cox Proportional Hazard model (Cox PH). This is what you will also find in most of the literature.

Next...

If your air pollution data is yearly averages corresponding to each year between 1989 and 2021, then defining a time-varying Cox PH model will be quite simple. Very recently me and colleagues published a paper (open access) that I will use as reference to avoid creating multiple tables in the answer.

  1. Your "basic" cohort and outcome tables will need to look like Table 1a and 1b (you don't need Table 1c as you already have your exposure table). In Table 1a you have the basic cohort information, while in Table 1b you have the outcome. In Table 1a the "Last follow-up date" refers to the date your observation leaves the follow-up, that is due to censoring (observation , death or administrative end of the follow-up, which in your case is 31/12/2021).

    Also, I assume your exposure data looks more or less like this:

ID year exposure_value
1 1989 ...
1 1990 ...
  1. Now you need to merge Table 1a and 1b so that you still only have one row per subject. In some way, you need to select which outcome you are exactly interested in, in terms of ICD. This merge with give you a table like this (replace the ... with your dates):

Table 2: |ID|Enrolment date|Last follow-up date|ICD| outcome date| |---|---|---|---|---| |1|...|...|I25.1|...|

From Table 2 you need to define a new date column (new_exitdate) which will have values equal to either "Last to follow-up date" or "outcome date", whichever comes first. Also, you need to define an indicator for event (event): 1 if the observation has the event (cardiovascular disease) during the follow-up or 0 if he/she doesn't. Eventually, you will only need to have the following columns: ID, "enterdate" (which is equal to "Enrolment date"),"new_exitdate" and "event".

  1. Now you have Table 2 ready to be split so we can link the exposure to it! When I worked on this stuff the first time, I got my ispiration from this working example (particularly model B). To do the time splitting in R you can use a simple code:

     library(lubridate);library(survival)
     low<- year(min(table2$enterdate)); up<- year(max(table2$new_exitdata))
     cutyr <- low:up
     splitdata <- survSplit(Surv(enterdate, new_exitdate, event) ~., table2, cut=cutyr)
    

Now you have your splitted data which includes multiple rows per observation, each of which corresponds to an ID-year pair.

  1. You can simply merge splitdata with your exposure data :) by ID and year! ATTENTION: be careful in this moment because you can merge your exposure using the same year (e.g. assign 2010 exposure to 2010 time) but you can also do a different assignment, for instance you can assign the exposure of the previous year (e.g. assign 2009 exposure to 2010 time). You need to run some sensivity analyses to see how the effect changes when you change assignment. Remember: in no way you can assign future exposure to a time. For instance, if the time is 2010 you cannot assign 2011 exposure as it makes not sense!

In this situation you might be interested in using different exposure averages instead of single years. For instance, you want to assign 5-year exposure average. Then you just need to define a 5-year average by row. For example for time 2010 you can assign averages of values from 2006 to 2010. There are some nice papers that looked how risk estimates change when you use averages for different exposure time frame (e.g. here) You can do that in R (with data.table) with something like this:

     exposuredata<- exposuredata[, 5yrave:=rowMeans(Reduce(cbind, shift(exposure, 0:5))), by=ID] 

To understand this part I recommend to study Figure 3 of the paper, which corresponds to the Definition of individual summaries for epidemiological studies (Step 3) section.

  1. You can run your cox model! The code will be something like this:

`model<-coxph(Surv(enterdate,new_exitdate, event) ~ exposure + covariates, data)

Just remember that the selection of the covariate must relatively careful. Because I imagine your exposure is from outdoor predictions, then using area-level covariates (such as neighborhood deprivation) is recommded to account for confounding.

I think this is enough for now and I tried not too specific, but if you need details on sometihng, I can edit the answer. Cheers