Announcement

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

  • How to get the hazard ratio for a categorical variable according to a determined covariate

    Hi everyone,

    I'm doing a Cox regression with a categorical variable "a" (5 categories) and I'm adjusting it for different covariates "b1, b2, b ..." continuous and categorical. In this case, I want to know the Hazard Ratio (HR) for each category (1 - 5) according to the variable "BMI" (dichotomous variable "<25" and "> = 25") and all the adjustment covariates that add to the model .

    With this, I would like to obtain the HR for each category (1 - 5) of my variable "a" if the covariate BMI is "<25", and the HR for each category (1 - 5) of my variable "a" if the covariate BMI is "> = 25" adjusted for all the covariates that you have put in the model. Do you know the syntax?

    I want something like this (but with HR):


    Captura de pantalla 2018-06-23 a las 21.07.28.png


    Thanks a million!!



  • #2
    The easiest way to do this is if you first run your Cox regression using factor variable notation. Then -margins- will easily give what you want.

    Code:
    gen byte oo = (bmi >= 25) if !missing(bmi)
    label define oo 0 "Normal Weight" 1 "Overweight/Obese"
    label values oo oo
    
    stcox i.a##i.oo other_covariates_here
    margins a#oo

    Comment


    • #3
      Thanks so much Clyde! The last question: after applying the command, the results are these:
      Captura de pantalla 2018-06-23 a las 23.49.27.png




      So, if I'm interpreting correctly, the HR's for "bmi_r" for the cat ">=25" are the number in red. Is this correct?
      And then I want to calculate the P for trend and the P-interaction but I get a value for each category (number) and I want a single value, so I used this syntax to give me just one value for each "P":

      P for trend:
      .testparm i.bmi_r#"continuous variable p for trend"

      P-interact:
      .levelsof i."a" if e(sample), local(levels)
      .testparm i.bmi_r#i(`levels').i"a"

      After running the syntax, both values of P are the same. I think I'm doing something wrong.
      A lot of thanks!
      Last edited by delao victor; 23 Jun 2018, 16:29.

      Comment


      • #4
        No. I don't think you did what I suggested. What you show in #3 is the stcox output. You won't find the hazard ratios you are looking for there. The hazard ratios you want will be in the output of the -margins- command.

        To get a single interaction p-value, you would run -testparm i.variable_a#i.bmi_r- (but replace variable_a by the actual name of that variable.

        It does not make sense to ask for a p for trend here because you have two different series of hazard ratios, one for bmi < 25 and the other for bmi >= 25. Trend p-values only make sense for a single ordered series.

        Comment


        • #5
          Okey! Thank you Clyde!

          Comment

          Working...
          X