Dear statalist,
I'm running a MV logistic regression and using marginsplot to understand the relationship between aki2 (DV) and log_avl (IV) in an observational cohort. As a side note, log_avl was log transformed after assessing its distribution with ladder plots, and it is now normally distributed and has a understandable and statistically significant relationship with aki2.
To better understand the specific nature of the relationship between aki2 and log_avl in the context of other coviarates, I'm also generating scatterplots after using the predict command. There seems to be a discrepancy in the shape of the marginsplot and scatter plot. Please see the code and graphs below:
logistic aki2 c.log_avl##i.it_type i.agecat male race i.bmicat i.cci_cat Auto_CKD_Preop i.renal i.clavien_cat
margins, at(log_avl=(-2(1)6))
predict fitted2
quietly margins, at(log_avl=(-2(0.5)6)) saving(file2, replace)
marginsplot
graph addplot scatter fitted2 log_avl, msym(oh) msize(vsmall) mcolor(cranberry*0.8) xlabel(-2(1)6)
graph addplot qfitci fitted2 log_avl
Array
The marginsplot is in blue. The scatterplot is in red and is created by using the predict command. The quadratic fit to the scatterplot is in gray. A quadratic fit was chosen after running the fp command to determine the optimal fit between pr(aki2) and log_avl.
When I assess the scatterplot, it seems like the quadratic fit does a much better job fitting the relationship. Is that because margins naturally attempts to fit the shape of a logistic regression, and so the tail ends of the curve flatten out? Which of the two curves is more appropriate than? Is marginsplot really giving me the correct relationship between these two variables in the regression?
Thanks for any help!
Julien
I'm running a MV logistic regression and using marginsplot to understand the relationship between aki2 (DV) and log_avl (IV) in an observational cohort. As a side note, log_avl was log transformed after assessing its distribution with ladder plots, and it is now normally distributed and has a understandable and statistically significant relationship with aki2.
To better understand the specific nature of the relationship between aki2 and log_avl in the context of other coviarates, I'm also generating scatterplots after using the predict command. There seems to be a discrepancy in the shape of the marginsplot and scatter plot. Please see the code and graphs below:
logistic aki2 c.log_avl##i.it_type i.agecat male race i.bmicat i.cci_cat Auto_CKD_Preop i.renal i.clavien_cat
margins, at(log_avl=(-2(1)6))
predict fitted2
quietly margins, at(log_avl=(-2(0.5)6)) saving(file2, replace)
marginsplot
graph addplot scatter fitted2 log_avl, msym(oh) msize(vsmall) mcolor(cranberry*0.8) xlabel(-2(1)6)
graph addplot qfitci fitted2 log_avl
Array
The marginsplot is in blue. The scatterplot is in red and is created by using the predict command. The quadratic fit to the scatterplot is in gray. A quadratic fit was chosen after running the fp command to determine the optimal fit between pr(aki2) and log_avl.
When I assess the scatterplot, it seems like the quadratic fit does a much better job fitting the relationship. Is that because margins naturally attempts to fit the shape of a logistic regression, and so the tail ends of the curve flatten out? Which of the two curves is more appropriate than? Is marginsplot really giving me the correct relationship between these two variables in the regression?
Thanks for any help!
Julien