I have a question about esttab and more precisely to add scalars.
I start with a spatial model (for this first estimation, all my scalars are displayed in the output of esttab). Then, as I want to modify the output, changing the equation names, I saved the estimated coefficients and variance matrix and play a bit with them. Then I have trouble with the scalars in esttab output (missing one).
Code:
copy http://www.stata-press.com/data/r15/homicide1990.dta . copy http://www.stata-press.com/data/r15/homicide1990_shp.dta . use homicide1990 spset spmatrix create contiguity W *STEP 0 : Small programm to rebuild estimation from B and V matrix capture program drop Post program Post, eclass syntax, r(string) vce(string) sample(string) eret post `r' `vce' , esample(`sample') eret local cmd "spregress" end eststo clear mat drop _all *STEP 1 : estimation model and saving of some information eststo ini : spregress hrate ln_population ln_pdensity gini, ml ivarlag(W: ln_population ln_pdensity gini) scalar pseudo_R2=e(r2_p) scalar N=e(N) qui estat ic mat A = r(S) scalar aic = A[1, 5] marksample touse estadd scalar pseudo_R2=pseudo_R2 esttab ini, scalars(N pseudo_R2 aic)
Code:
---------------------------- (1) hrate ---------------------------- hrate ln_populat~n -0.0325 (-0.10) ln_pdensity 1.037** (3.25) gini 98.97*** (15.29) _cons -35.47*** (-11.82) ---------------------------- W ln_populat~n 1.206** (2.61) ln_pdensity -0.163 (-0.32) gini -22.52** (-2.92) ---------------------------- / var(e.hrate) 40.28*** (26.57) ---------------------------- N 1412 pseudo_R2 0.186 aic 9241.6 ---------------------------- t statistics in parentheses * p<0.05, ** p<0.01, *** p<0.001
Code:
* saving estimated coeff and variance matrix mat B=e(b) mat V=e(V) * STEP 2 : modify the equation names ("X variables" instead of "hrate", "WX variables" instead of "W") matrix coleq B = "X~Variables" "X~Variables" "X~Variables" "X~Variables" "WX~Variables" "WX~Variables" "WX~Variables" "/" matrix coleq V = "X~Variables" "X~Variables" "X~Variables" "X~Variables" "WX~Variables" "WX~Variables" "WX~Variables" "/" matrix roweq V = "X~Variables" "X~Variables" "X~Variables" "X~Variables" "WX~Variables" "WX~Variables" "WX~Variables" "/" Post, r(B) vce(V) sample(`touse') estimate store Then scalar list estadd scalar pseudo_R2=pseudo_R2 estadd scalar aic=aic estadd scalar N=N
Code:
. ereturn list scalars: e(N) = 1412 e(pseudo_R2) = .1864699789919876 e(aic) = 9241.564645867 macros: e(properties) : "b V" e(cmd) : "spregress" matrices: e(b) : 1 x 8 e(V) : 8 x 8 functions: e(sample)
Code:
. esttab Then, scalars(N pseudo_R2 aic) ---------------------------- (1) ---------------------------- X~Variables ln_populat~n -0.0325 (-0.10) ln_pdensity 1.037** (3.25) gini 98.97*** (15.29) _cons -35.47*** (-11.82) ---------------------------- WX~Variables ln_populat~n 1.206** (2.61) ln_pdensity -0.163 (-0.32) gini -22.52** (-2.92) ---------------------------- / var(e.hrate) 40.28*** (26.57) ---------------------------- N 1412 pseudo_R2 0.186 aic . ---------------------------- t statistics in parentheses * p<0.05, ** p<0.01, *** p<0.001
What is my mistake with the scalars?
Was there a easiest way to change the equation names ?
Thank you very much.
Valérie
0 Response to Scalars missing in output of esttab
Post a Comment