Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Time varying exposure in cox regression

    Dear STATALIST,

    I am making a study, where the objective is to evaluate if a Covid-19 infection before or during pregnancy increases the risk of developing intrahepatic cholestasis of pregnancy.

    The outcome is having an IDC-10 code for intrahepatic cholestasis of pregnancy (binary).

    The exposure is a categorical variable for having a positive Covid-19 test before and/ or during pregnancy (based on the first registered positive test either before and/ or during pregnancy):
    0=non-exposed before and during pregnancy
    1=exposed before pregnancy (within window of 6 months prior to the date of conception)
    2=exposed during pregnancy
    3=exposed before and during pregnancy

    I analyze the risk of developing cholestasis of pregnancy after a C19 infection using a multiple Cox regression model with gestational age in days as underlying time-scale and with week of conception as strata.

    C19 exposure is a time-dependent variable with follow-up until date of cholestasis or date of delivery, whichever comes first.
    The pregnancy provide risk time as unexposed until the date of a positive test from which point the pregnancy is exposed until end of follow-up (date of cholestasis or date of delivery, whichever comes first) unless the women is exposed before pregnancy and she thus enters the analysis as exposed.

    C19 infection can occur either before pregnancy or during pregnancy. Entry date into the analysis is day 154 of gestation (equivalent to completed gestational week 22+0) or start of the study (March 1, 2020) if longer than 22+0 at this date, from which time the pregnant woman is at risk of developing cholestasis.
    The analysis is performed with delayed entry to reduce the risk of immortal-time bias, which can occur when participants cannot experience the outcome during part of the follow-up time.

    I am struggling with how to setup my analysis in Stata when I want to include info on exposure before pregnancy and to account for women exposed both before and during pregnancy, and when a woman is not under risk of the outcome until GA 22+0.
    If a woman is exposed before pregnancy then she is coded 1, and if she is then infected again during pregnancy then she need to change exposure status from 1 to 3 at the time of the first registered positive test during pregnancy.

    How can I account for this in my coding using stset and stsplit?

    For now I have only been able to run the analysis including women exposed only during pregnancy (excluding women exposed prior to pregnancy).
    For this analysis I have setup the analysis in this way:

    /* Generating a variable indicating the date of entry into the cox model.
    The date the pregnancy has reached 22 completed weeks of gestation (154 days) or March 1st 2020 if >=GA 22+0 at this date*/

    gen enter=154
    replace enter=mdy(3,1,2020)-date_last_menstrual_period if (mdy(3,1,2020)-date_lmp>=(22*7))
    format enter %td


    /* Generating a variable for the gestational age at the date of a cholestasis diagnosis */

    gen gest_age_cholestasis=date_cholestasis-date_last_menstrual_period


    /* Generating a variable indicating the end of follow-up in the cox model which is date of a cholestasis diagnosis or date of delivery if no cholestasis */

    gen exit=gest_age_cholestasis
    replace exit=gest_age_at_delivery if gest_age_cholestasis==.


    ************************************************** ************************************************** ***
    ***ST-SETTER****

    ***************

    stset exit, entry(enter) fail(cholestasis) id(mat_id)


    ***************
    **ST-SPLIT**
    ***************

    stsplit t1, at(0) after(time=gest_age_first_positive_C19_test_during _preg)


    **Redefines the exposure variable so it is 0 for the first record if the woman has more than one record after stsplit. Has the value 0
    in the record where the woman is unexposed and 1 in the record where she is exposed (after stsplit).

    replace pos_C19_preg=0 if pos_C19_preg==1 & t1==0


    /************************************************** *************************************************
    ***************************************** STATISTICAL ANALYSIS**************************************
    ************************************************** **************************************************/

    /******** Primary analysis ********/


    /// The risk of Cholestasis after a SARS-CoV-2 infection before and/or during pregnancy
    /// Multiple Cox regression with gestational age in days as underlying time-scale and with week of conception as strata


    stcox pos_C19_preg, strata(date_concep_yw)


    So back to my question:

    I am struggling with how to setup my analysis in Stata when I want to include info on exposure before pregnancy and to account for women exposed both before and during pregnancy, and when a woman is not under risk of the outcome until GA 22+0.
    If a woman is exposed before pregnancy then she is coded 1, and if she is then infected again during pregnancy then she need to change exposure status from 1 to 3 at the time of the first registered positive test during pregnancy.

    How can I account for this in my coding using stset and stsplit?

    I hope you can help me. Thanks in advance.

    Best,
    Trine.
Working...
X