I would like to save the AIC and BIC values in tabular form for fitted Accelerated Failure Time (AFT) models. Currently, I need to run each model separately, and run the "estat ic" command repetatively. Can we automate the comparison process using a loop.
I know how to fit an AFT model and interpret it, but I would like to automate the fitting using a for loop where it would iterate through the distribution names [exponential, loglogistic etc], fit the model like above and estimate the AIC and BIC then save it in tabular form. Once the computation done for all model, then it prints the table with “model name”, "AIC" and "BIC" columns and corresponding values.
I'm new to stata and still learning the coding part. Any help regarding this will be appreciated.
HTML Code:
// Example of Exponential AFT model streg age ib(1).sex ib(0).ph_ecog ph_karno pat_karno meal_cal wt_loss, distribution(exponential) time allbaselevels cformat(%9.3f) pformat(%5.3f) sformat(%8.3f) estat ic // Example of Loglogistic AFT model streg age ib(1).sex ib(0).ph_ecog ph_karno pat_karno meal_cal wt_loss, distribution(loglogistic) time allbaselevels cformat(%9.3f) pformat(%5.3f) sformat(%8.3f) estat ic
I'm new to stata and still learning the coding part. Any help regarding this will be appreciated.
Comment