Mike, if you want to group the custom pvalues with the coefficients in
-estout- you have to add a matrix holding the pvalues (using the same
column names as in e(b)). Here is an example. I hope it is helpful.
ben
. clear
. set obs 100
obs was 0, now 100
. scalar a = 1
. scalar b = 2
. gen x = uniform(
. forv i = 1/2 {
2. gen y`i' = a + b*x + invnorm(uniform())
3. qui reg y`i' x
4. mat res = J(1,2,.)
5. mat coln res = x _cons
6. qui test _b[x] = b
7. mat res[1,1] = r(p)
8. qui test _b[_cons] = a
9. mat res[1,2] = r(p)
10. estadd matrix pval = res
11. est sto reg`i'
12. }
. estout *, cell(b(fmt(2)) se pval(fmt(4))) style(fixed)
reg1 reg2
b/se/pval b/se/pval
x 2.22 1.48
0.34 0.33
0.5162 0.1211
_cons 0.94 1.32
0.20 0.20
0.7553 0.1068
On 1/19/07, Michael S. Hanson <[email protected]> wrote:
I have a particular question regarding the display of a table of
regression results using -estimates table-. I have written a
short .do file that simulates a series of random (x,y) draws from a
simple linear relationship to illustrate the difference between the
population regression relationship and the estimated sample
regression line, as well as the role of sampling variation, for my
econometrics course this semester. The relevant extract is below
(with local variables appropriately defined previously in the program):
// --- BEGIN CODE --- //
forvalues i = 1/`m' {
drawnorm u`i', n(`n') sds(sd)
}
gen x = uniform()*r
sort x
gen ytrue = a + b*x
quietly regress ytrue x
est store true
forval i = 1/`m' {
gen y`i' = ytrue + u`i'
quietly regress y`i' x
quietly predict y`i'hat
est store reg`i'
}
est table *, b(%4.2f) se p stats(r2 rmse)
// --- END CODE --- //
This program will be run "live" during my lecture, so I'm looking for
as clear a table of results as possible. Notice that the p-values
that are reported in the -est table- command are not particularly
interesting for this application; rather, I'd like to list the p-
values that correspond to the following tests, given that the true
population parameters are known in this simulation:
test _b[_cons] = a
test _b[x] = b
test (_b[_cons] = a) (_b[x] = b)
It appears that I can accomplish this objective in part with -
estadd-, such as:
quietly test _b[_cons] = a
estadd scalar p_a = r(p)
...
est table *, b(%4.2f) se stats(p_a r2 rmse)
However, for pedagogical reasons, I'd prefer the p-values to be
grouped with the coefficient estimates and SEs, rather than lumped
with the other summary statistics for the regression as a whole. Is
this possible?
By the way, I have looked at -estout- to create the table, but it
has a few shortcomings for my purposes. Most significantly, it
doesn't output SMCL, so the tables are not (IMO) suitable for
classroom presentation. I also cannot get it to group the above-
computed p-values with the coefficient estimates and SEs. (Note that
I have very limited facility with -estout-, so there may be a way to
do what I want that I am unaware of.) Any suggestions for producing
this table output would be appreciated.
-- Mike
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/