Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Estimation output from different regression commands for simulations

    Hello Statalisters,

    Me and my colleagues are running several regression models on patient data in order to estimate health outcomes and resource consumption. Regression commands include (but not necessarily limited to): regress, logit, nbreg and glm, family(gamma). Each model has up to 20 covariates, and the patients are sometimes divided into named subgroups. Regressions are either done for all patients or for each subgroup separately. Now to the problem: I want to be able to export the output from the regressions to some standard format (preferably .csv or similar) which contains all relevant data in order to predict the outcomes. Relevant data includes: Regression coefficients, regression model (actually the formula for prediction) and subgroup for which this regression is done over. Also of interest is the number of data points in each regression and the mean of the dependent variable in each regression, and maybe the data type of each covariate and dependent variable, but these are not as neccessary. Basically, the export file should contain all data to assemble a prediction model in e.g. excel without any extra data added.

    My idea has so far been to use eststo to store the result from each regression, estadd to somehow manually add the metadata needed to named e(
    ) macros or scalars and estout to actually write the export file, all from SSC. Maybe I will write wrapper functions for these ones with predefined options for the commands.

    Many thanks for suggestions on how to do this!

  • #2
    The easiest way is to stick with Stata. You can use estimates save to store your models in a file, which includes everthing you need to do the predictions. Afterwards you can load your model using estimates use and use predict to do the predictions. This way the saving and predicting is to a very high degree automated, which means less work, but more importantly fewer chances of introducing a bug. The disadvantage is that the person doing the predictions needs to have access to Stata.
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      Maarten: Unfortunately your suggestion will not be an option. But that would definitely be the easiest way to do it, and as you say, minimal bug-risk and very automated which is preferable.

      Comment


      • #4
        In a general sense, if I were in your position and a fully Stata-based solution such as Maarten suggests were not an option, I would use Stata's -postfile- apparatus to do this. I would create a loop (or perhaps several nested or sequential loops if necessary) with one regression in each iteration and -post- the relevant statistics and metadata into the -postfile- each time. When all the regressions are done, close the -postfile-, load it into Stata and then export it as .csv or .txt or .xls(x), or whatever as needed.

        Comment

        Working...
        X