Search code examples
exportstatadta

Export Fit Statistics and variance/covariance matrix to dta dataset


I'd like to export fit statistics (log likelihood, AIC, BIC) to a table in dta format. I can display fit statistics after fitting the model (created using strsmix) easily enough using estimates stats, or estat ic, but I can't seem to find a way to write that to a proper .dta file.

I have the same problem with exporting the variance covariance matrix. I can display it using estat vce, but I can't see to find a way to export it.


Solution

  • Figure out a solution that works OK, but doesn't seem to preserve labels.

    estat ic
    matrix fit = r(S)
    estat vce
    matrix vce = r(V)
    clear
    svmat double fit, name(fit)
    save fit.dta, replace
    clear
    svmat double vce, name(vce)
    save vce.dta, replace
    clear