Announcement

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

  • How to collate multiple, individual regression outputs

    Looking for some help on the following:

    I want to tabulate the univariate association of 8 variables (v1-v8) with an outcome (outcome).
    For each variable I would write, for instance:
    Code:
    logistic outcome v1, coef
    I want the outputs that are created to be added as new rows to create a table where the first column has all the variables and their subcategories (some are i.variables), and the columns show the regression outputs as they would when I write the above code for each variable individually.

    Many thanks in advance

  • #2
    There's probably a more ready-made and nicer way to do this, but here's a quick and dirty approach to what I *think* you want:
    Code:
    // Example data
    clear
    set seed 4746
    sysuse auto
    replace rep78 = ceil(runiform() * 5) // better data for example
    //
    logistic foreign weight, coef
    mat list r(table) // to show you what is available; see also -ereturn list-
    //
    cap mat drop Results
    foreach v in weight i.rep78 price length {
        quiet logistic foreign `v', coef
        mat A = r(table)'
        mat Results = nullmat(Results)\A
    }
    mat Results = Results[1..`=rowsof(Results)', 1..6] // drop last columns
    mat list Results
    which gives:
    Code:
    . mat list Results
    
    Results[12,6]
                               b          se           z      pvalue          ll          ul
      foreign:weight  -.00258739   .00060937  -4.2460168   .00002176  -.00378173  -.00139305
       foreign:_cons   6.2825993   1.6039668   3.9169136   .00008969   3.1388822   9.4263164
    foreign:1b.rep78           0           .           .           .           .           .
     foreign:2.rep78   4.541e-16    .8660254   5.244e-16           1  -1.6973786   1.6973786
     foreign:3.rep78  -.91629058   .98742085  -.92796357   .35342647  -2.8515999   1.0190187
     foreign:4.rep78   4.258e-16   .82158384   5.183e-16           1  -1.6102747   1.6102747
     foreign:5.rep78  -.13353139   .76181175  -.17528135   .86085856   -1.626655   1.3595922
       foreign:_cons  -.69314718   .61237244  -1.1319046   .25767454  -1.8933751   .50708074
       foreign:price   .00003528   .00008436   .41820364   .67579823  -.00013007   .00020063
       foreign:_cons  -1.0797924   .58783442   -1.836899   .06622481  -2.2319267   .07234185
      foreign:length  -.07973532   .01948539  -4.0920564   .00004276  -.11792599  -.04154466
       foreign:_cons   13.606339   3.4572728     3.93557     .000083   6.8302089   20.382469

    Comment


    • #3
      You'll need to give an example we can work with. This is super nebulous so far

      Comment


      • #4
        Mike Lacy that's exactly what I needed thanks very much

        Comment

        Working...
        X