Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Creating output table after -mfx-


From   "Ben Jann" <[email protected]>
To   [email protected]
Subject   Re: st: Creating output table after -mfx-
Date   Thu, 14 Jun 2007 19:28:59 +0200

Manos, I have two solutions for you. None of them is simple, but they
work. The first is to use separate -estout- calls to produce the three
parts of the table and append them in a file:

**********begin example**********
. clear

. set obs 200
obs was 0, now 200

. set seed 125

. gen pid=_n

. expand 3
(400 observations created)

. bys pid: gen y=uniform() >0.5

. bys pid: gen x1=invnormal(uniform())

. bys pid: gen x2=uniform()

. bys pid: gen z=invnormal(uniform())

. gen k=1 if z>-10 & z<-0.5
(416 missing values generated)

. replace k=2 if z>=-0.5 & z<0.8
(293 real changes made)

. replace k=3 if z>=0.8 & z<10
(123 real changes made)

. qui tab k, gen(t)

. qui xtprobit y x1 x2 t2 t3 , i(pid)

. qui mfx, predict(pu0) varlist(x1 x2)

. eststo x1x2

. qui mfx, predict(pu0) varlist(t2) at(t3=0)

. eststo t2

. qui mfx, predict(pu0) varlist(t3) at(t2=0)

. eststo t3

. estout x1x2 using temp.txt, style(fixed) /*
 */ margin keep(x1 x2) cells(b se(par))  /*
 */ replace notype posthead("") /*
 */ eqlab(,none) mlab(,none) collab(dy/dx, lhs(Var))
. estout t2 using temp.txt, style(fixed) /*
 */ margin keep(t2) append /*
 */ nodiscrete cells(b se(par)) notype /*
 */ eqlab(,none) mlab(,none) collab(,none)
. estout t3 using temp.txt, style(fixed) /*
 */ margin keep(t3) append /*
 */ nodiscrete cells(b se(par)) notype /*
 */ eqlab(,none) mlab(,none) collab(,none) /*
 */ postfoot("" "*Std errors in parenthesis")
. type temp.txt
Var                 dy/dx

x1              -.0220458
              (.0202115)
x2               .0246864
              (.0698746)
t2              -.0412405
              (.0472547)
t3               .0108793
              (.0589848)

*Std errors in parenthesis
**********end example**********

The second approach is to gather the results from the different -mfx-
calls and add them at the end using -estadd-:

**********begin example**********
. eststo clear

. qui xtprobit y x1 x2 t2 t3 , i(pid)

. eststo model1

. matrix mfx = e(b)*.

. matrix mfx_se = mfx

. qui mfx, predict(pu0) varlist(x1 x2)

. matrix mfx[1,1] = el(e(Xmfx_dydx),1,1)

. matrix mfx[1,2] = el(e(Xmfx_dydx),1,2)

. matrix mfx_se[1,1] = el(e(Xmfx_se_dydx),1,1)

. matrix mfx_se[1,2] = el(e(Xmfx_se_dydx),1,2)

. qui mfx, predict(pu0) varlist(t2) at(t3=0)

. matrix mfx[1,3] = el(e(Xmfx_dydx),1,3)

. matrix mfx_se[1,3] = el(e(Xmfx_se_dydx),1,3)

. qui mfx, predict(pu0) varlist(t3) at(t2=0)

. matrix mfx[1,4] = el(e(Xmfx_dydx),1,4)

. matrix mfx_se[1,4] = el(e(Xmfx_se_dydx),1,4)

. estadd local Xmfx_type "dydx"

. estadd matrix Xmfx_dydx = mfx : model1

. estadd matrix Xmfx_se_dydx = mfx_se : model1

. estout model1, style(fixed) /*
 */ margin keep(x1 x2 t2 t3) cells(b se(par))  /*
 */ posthead("") eqlab(,none) /*
 */ mlab(,none) collab(dy/dx, lhs(Var)) /*
 */ postfoot("" "*Std errors in parenthesis")
Var                 dy/dx

x1              -.0220458
              (.0202115)
x2               .0246864
              (.0698746)
t2              -.0412405
              (.0472547)
t3               .0108793
              (.0589848)

*Std errors in parenthesis
**********end example**********

If you need something general I advise you to follow approach 2 and
wrap it up as a program, say -mymfx-, so you can type:

xtprobit ...
mymfx ...
estout ...

It will need some work though.

ben

On 6/14/07, Mentzakis, Emmanouil <[email protected]> wrote:
Dear Statalist,

I am trying to create a table output after -mfx- but I cannot make
-outreg- and -outreg2- to work, while -estout-, although is working, I
cannot append the results in a useful format.

Below is a code of what I am running and below that is the output that I
would like to get.

The reason behind running -mfx- separately for each variable is because
of t2 & t3. When computing -mfx-, while one of them is 1 the other needs
to be zero and vice versa.

I'd be grateful for any suggestions

Thank you
Manos


**************** begin example ***********************

********** model **********
clear
set obs 200
set seed 125
gen pid=_n
expand 3
bys pid: gen y=uniform() >0.5
bys pid: gen x1=invnormal(uniform())
bys pid: gen x2=uniform()
bys pid: gen z=invnormal(uniform())
gen k=1 if z>-10 & z<-0.5
replace k=2 if z>=-0.5 & z<0.8
replace k=3 if z>=0.8 & z<10
tab k, gen(t)

xtprobit y x1 x2 t2 t3 , i(pid)
mfx, predict(pu0) varlist(x1 x2)
mfx, predict(pu0) varlist(t2) at(t3=0)
mfx, predict(pu0) varlist(t3) at(t2=0)


********* desired output ***********
Var     dy/dx

X1   -.0220458
      (.02021)
X2    .0246864
      (.06987)
T2   -.0412405
      (.04725)
T3    .0108793
      (.05898)

*Std errors in parenthesis

**************** end example ***********************

*
*   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/

*
*   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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index