Statalist


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

Re: st: -est combine-?


From   "Ben Jann" <[email protected]>
To   [email protected]
Subject   Re: st: -est combine-?
Date   Tue, 31 Jul 2007 18:26:23 +0200

Michael, I think the approach using -erepost- works best in your case.
Here is an example.

Step 1: estimate the nl model and make a hardcopy of the AIC/BIC
measures (adding the nlcom results later on screws up computation of
the information measures)

/*----------------------------------------------*/
. sysuse auto
(1978 Automobile Data)

. qui nl (price = {alpha} + {beta}*mpg)

. qui estat ic

. estadd scalar AIC = el(r(S),1,5)

. estadd scalar BIC = el(r(S),1,6)

. eststo NLreg
/*----------------------------------------------*/

Step 2: Get a hold of the coefficients and variances. (Note that the
covariances are dropped here to keep things easier. The covariances
are not needed for tabulation.)

/*----------------------------------------------*/
. mat b = e(b)

. mat V = vecdiag(e(V))
/*----------------------------------------------*/

Step 3: run nlcom and add the results to b and V; then post everything in e()

/*----------------------------------------------*/
. qui nlcom (d1: _b[/alpha]-10000) (d2: _b[/beta]+250)

. mat tmp = r(b)

. mat coleq tmp = nlcom

. mat b = b, tmp

. mat tmp = vecdiag(r(V))

. mat coleq tmp = nlcom

. mat V = V, tmp

. mat V = diag(V)

. erepost b=b V=V

. eststo NLregNLcom
/*----------------------------------------------*/

Step 4: apply esttab

/*----------------------------------------------*/
. esttab NLreg NLregNLcom, p nostar ar2 scalars(AIC BIC) nodepvar
eqlabels(,none)

--------------------------------------
                      (1)          (2)
                    NLreg   NLregNLcom
--------------------------------------
alpha             11253.1      11253.1
                  (0.000)      (0.000)

beta               -238.9       -238.9
                  (0.000)      (0.000)

d1                              1253.1
                               (0.288)

d2                               11.11
                               (0.835)
--------------------------------------
N                      74           74
adj. R-sq           0.209        0.209
AIC                1377.1       1377.1
BIC                1381.7       1381.7
--------------------------------------
p-values in parentheses
/*----------------------------------------------*/

Adding a line between the nlreg and nlcom results is a bit tricky. The
following command would do:
/*----------------------------------------------*/
. esttab NLreg NLregNLcom, p nostar ar2 scalars(AIC BIC) nodepvar
eqlabels(,none) ///
>  varl(,blist(d1 "{hline @width}") begin("" "") nofirst)

--------------------------------------
                      (1)          (2)
                    NLreg   NLregNLcom
--------------------------------------
alpha             11253.1      11253.1
                  (0.000)      (0.000)

beta               -238.9       -238.9
                  (0.000)      (0.000)
--------------------------------------
d1                              1253.1
                               (0.288)

d2                               11.11
                               (0.835)
--------------------------------------
N                      74           74
adj. R-sq           0.209        0.209
AIC                1377.1       1377.1
BIC                1381.7       1381.7
--------------------------------------
p-values in parentheses
/*----------------------------------------------*/

ben

On 7/30/07, Michael Hanson <[email protected]> wrote:
>         Here is a set of examples that may clarify my question.  Given the
> notation below, I'd ultimately like one table with /a0, /b0, /b1, /
> b2, /d1, and /d2 (see the end of the example) listed in a single
> column, along with the p-values (or HAC SEs) for each of these six
> estimated parameters.  My apologies in advance for the length of this
> message.
[...]
>         What I ultimately would like is something akin to the following
> table, which I have constructed by hand via copy-and-paste;  I'd like
> to be able to automate construction of such a table in a .do file
> (ultimately to produce tables in SMCL and LaTeX formats):
>
> -----------------------------
>                            (1)
>                          NLreg
> -----------------------------
> a0                      0.903
>                        (0.000)
>
> b0                     -0.159
>                        (0.910)
>
> b1                      1.930
>                        (0.000)
>
> b2                      0.977
>                        (0.097)
> -----------------------------
> d1                      0.216
>                        (0.988)
>
> d2                      3.918
>                        (0.784)
> -----------------------------
> N                         155
> adj. R-sq               0.973
> AIC                     111.9
> BIC                     124.1
> -----------------------------
> p-values in parentheses
>
*
*   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