Displaying first stage statistics of ivreg2 using estout in Stata
I am trying to add the first stage statistics from the command ivreg2
, namely AP F stat, to the output for the first stage results using estout
. I know that these statistics are stored in the matrix e(first)
from the second stage, but I am having a hard time figuring out how to represent these statistics in the results of the first stage. I tried the following and didn't work:
ivreg2 y `included' (q=z), first ffirst savefirst savefprefix(first_)
estimates store m1
estadd matrix first=first: first_q
estimates restore first_q
and then tried to include APF
as statistics in estout
and it doesn't work. I also tried adding the lines:
matrix first=e(first)
estadd scalar APF=first[7,1]
and that doesn't work either. I also tried to write a new subcommand _estadd_apf.ado
and couldn't get it to work, and tried using the syntax myel[#]
described in the help file estout
and that won't work either. (It looks like including parentheses anywhere in the parameter stats()
results in an error.) I also tried the aux()
wrapped parameter esttab
and it didn't work.
When I type matrix list first
I can see the correct APF value, but it is stored in a matrix, not a scalar, and estout
will not include it in the table, the cells are just empty. I also tried to just define a local scalar without using it estadd
, and that won't work either. Any suggestions?
source to share
Am I missing something? estadd scalar
seems to work in this case.
clear
set more off
use http://fmwww.bc.edu/ec-p/data/hayashi/griliches76.dta // example from the help file
xi i.year
ivreg2 lw s expr tenure rns smsa _I* (iq=med kww age mrt), small first ffirst savefirst savefprefix(first_)
mat first=e(first)
estadd scalar APF=first[7,1]
estout, c(b) stats(APF)
source to share