Good morning all,
I am running estat phtest following stcox (Stata 15.1, updated)
I want to generate the plot of scaled Schoenfeld residuals for each categorical predictor as part of assumption testing (I have 20 categorical predictors against 500,000 observations). Categorical predictors have differing number of levels (from 2 to 10).
My initial hope had been to run a for loop for with estat phtest, plot(var) for each of the predictors contained in a var local . This is not possible however, because the plots only succeed when running estat phtest manually for each explicity declared level of the predictors (as per code example for deprivation).
Keeping IMD5 as an example, none of the options below work (all generate error of 'not found in model'). I can understand why these options do not work (plot requires varname, rather than a list etc), but tried them anyway!
Is there are a way to request phtest, plot() to iterate through each level of predictor, for each variable, and generate a plot for each?
Or does it boil down to manually listing each level for each variable as the initial code chunk above?
Many thanks,
Michael
I am running estat phtest following stcox (Stata 15.1, updated)
I want to generate the plot of scaled Schoenfeld residuals for each categorical predictor as part of assumption testing (I have 20 categorical predictors against 500,000 observations). Categorical predictors have differing number of levels (from 2 to 10).
My initial hope had been to run a for loop for with estat phtest, plot(var) for each of the predictors contained in a var local . This is not possible however, because the plots only succeed when running estat phtest manually for each explicity declared level of the predictors (as per code example for deprivation).
Code:
estat phtest, plot(1.imd5) graph export Schoenfeld_1imd5.svg, as(svg) replace estat phtest, plot(2.imd5) graph export Schoenfeld_2imd5.svg, as(svg) replace estat phtest, plot(3.imd5) graph export Schoenfeld_3imd5.svg, as(svg) replace estat phtest, plot(4.imd5) graph export Schoenfeld_3imd5, as(svg) replace
Code:
estat phtest, plot(imd5) estat phtest, plot(i.imd5) estat phtest, plot(1.imd5 2.imd5 3.imd5 4.imd5)
Or does it boil down to manually listing each level for each variable as the initial code chunk above?
Many thanks,
Michael
Comment