Hi All
I'm analyzing the association between y (a clinical variable) and time (time since diagnosis of diabetes), adjusting for gender and at age at diagnosis. We already know from existing literature and the raw data, that y has a non-linear relationship with time since diagnosis. I've fit a multilevel piece-wise linear spline model to account for the non-linearity of the data with knots at 1, 2, 4, 8, 12, 17, 24 & 34 months after diagnosis (total follow-up time 72 months). The data is longitudinal with subjects having multiple measurements of Y, so essentially this is a growth curve analysis (random slope & random coefficient model):
I would now like to visualize the data post regression - plot y with time since diagnosis first for all subjects and then separately for males and females. What is the best way to do this?
I've been told margins and marginsplot (which I generally use) doesn't work too well for linear spline models. Is this true? There is a user written package to help plot data post regression when using restricted cubic splines (the 'postrcspline' package).
Is there a way to plot what I would like to see? Due to the nature of the data, it is stored on a secure online server and I'm unable to download and run any user-written commands which complicates matters.....
Thanks!
/Amal
I'm analyzing the association between y (a clinical variable) and time (time since diagnosis of diabetes), adjusting for gender and at age at diagnosis. We already know from existing literature and the raw data, that y has a non-linear relationship with time since diagnosis. I've fit a multilevel piece-wise linear spline model to account for the non-linearity of the data with knots at 1, 2, 4, 8, 12, 17, 24 & 34 months after diagnosis (total follow-up time 72 months). The data is longitudinal with subjects having multiple measurements of Y, so essentially this is a growth curve analysis (random slope & random coefficient model):
Code:
mkspline durm1 1 durm2 2 durm4 4 durm8 8 durm12 12 durm17 17 durm24 24 durm34 34 durm36 = durationm mixed y durm1 durm2 durm4 durm8 durm12 durm17 durm24 durm34 durm36 sexnew diagagenew || id: durationm, cov(unstr) mle, if diabtype==1 & audityr>2010 & durationall<6.1 Performing EM optimization: Performing gradient-based optimization: Iteration 0: log likelihood = -739203.39 Iteration 1: log likelihood = -739203.15 Iteration 2: log likelihood = -739203.15 Computing standard errors: Mixed-effects ML regression Number of obs = 187,201 Group variable: id Number of groups = 25,677 Obs per group: min = 1 avg = 7.3 max = 36 Wald chi2(11) = 36063.34 Log likelihood = -739203.15 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ y | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- durm1 | -18.9578 .2976129 -63.70 0.000 -19.54111 -18.37449 durm2 | -11.29657 .3486496 -32.40 0.000 -11.97991 -10.61323 durm4 | -4.899221 .1451236 -33.76 0.000 -5.183658 -4.614784 durm8 | 1.85443 .0570494 32.51 0.000 1.742615 1.966245 durm12 | .414913 .0476722 8.70 0.000 .3214771 .5083489 durm17 | .2890149 .0343775 8.41 0.000 .2216362 .3563936 durm24 | .2048707 .0219777 9.32 0.000 .1617952 .2479462 durm34 | .1576019 .0133097 11.84 0.000 .1315154 .1836883 durm36 | .0369482 .0055738 6.63 0.000 .0260238 .0478727 sexnew | 1.399622 .1986482 7.05 0.000 1.010279 1.788965 diagagenew | .4907482 .0241491 20.32 0.000 .4434168 .5380795 _cons | 91.32118 .4392206 207.92 0.000 90.46032 92.18204 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval] -----------------------------+------------------------------------------------ id: Unstructured | var(durati~m) | .1717863 .0028512 .1662881 .1774663 var(_cons) | 262.7687 3.711764 255.5935 270.1452 cov(durati~m,_cons) | -3.667118 .0833349 -3.830452 -3.503785 -----------------------------+------------------------------------------------ var(Residual) | 99.06962 .3773554 98.33277 99.81199 ------------------------------------------------------------------------------ LR test vs. linear model: chi2(3) = 1.3e+05 Prob > chi2 = 0.0000 Note: LR test is conservative and provided only for reference.
I would now like to visualize the data post regression - plot y with time since diagnosis first for all subjects and then separately for males and females. What is the best way to do this?
I've been told margins and marginsplot (which I generally use) doesn't work too well for linear spline models. Is this true? There is a user written package to help plot data post regression when using restricted cubic splines (the 'postrcspline' package).
Is there a way to plot what I would like to see? Due to the nature of the data, it is stored on a secure online server and I'm unable to download and run any user-written commands which complicates matters.....
Thanks!
/Amal
Comment