Announcement

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

  • How to plot a restricted cubic spline among 2 groups using a logistic regression model fitted on a case control data

    Dear Statalist members,

    This question is based on a case-control data with a binary outcome variable and continuous and categorical predictors. (logistic regression based analysis). My broad aim is characterization of interaction between the continuous variable (X) and a binary variable (Z). One method I am using to visualize this is by plotting the continuous variable using restricted cubic spline against odds ratios for the binary outcome. I need to see how different the graphs are among 2 groups of Z. But I am stuck right now. The steps I have been following are as follows: (using Stata 13)
    Let Y be the binary outcome, X the continuous variable, Z the variable representing 2 groups and C1,C2 etc the confounders.
    1. First, I center the variable X to get C_X.
    sum X
    gen C_X = X - r(mean)
    1. Fit a linear model with this centered variable and covariates and store its estimates.
    logistic Y C_X C1 C2
    estimates store L

    3.Finding knot positions of the 3 knots

    centile(C_X) , centile(25 50 75) //set-1

    Values of the centered X variable corresponding to these knot positions where -25, -7.5 and 12.
    1. Transforming C_X to spline function with 3 knots at positions as set 1.
    mkspline2 XS1 = C_X, cubic knots(-25 -7.5 12)
    mat knots1 = r(knots)
    1. Fitting the logistic regression model with this spline function and storing the estimates of this model.
    logistic Y XS1* C1 C2
    estimates store M1
    1. Testing for linearity through likelihood ratio test.
    lrtest L M1

    Next I need to estimate the pointwise odds ratios from this model to plot the graph between odds ratios and X. And I need to see how the shape of curves would vary (along with their Confidence interval) among the 2 groups of Z. And if there is a difference, is the difference significant. How can I do this? I looked into the xbrsplinecommand but I am not able to understand it properly. Also, if I plot the graph from the above model, i would be plotting C_X instead of X itself. Is this a correct method?
    I also found on the internet, plotting interaction between a continuous and binary variables through logistic regression using margins command. However, we cannot plot the predicted probabilities /risk in this situation as this is a case –control data.

    Any help is appreciated. Please let me know if you would need any additional information.
    Last edited by Thekke Purakkal; 06 Jan 2016, 02:46.

  • #2
    Ok So I guess I can use commands such as plot_rcspline, xrbspline etc to get the restricted cubic spline graphs. But I still have two questions.


    1) How would the interpretation of the final graph change, now that the X axis is not X but centered X?
    2) Also in a single graph, how can I get the spline curves for 2 groups of the sample?

    I was using the plot_rcspline command.


    Thank you for any help/direction anyone can provide or any better options you can suggest

    Comment


    • #3
      Hello all,
      I still have not got any hep but i have made some progress on this. so I am closing this thread here and starting a new one under the title " Plotting restricted cubic spline graph stratified by another binary variable"

      thanks

      Comment

      Working...
      X