I would like to export the results of a spatial error lag model using collect in Stata 19. Example 1 below illustrates that when I restrict the number of coefficients shown in the collect table that I lose the estimated error term even though the term (e.mpg) is included in the table layout and is also a level of the colname dimension. Example 2 shows that e.mpg is included in the table layout when I make no attempt to restrict the variables displayed.
I'm not sure if this is a bug or feature of collect. I would welcome any advice on how to get the error term to display when restricting the variables shown in the table layout.
EDIT: I added an Example 3 below with a workaround using autolevels. However, it's still not clear to me why Example 1 fails. Genuinely curious if there's a bug or something I'm missing about the syntax.
I'm not sure if this is a bug or feature of collect. I would welcome any advice on how to get the error term to display when restricting the variables shown in the table layout.
EDIT: I added an Example 3 below with a workaround using autolevels. However, it's still not clear to me why Example 1 fails. Genuinely curious if there's a bug or something I'm missing about the syntax.
Code:
clear all spset, clear * Import Auto Dataset clear all spset, clear * Import Auto Dataset sysuse auto, clear * Generate ID gen id = _n * Generate Longitude and Latitude Coordinates gen _CX = 40 + rnormal() gen _CY = -70 + rnormal() * Set the Data for Spatial Analysis spset id, coord(_CX _CY) coordsys(latlong, miles) * Create a Spatial Matrix Based on Inverse Distance spmatrix create idistance W * Estimate Regression Model collect _r_b _r_se, tag(model[1]): spregress mpg price weight, gs2sls errorlag(W) collect _r_b _r_se, tag(model[2]): spregress mpg price weight, ml vce(robust) errorlag(W) * Example 1: Select Model Variables (e.mpg not displayed) collect layout (colname[price _cons e.mpg var(e.mpg)]#result[_r_b _r_se]) (model) * Show that e.mpg is in the colname dimension collect levelsof colname * Example 2: All Model Variables collect layout (colname#result[_r_b _r_se]) (model) * Example 3: Workaround using autolevels collect style autolevels colname price _cons e.mpg var(e.mpg) collect layout (colname#result[_r_b _r_se]) (model)

Comment