Tables for Multilevel Models in Stata

A Shorter Working Example

Author

Andy Grogan-Kaylor

Published

March 28, 2024

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.”

Old Tjikko, a 9,550 Year Old Norway Spruce in Sweden

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🌲


clear all // clear workspace

use "gutten.dta", clear // use tree data as example

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🌲

Use 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🌲


etable, estimates(M1 M2) /// use these estimate(s)
novarlabel /// variable names only
cstat(_r_b) /// beta's only
showstars showstarsnote /// show stars and note
column(estimate) // column is modelname
                           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