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.
gen C_X = X - r(mean)
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.
mat knots1 = r(knots)
estimates store 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.
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.
- First, I center the variable X to get C_X.
gen C_X = X - r(mean)
- Fit a linear model with this centered variable and covariates and store its estimates.
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.
- Transforming C_X to spline function with 3 knots at positions as set 1.
mat knots1 = r(knots)
- Fitting the logistic regression model with this spline function and storing the estimates of this model.
estimates store M1
- Testing for linearity through likelihood ratio test.
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.
Comment