The factor command does not return e(b) and e(V), which makes
tabulation less obvious. For example, the factor loadings are returned in matrix e(L)
and the unique variances are returned in e(Psi):
. webuse bg2, clear (Physician-cost data) . factor bg2cost1-bg2cost6 (obs=568) Factor analysis/correlation Number of obs = 568 Method: principal factors Retained factors = 3 Rotation: (unrotated) Number of params = 15 -------------------------------------------------------------------------- Factor | Eigenvalue Difference Proportion Cumulative -------------+------------------------------------------------------------ Factor1 | 0.85389 0.31282 1.0310 1.0310 Factor2 | 0.54107 0.51786 0.6533 1.6844 Factor3 | 0.02321 0.17288 0.0280 1.7124 Factor4 | -0.14967 0.03951 -0.1807 1.5317 Factor5 | -0.18918 0.06197 -0.2284 1.3033 Factor6 | -0.25115 . -0.3033 1.0000 -------------------------------------------------------------------------- LR test: independent vs. saturated: chi2(15) = 269.07 Prob>chi2 = 0.0000 Factor loadings (pattern matrix) and unique variances ----------------------------------------------------------- Variable | Factor1 Factor2 Factor3 | Uniqueness -------------+------------------------------+-------------- bg2cost1 | 0.2470 0.3670 -0.0446 | 0.8023 bg2cost2 | -0.3374 0.3321 -0.0772 | 0.7699 bg2cost3 | -0.3764 0.3756 0.0204 | 0.7169 bg2cost4 | -0.3221 0.1942 0.1034 | 0.8479 bg2cost5 | 0.4550 0.2479 0.0641 | 0.7274 bg2cost6 | 0.4760 0.2364 -0.0068 | 0.7175 ----------------------------------------------------------- . ereturn list scalars: e(f) = 3 e(N) = 568 e(df_m) = 15 e(df_r) = 0 e(chi2_i) = 269.0736870812582 e(df_i) = 15 e(p_i) = 1.43900835150e-48 e(evsum) = .8281790835746108 macros: e(cmdline) : "factor bg2cost1-bg2cost6" e(cmd) : "factor" e(marginsnotok) : "_ALL" e(properties) : "nob noV eigen" e(title) : "Factor analysis" e(predict) : "factor_p" e(estat_cmd) : "factor_estat" e(rotate_cmd) : "factor_rotate" e(rngstate) : "XAA9ed88223516e274a356c2f09b5d3751dad848dd14ccb2bdf5ffa49.." e(mtitle) : "principal factors" e(method) : "pf" matrices: e(sds) : 1 x 6 e(means) : 1 x 6 e(C) : 6 x 6 e(Phi) : 3 x 3 e(L) : 6 x 3 e(Psi) : 1 x 6 e(Ev) : 1 x 6 functions: e(sample) . matrix list e(L) e(L)[6,3] Factor1 Factor2 Factor3 bg2cost1 .24704957 .36703122 -.04457883 bg2cost2 -.33741222 .33210838 -.07721559 bg2cost3 -.37640773 .3755668 .02035389 bg2cost4 -.32206954 .1941843 .10341942 bg2cost5 .45501598 .24785063 .06407803 bg2cost6 .47598434 .23638092 -.0067801 . matrix list e(Psi) e(Psi)[1,6] bg2cost1 bg2cost2 bg2cost3 bg2cost4 bg2cost5 bg2cost6 Uniqueness .80226732 .76989477 .71685252 .84786809 .72742453 .717517Code
The simplest way to tabulate the factor loadings is to type:
. esttab e(L) --------------------------------------------------- e(L) Factor1 Factor2 Factor3 --------------------------------------------------- bg2cost1 .2470496 .3670312 -.0445788 bg2cost2 -.3374122 .3321084 -.0772156 bg2cost3 -.3764077 .3755668 .0203539 bg2cost4 -.3220695 .1941843 .1034194 bg2cost5 .455016 .2478506 .064078 bg2cost6 .4759843 .2363809 -.0067801 ---------------------------------------------------Code
Reproducing the factor loadings table including the unique variances is more involved. The
single factors in e(L) have to be addressed individually. For example, type:
. esttab, cells("L[1](transpose) L[2](transpose) L[3](transpose) Psi") /// > nogap noobs nonumber nomtitle ---------------------------------------------------------------- L[1] L[2] L[3] Psi ---------------------------------------------------------------- bg2cost1 .2470496 .3670312 -.0445788 .8022673 bg2cost2 -.3374122 .3321084 -.0772156 .7698948 bg2cost3 -.3764077 .3755668 .0203539 .7168525 bg2cost4 -.3220695 .1941843 .1034194 .8478681 bg2cost5 .455016 .2478506 .064078 .7274245 bg2cost6 .4759843 .2363809 -.0067801 .717517 ----------------------------------------------------------------Code
The transpose suboption is required since the factors are in the columns
of e(L) and, by default, e()-matrices are read row-wise
(transpose can be abbreviated to t). Hence,
L[#](transpose) refers to the #th column of e(L).
The label() suboption can be used to add labels, for example:
. esttab, cells("L[1](t label(Factor 1)) L[2](t) L[3](t) Psi") /// > nogap noobs nonumber nomtitle ---------------------------------------------------------------- Factor 1 L[2] L[3] Psi ---------------------------------------------------------------- bg2cost1 .2470496 .3670312 -.0445788 .8022673 bg2cost2 -.3374122 .3321084 -.0772156 .7698948 bg2cost3 -.3764077 .3755668 .0203539 .7168525 bg2cost4 -.3220695 .1941843 .1034194 .8478681 bg2cost5 .455016 .2478506 .064078 .7274245 bg2cost6 .4759843 .2363809 -.0067801 .717517 ----------------------------------------------------------------Code
Alternatively, you can also use syntax el[name], where
name refers to the name of the row to be tabulated (or column if
transpose is specified) and also sets the label:
. esttab, cells("L[Factor1](t) L[Factor2](t) L[Factor3](t) Psi[Uniqueness]") /// > nogap noobs nonumber nomtitle ---------------------------------------------------------------- Factor1 Factor2 Factor3 Uniqueness ---------------------------------------------------------------- bg2cost1 .2470496 .3670312 -.0445788 .8022673 bg2cost2 -.3374122 .3321084 -.0772156 .7698948 bg2cost3 -.3764077 .3755668 .0203539 .7168525 bg2cost4 -.3220695 .1941843 .1034194 .8478681 bg2cost5 .455016 .2478506 .064078 .7274245 bg2cost6 .4759843 .2363809 -.0067801 .717517 ----------------------------------------------------------------Code
Tables of ologit
or oprobit
look somewhat complicated in
Stata 9 or newer since each cutoff is stored in its own equation. To clean out
the table, specify eqlabels(none):
. sysuse auto, clear (1978 Automobile Data) . ologit rep mpg foreign Iteration 0: log likelihood = -93.692061 Iteration 1: log likelihood = -78.844995 Iteration 2: log likelihood = -78.095292 Iteration 3: log likelihood = -78.089244 Iteration 4: log likelihood = -78.089242 Ordered logistic regression Number of obs = 69 LR chi2(2) = 31.21 Prob > chi2 = 0.0000 Log likelihood = -78.089242 Pseudo R2 = 0.1665 ------------------------------------------------------------------------------ rep78 | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- mpg | .0672774 .0494465 1.36 0.174 -.029636 .1641908 foreign | 2.599085 .6745635 3.85 0.000 1.276964 3.921205 -------------+---------------------------------------------------------------- /cut1 | -1.885212 1.175719 -4.18958 .4191557 /cut2 | -.0922329 .9934141 -2.039289 1.854823 /cut3 | 2.524538 1.021289 .5228484 4.526228 /cut4 | 4.580877 1.146848 2.333095 6.828658 ------------------------------------------------------------------------------ . esttab, wide ----------------------------------------- (1) rep78 ----------------------------------------- rep78 mpg 0.0673 (1.36) foreign 2.599*** (3.85) ----------------------------------------- cut1 _cons -1.885 (-1.60) ----------------------------------------- cut2 _cons -0.0922 (-0.09) ----------------------------------------- cut3 _cons 2.525* (2.47) ----------------------------------------- cut4 _cons 4.581*** (3.99) ----------------------------------------- N 69 ----------------------------------------- t statistics in parentheses * p<0.05, ** p<0.01, *** p<0.001 . esttab, wide eqlabels(none) ----------------------------------------- (1) rep78 ----------------------------------------- mpg 0.0673 (1.36) foreign 2.599*** (3.85) cut1 -1.885 (-1.60) cut2 -0.0922 (-0.09) cut3 2.525* (2.47) cut4 4.581*** (3.99) ----------------------------------------- N 69 ----------------------------------------- t statistics in parentheses * p<0.05, ** p<0.01, *** p<0.001Code
To print a line between the main part of the table and the cutoffs, type:
. esttab, wide eqlabels(none) /// > varlabels(,blist(cut1:_cons "{hline @width}{break}")) ----------------------------------------- (1) rep78 ----------------------------------------- mpg 0.0673 (1.36) foreign 2.599*** (3.85) ----------------------------------------- cut1 -1.885 (-1.60) cut2 -0.0922 (-0.09) cut3 2.525* (2.47) cut4 4.581*** (3.99) ----------------------------------------- N 69 ----------------------------------------- t statistics in parentheses * p<0.05, ** p<0.01, *** p<0.001Code
Furthermore, to suppress significance stars and standard errors for the cutoffs, type:
. esttab, cells("b(fmt(a3) star) se(drop(cut*:))") /// > stardrop(cut*:) eqlabels(none) /// > varlabels(,blist(cut1:_cons "{hline @width}{break}")) ----------------------------------------- (1) rep78 b se ----------------------------------------- mpg 0.0673 0.0494 foreign 2.599*** 0.675 ----------------------------------------- cut1 -1.885 cut2 -0.0922 cut3 2.525 cut4 4.581 ----------------------------------------- N 69 -----------------------------------------Code
To tabulate the marginal effects for all outcomes after
mlogit
it is necessary to store several sets of results from margins. Example:
. sysuse auto, clear (1978 Automobile Data) . replace price = price / 1000 variable price was int now float (74 real changes made) . replace weight = weight / 1000 variable weight was int now float (74 real changes made) . quietly mlogit rep78 price mpg foreign if rep78>=3, nolog . eststo mlogit . foreach o in 3 4 5 { 2. quietly margins, dydx(*) predict(outcome(`o')) post 3. eststo, title(Outcome `o') 4. estimates restore mlogit 5. } (est2 stored) (results mlogit are active now) (est3 stored) (results mlogit are active now) (est4 stored) (results mlogit are active now) . eststo drop mlogit (mlogit dropped) . esttab, noobs se nostar mtitles nonumbers title(Average Marginal Effects) (tabulating estimates stored by eststo; specify "." to tabulate the active results) Average Marginal Effects --------------------------------------------------- Outcome 3 Outcome 4 Outcome 5 --------------------------------------------------- price -0.00245 -0.0163 0.0188 (0.0213) (0.0251) (0.0176) mpg -0.0118 -0.00802 0.0198 (0.0122) (0.0126) (0.00770) foreign -0.396 0.223 0.173 (0.0884) (0.116) (0.0754) --------------------------------------------------- Standard errors in parentheses . eststo clearCode
Variance parameters are returned by
xtmixed as logarithms of
standard deviations in e(b).
To tabulate the parameters as standard deviations, back-transform
them using the transform() option. Example:
. webuse pig, clear (Longitudinal analysis of pig weights) . xtmixed weight week || id: week Performing EM optimization: Performing gradient-based optimization: Iteration 0: log likelihood = -869.03825 Iteration 1: log likelihood = -869.03825 Computing standard errors: Mixed-effects ML regression Number of obs = 432 Group variable: id Number of groups = 48 Obs per group: min = 9 avg = 9.0 max = 9 Wald chi2(1) = 4689.51 Log likelihood = -869.03825 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ weight | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- week | 6.209896 .0906819 68.48 0.000 6.032163 6.387629 _cons | 19.35561 .3979159 48.64 0.000 18.57571 20.13551 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval] -----------------------------+------------------------------------------------ id: Independent | sd(week) | .6066851 .0660294 .4901417 .7509396 sd(_cons) | 2.599301 .2969073 2.077913 3.251515 -----------------------------+------------------------------------------------ sd(Residual) | 1.264441 .0487958 1.17233 1.363789 ------------------------------------------------------------------------------ LR test vs. linear model: chi2(2) = 764.42 Prob > chi2 = 0.0000 Note: LR test is conservative and provided only for reference. . esttab, se wide nostar transform(ln*: exp(@) exp(@)) -------------------------------------- (1) weight -------------------------------------- weight week 6.210 (0.0907) _cons 19.36 (0.398) -------------------------------------- lns1_1_1 _cons 0.607 (0.0660) -------------------------------------- lns1_1_2 _cons 2.599 (0.297) -------------------------------------- lnsig_e _cons 1.264 (0.0488) -------------------------------------- N 432 -------------------------------------- Standard errors in parentheses . esttab, se wide nostar transform(ln*: exp(@) exp(@)) /// > eqlabels("" "sd(week)" "sd(_cons)" "sd(Residual)", none) /// > varlabels(,elist(weight:_cons "{break}{hline @width}")) /// > varwidth(13) --------------------------------------- (1) weight --------------------------------------- week 6.210 (0.0907) _cons 19.36 (0.398) --------------------------------------- sd(week) 0.607 (0.0660) sd(_cons) 2.599 (0.297) sd(Residual) 1.264 (0.0488) --------------------------------------- N 432 --------------------------------------- Standard errors in parenthesesCode
Note that in transform() you also have to include
the function's first derivative, which is required for the standard errors.
The example above might be confusing because the first derivative of exp(x)
is simply exp(x). See below for examples where the two differ.
Similarly, to display the parameters as variances, type:
. xtmixed, variance Mixed-effects ML regression Number of obs = 432 Group variable: id Number of groups = 48 Obs per group: min = 9 avg = 9.0 max = 9 Wald chi2(1) = 4689.51 Log likelihood = -869.03825 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ weight | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- week | 6.209896 .0906819 68.48 0.000 6.032163 6.387629 _cons | 19.35561 .3979159 48.64 0.000 18.57571 20.13551 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval] -----------------------------+------------------------------------------------ id: Independent | var(week) | .3680668 .0801181 .2402389 .5639103 var(_cons) | 6.756364 1.543503 4.317721 10.57235 -----------------------------+------------------------------------------------ var(Residual) | 1.598811 .1233988 1.374358 1.85992 ------------------------------------------------------------------------------ LR test vs. linear model: chi2(2) = 764.42 Prob > chi2 = 0.0000 Note: LR test is conservative and provided only for reference. . esttab, se wide nostar transform(ln*: exp(2*@) 2*exp(2*@)) /// > eqlabels("" "var(week)" "var(_cons)" "var(Residual)", none) /// > varlabels(,elist(weight:_cons "{break}{hline @width}")) /// > varwidth(13) --------------------------------------- (1) weight --------------------------------------- week 6.210 (0.0907) _cons 19.36 (0.398) --------------------------------------- var(week) 0.368 (0.0801) var(_cons) 6.756 (1.544) var(Residual) 1.599 (0.123) --------------------------------------- N 432 --------------------------------------- Standard errors in parenthesesCode
If the model also has covariance terms, these are returned as
arc-hyperbolic tangents of correlations in e(b) and can be back-transformed
to correlations using Stata's tanh() function. Example:
. xtmixed weight week || id: week, covariance(unstructured) Performing EM optimization: Performing gradient-based optimization: Iteration 0: log likelihood = -868.96185 Iteration 1: log likelihood = -868.96185 Computing standard errors: Mixed-effects ML regression Number of obs = 432 Group variable: id Number of groups = 48 Obs per group: min = 9 avg = 9.0 max = 9 Wald chi2(1) = 4649.17 Log likelihood = -868.96185 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ weight | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- week | 6.209896 .0910745 68.18 0.000 6.031393 6.388399 _cons | 19.35561 .3996387 48.43 0.000 18.57234 20.13889 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval] -----------------------------+------------------------------------------------ id: Unstructured | sd(week) | .6095286 .0666874 .4918874 .7553052 sd(_cons) | 2.612157 .2997895 2.085976 3.271064 corr(week,_cons) | -.0618257 .1575911 -.3557072 .243182 -----------------------------+------------------------------------------------ sd(Residual) | 1.263657 .0487466 1.171638 1.362903 ------------------------------------------------------------------------------ LR test vs. linear model: chi2(3) = 764.58 Prob > chi2 = 0.0000 Note: LR test is conservative and provided only for reference. . esttab, se wide nostar /// > transform(ln*: exp(@) exp(@) at*: tanh(@) (1-tanh(@)^2)) /// > eqlabels("" "sd(week)" "sd(_cons)" "corr(week,_cons)" "sd(Residual)", /// > none) /// > varlabels(,elist(weight:_cons "{break}{hline @width}")) /// > varwidth(16) ------------------------------------------ (1) weight ------------------------------------------ week 6.210 (0.0911) _cons 19.36 (0.400) ------------------------------------------ sd(week) 0.610 (0.0667) sd(_cons) 2.612 (0.300) corr(week,_cons) -0.0618 (0.158) sd(Residual) 1.264 (0.0487) ------------------------------------------ N 432 ------------------------------------------ Standard errors in parenthesesCode
Unfortunately, it is not possible for transform() to turn such correlations
into covariances (requires multiplication by the standard deviations). However, you can
use estadd to manually compute the terms in advance and add them in the footer
of the table. Example:
. xtmixed, variance Mixed-effects ML regression Number of obs = 432 Group variable: id Number of groups = 48 Obs per group: min = 9 avg = 9.0 max = 9 Wald chi2(1) = 4649.17 Log likelihood = -868.96185 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ weight | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- week | 6.209896 .0910745 68.18 0.000 6.031393 6.388399 _cons | 19.35561 .3996387 48.43 0.000 18.57234 20.13889 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval] -----------------------------+------------------------------------------------ id: Unstructured | var(week) | .3715251 .0812958 .2419532 .5704859 var(_cons) | 6.823363 1.566194 4.351297 10.69986 cov(week,_cons) | -.0984378 .2545767 -.5973991 .4005234 -----------------------------+------------------------------------------------ var(Residual) | 1.596829 .123198 1.372735 1.857505 ------------------------------------------------------------------------------ LR test vs. linear model: chi2(3) = 764.58 Prob > chi2 = 0.0000 Note: LR test is conservative and provided only for reference. . mat list e(b) e(b)[1,6] weight: weight: lns1_1_1: lns1_1_2: atr1_1_1_2: lnsig_e: week _cons _cons _cons _cons _cons y1 6.2098958 19.355613 -.4950694 .96017623 -.06190461 .2340099 . estadd scalar v1 = exp(2*[lns1_1_1]_b[_cons]) added scalar: e(v1) = .37152512 . estadd scalar v2 = exp(2*[lns1_1_2]_b[_cons]) added scalar: e(v2) = 6.823363 . estadd scalar cov = tanh([atr1_1_1_2]_b[_cons]) * /// > exp([lns1_1_1]_b[_cons]) * exp([lns1_1_2]_b[_cons]) added scalar: e(cov) = -.09843783 . estadd scalar v_e = exp(2*[lnsig_e]_b[_cons]) added scalar: e(v_e) = 1.596829 . esttab, se wide nostar keep(weight:) obslast /// > scalars("v1 var(week)" "v2 var(_cons)" /// > "cov cov(week,_cons)" "v_e var(Residual)") /// > eqlabels(none) varwidth(15) ----------------------------------------- (1) weight ----------------------------------------- week 6.210 (0.0911) _cons 19.36 (0.400) ----------------------------------------- var(week) 0.372 var(_cons) 6.823 cov(week,_cons) -0.0984 var(Residual) 1.597 N 432 ----------------------------------------- Standard errors in parenthesesCode