Open ericmelse opened 2 years ago
Dear Ben,
I did find a work-around using code from here.
After running a reldist pdf
command, I use:
* SET T stat
global sig= 0.95
scalar _df = e(df_r) // df scalar
scalar _t = abs(invt(_df,(1 - ${sig})/2)) // t stat scalar
* SET BETA AND SE MATRICES
local names : colfullnames e(b)
matrix B = (e(b))'
mata st_matrix("SD_matrix",sqrt(diagonal(st_matrix("e(V)"))))
* IDENTITY MATRIX FOR CONFORMABILITY
matrix I = I(`= rowsof(B)')
* MAKE Confidence interval MATRICES
matrix CI_low = B - _t*I*SD_matrix
matrix CI_high = B + _t*I*SD_matrix
* Final Results
matrix ALL = [B' \ CI_low' \ CI_high']
matrix rownames ALL = "y1" "lb" "ub"
matlist ALL
and with this matrix ALL, I can use svmat
to create variables from it for further use.
However, being able to use the result table directly from reldist
has my preference.
Hi Eric,
reldist
behaves like other estimation commands and returns r(table)
(unless the coefficients table is suppressed). So an easy solution is:
sysuse auto , clear
reldist pdf price , by(foreign)
matrix ALL = e(at) \ r(table)
ben
Thank you Ben.
Indeed this does work just fine.
I did look for r(table)
but that is not available after running:
sysuse auto , clear
reldist pdf price , by(foreign) graph
matlist r(table)
because, as you explained, that suppresses the coefficients table, which is reported to the user with:
(coefficients table suppressed)
but when I use:
reldist pdf price , by(foreign) table graph
matlist r(table)
I do get the coefficients table in the results window but the r(table)
is empty while the message:
(coefficients table suppressed)
is not displayed (which might be confusing).
I assume that using the option graph
clears the r(table)
as such.
Maybe you can adjust the code to not clear r(table)
when the option table
is used even in combination with the option graph
.
Yes, Stata's graph
command appears to clear r()
. I guess I could add some code to preserve r()
and then restore it after running graph
, but why not do something like the following?
sysuse auto , clear
quietly reldist pdf price , by(foreign)
matrix ALL = e(at) \ r(table)
reldist graph
Best. ben
Dear Ben,
I agree that both reldist
and your example show that there is no error as such and that the required functionality is available with limited code writing.
I suppose that it is now more a matter of convenience to have r(table)
immediately available also in those cases when the option graph
is included in the command.
I'll see what I can do.
I now fixed this; see latest update. That is, r(table)
will be returned also if option graph
is applied (as long as option table
is also applied). Furthermore, quietly reldist ...
will now also return r(table)
. Ben
Dear Ben,
I currently work on the combination of a
reldist
graph and other plots using theaddplot
functionality. However, that gives (for me) a problematic visualization as any added plot is drawn on top of thereldist
graph whereas I want to order these below it. Thus, my strategy now is to have the result data ofreldist
available in a matrix and then take it from there. That is indeed possible for the y-axis points and the coefficient usinge(at)
ande(b)
but not for the confidence interval result data (unless, maybe, that is manually calculated, something I rather leave toreldist
). This brings me to my question why it is possible to display the full result table like:but not have that table available in a result matrix? E.g. like Stata provides after regress with
r(table)
, it would be very helpful when reldist can provide the same. Maybe using a matrix name like:e(table)
.I look forward to your update, if possible and with time permitting.
Best regards, Eric Melse