clear all // clear workspace
use "gutten.dta", clear // use tree data as example
1 Introduction 🌲
This is a shorter working example to make tables in Stata.
2 Data Source 🌲
The data used in this example are derived from the R package Functions and Datasets for “Forest Analytics with R”.
According to the documentation, the source of these data are: “von Guttenberg’s Norway spruce (Picea abies [L.] Karst) tree measurement data.”
The documentation goes on to further note that:
“The data are measures from 107 trees. The trees were selected as being of average size from healthy and well stocked stands in the Alps.”
3 Setup🌲
4 Variables 🌲
site
Growth quality class of the tree’s habitat. 5 levels.
location
Distinguishes tree location. 7 levels.
tree
An identifier for the tree within location.
age_base
The tree age taken at ground level.
height
Tree height, m.
dbh_cm
Tree diameter, cm.
volume
Tree volume.
age_bh
Tree age taken at 1.3 m.
tree_ID
A factor uniquely identifying the tree.
5 Estimate Multilevel Models🌲
quietly
To Suppress Output
For the sake of parsimony, I use quietly:
to suppress the output of the mixed
commands.
quietly: mixed height age_base i.site || tree_ID: // shorter mixed model
est store M1 // store the estimates
quietly: mixed height age_base i.site i.location || tree_ID: // longer mixed model
est store M2 // store the estimates
6 Table With etable
🌲
6.1 Regression Coefficients With Significance Stars
estimates(M1 M2) /// use these estimate(s)
etable, /// variable names only; could use variable labels
novarlabel /// beta's only
cstat(_r_b) /// show stars and note
showstars showstarsnote // column is modelname column(estimate)
M1 M2
--------------------------------------------
age_base 0.214 ** 0.214 **
site
2 -3.316 ** -2.994 **
3 -8.095 ** -7.765 **
4 -11.510 ** -10.844 **
5 -15.866 ** -15.179 **
location
2 -0.322
3 0.475
4 0.060
5 -0.450
6 -0.255
7 -1.454
_cons 8.233 ** 8.181 **
var(_cons) 2.171 1.981
var(e) 8.393 8.397
Number of observations 1200 1200
--------------------------------------------
** p<.01, * p<.05
6.2 Regression Coefficients With p Values
estimates(M1 M2) /// use these estimate(s)
etable, /// variable names only; could use variable labels
novarlabel /// beta's and p values
cstat(_r_b) cstat(_r_p) // column is modelname column(estimate)
M1 M2
--------------------------------------
age_base 0.214 0.214
0.00 0.00
site
2 -3.316 -2.994
0.00 0.00
3 -8.095 -7.765
0.00 0.00
4 -11.510 -10.844
0.00 0.00
5 -15.866 -15.179
0.00 0.00
location
2 -0.322
0.80
3 0.475
0.46
4 0.060
0.93
5 -0.450
0.40
6 -0.255
0.72
7 -1.454
0.05
_cons 8.233 8.181
0.00 0.00
var(_cons) 2.171 1.981
var(e) 8.393 8.397
Number of observations 1200 1200
--------------------------------------