Use the -matrix- command to copy the contents of the r(table) to a custom matrix. Since we actually need to save 3 separate r(table) matrices to fill out the blank table (one for each row), you should do this anyway to help facilitate completing the table. Make sure to save the r(table) matrix as custom matrix before going any further. įor various reasons that you can read about here, r(table) is not a usual matrix and Stata will do funny things if you try to run matrix commands on it. You’ll note above (after the -matrix list r(table)- command) that Stata tells you that the r(table) matrix has 9 rows and 2 columns, or. These exist separate from the dataset, which is also basically a big spreadsheet. Matrices are basically small spreadsheets saved in the memory that can be accessed by referencing a cell reference. Copy it to a custom ‘typical’ matrix before doing anything else! Actually view the r(table) matrix in order to verify that all of the data points of interest are hiding there.Take a look at the -return list- to see that the r(table) is hiding there (without actually viewing the contents of r(table)).Let’s take a look at the regression output below and how they exist in the r() level r(table), I have bolded/underlined the output of interest. We actually don’t need this to fill out the above table. ereturn list – this will let you see the ‘brains’ behind the regression, namely the e() level bits, which are useful in post-estimation commands.Type -matrix list r(table)- to see the structured output of this matrix.These are what you will use to fill out the above blank table. Importantly, the r() level contains the r(table) matrix, which holds all of the raw numbers used to generate the output of your regression as you see it in Stata’s output. return list – This will give the ‘guts’ of the regression, namely the r() level bits, as you see it in the Stata output.You can view the r() ‘guts’ with -return list- and e() ‘brains’ with -ereturn list. When you run a regression, Stata saves relevant bits of these regressions in scalars and matrices saved in different r() and e() levels. Let’s get familiar with the ‘guts’ and ‘brains’ behind Stata’s regression functions. You can either copy the output manually, or automate it! Let’s learn how to automate this process. In Stata you’ll run three regressions to fill out the three rows: sysuse auto, clear We want to regress MPG (Y) on weight (x) overall and by strata of domestic vs. Let’s use the classic 1978 auto dataset that comes with Stata. Here’s one step-by-step approach that you might find helpful. Extracting the results from regressions in Stata can be a bit cumbersome. I'm not an advanced user of Stata and I have been unsuccessful to find a way to get the desired dataset.If you make your own Stata programs and loops, you have discovered the wonders of automating output of analyses to tables. I have multiple regression to run in double loop (with ID and year) and then save specific coefficient in new dataset for further analysis.
0 Comments
Leave a Reply. |