Custom statistics in nested regression tables
In recent version of asdocx (Jan 20, 2022: Version 1.9.8), the option stat()
of nested regressions has a big improvement. Previously, option stat()
would only report additional regression statistics that are stored in macro e()
. The updated version of asdocx allows us to report several other descriptive statistics for the dependent or any other selected variable. In this post, I show several examples of how option stat()
can be used in different scenarios. Please note that each statistic should be separated by the character comma.
Report statistics available in e() macro
After any regression model, you type ereturn list
, you shall see different scalars / macros available on the screen. These can be reported in the nested regression table by writing the macro name inside option stat()
. For example, after running an OLS model, the following macro are available.
ereturn list e(N) = 69 e(df_m) = 2 e(df_r) = 66 e(F) = 11.05650420530028 e(r2) = .250961904598189 e(rmse) = 2558.53561189829 e(mss) = 144754063.3643494 e(rss) = 432042895.5052159 e(r2_a) = .2282637804951038 e(ll) = -637.8293069393488 e(ll_0) = -647.7986144493904 e(rank) = 3
Let’s report the rmse
and r2_a
(the adjusted r-squared) in the nested regression model.
asdocx reg price mpg rep78, nest replace stat(rmse, r2_a)
(1) | |
---|---|
price | |
mpg | -271.643*** |
(57.771) | |
rep78 | 666.957* |
(342.356) | |
Intercept | 9657.754*** |
(1346.54) | |
Observations | 69 |
R2 | 0.251 |
RMSE | 2558.536 |
Adjusted R2 | 0.228 |
Report custom-statistics
Descriptive statistics can be reported for any variable in the nested regression tables using options statvar(varname)
and stat()
together. If option statvar()
is not used, the descriptive statistics are reported for the dependent variable of the regression model. The following descriptive statistics are allowed.
option | details |
---|---|
N | Number of observations |
mean | Arithmetic mean |
sd | Standard deviation |
sum | Sum / total |
min | The smallest value |
max | The largest value |
skewness | Skewness |
kurtosis | Kurtosis |
p1 | 1st percentile |
p5 | 5th percentile |
p10 | 10th percentile |
p25 | 25th percentile |
p50 | Median or the 50 percentile |
p75 | 75th percentile |
p90 | 90th percentile |
p99 | 99th percentile |
Let’s make a nested table of two regressions, each one having a different dependent variable. Also, let’s add mean, standard deviation, skewness, and kurtosis for the dependent variables.
asdocx reg price mpg rep78, nest replace stat(mean sd skewness kurtosis) asdocx reg foreign mpg rep78 length turn , nest stat(mean sd skewness kurtosis)
Variables | (1) | (2) |
---|---|---|
price | foreign | |
mpg | -271.643*** | -0.021* |
(57.771) | (0.011) | |
rep78 | 666.957* | 0.182*** |
(342.356) | (0.045) | |
length | -0.008** | |
(0.004) | ||
turn | -0.036* | |
(0.018) | ||
Intercept | 9657.754*** | 3.072*** |
(1346.54) | (0.79) | |
Observations | 69 | 69 |
R2 | 0.251 | 0.58 |
Mean | 6146.043 | 0.304 |
Std. Dev. | 2912.44 | 0.464 |
Skewness | 1.688 | 0.85 |
Kurtosis | 5.032 | 1.723 |
Option statvar()
Option
statvar()
is used to specify the variable for which descriptive statistics are reported. The default variable is the dependent variable of the regression model.