1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260
| . * net install bivariate.pkg, from("http://digital.cgdev.org/doc/stata/MO/Misc/")
. * h bivariate
. * 因变量与每个独立变量的二元关联,可以产生变量的描述性统计表格和VIF等
. * Setup
. sysuse auto, clear (1978 Automobile Data)
. bivariate price weight mpg rep78 foreign, tabstat obsgain
Summary of the bivariate relationships between the dependent variable: price and each of the independent variables: weight mpg rep78 foreign
Casewise deletion deletes : 5 observations.
The analysis uses : 69 observations. The variance inflation factor is: Centered Without the variable rep78 nobs is: 74
Bivariate table for the dependent variable: price
| Correla~n For D=0 For D=1 t-stat p-value VIF Obs Gai~d -------------+----------------------------------------------------------------------------- weight | .5478396 . . 5.360207 1.10e-06 4.087574 0 mpg | -.455949 . . -4.193346 .0000825 3.104604 0 rep78 | .0065533 . . .053642 .95738 1.64413 5 foreign | . 6179.25 6070.143 -.1421511 .8873872 2.36932 0
If Gallup's -frmttable- is installed, click here: frmttable , statmat(r(bivariate))
Option -tabstat-: Descriptive statistics on the dependent and the independent variables:
| mean p50 sd cv min max skewness -------------+----------------------------------------------------------------------------- price | 6146.043 5079 2912.44 .4738724 3291 15906 1.687968 weight | 3032.029 3200 792.8515 .2614921 1760 4840 .1180643 mpg | 21.28986 20 5.866408 .2755495 12 41 .9953495 rep78 | 3.405797 3 .9899323 .290661 1 5 -.0570331 foreign | .3043478 0 .4635016 1.522934 0 1 .8504201
If Gallup's -frmttable- is installed, click here: frmttable , statmat(r(TransposedST))
. * 更美观的表格显示
. frmttable , statmat(r(TransposedST))
------------------------------------------------------------------------------ mean p50 sd cv min max skewness ------------------------------------------------------------------------------ price 6,146.04 5,079.00 2,912.44 0.47 3,291.00 15,906.00 1.69 weight 3,032.03 3,200.00 792.85 0.26 1,760.00 4,840.00 0.12 mpg 21.29 20.00 5.87 0.28 12.00 41.00 1.00 rep78 3.41 3.00 0.99 0.29 1.00 5.00 -0.06 foreign 0.30 0.00 0.46 1.52 0.00 1.00 0.85 ------------------------------------------------------------------------------
. frmttable , statmat(r(bivariate))
------------------------------------------------------------------------------- Correlation For D=0 For D=1 t-stat p-value VIF Obs Gained ------------------------------------------------------------------------------- weight 0.55 5.36 0.00 4.09 0.00 mpg -0.46 -4.19 0.00 3.10 0.00 rep78 0.01 0.05 0.96 1.64 5.00 foreign 6,179.25 6,070.14 -0.14 0.89 2.37 0.00 -------------------------------------------------------------------------------
. * 下面的命令可以产生相同的结果
. regress price weight mpg rep78 foreign
Source | SS df MS Number of obs = 69 -------------+---------------------------------- F(4, 64) = 15.82 Model | 286761158 4 71690289.6 Prob > F = 0.0000 Residual | 290035800 64 4531809.38 R-squared = 0.4972 -------------+---------------------------------- Adj R-squared = 0.4657 Total | 576796959 68 8482308.22 Root MSE = 2128.8
------------------------------------------------------------------------------ price | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- weight | 3.565247 .6582976 5.42 0.000 2.250146 4.880347 mpg | 27.32371 77.53757 0.35 0.726 -127.5754 182.2228 rep78 | 121.1322 334.3828 0.36 0.718 -546.8742 789.1387 foreign | 3520.324 857.318 4.11 0.000 1807.634 5233.013 _cons | -6729.56 3450.835 -1.95 0.056 -13623.4 164.2752 ------------------------------------------------------------------------------
. gen byte insample = e(sample)
. summ price weight mpg rep78 if insample
Variable | Obs Mean Std. Dev. Min Max -------------+--------------------------------------------------------- price | 69 6146.043 2912.44 3291 15906 weight | 69 3032.029 792.8515 1760 4840 mpg | 69 21.28986 5.866408 12 41 rep78 | 69 3.405797 .9899323 1 5
. tab foreign if insample, sum(price)
| Summary of Price Car type | Mean Std. Dev. Freq. ------------+------------------------------------ Domestic | 6,179.25 3,188.969 48 Foreign | 6,070.143 2,220.984 21 ------------+------------------------------------ Total | 6,146.043 2,912.44 69
. . * 不显示VIF
. bivariate price weight mpg rep78 foreign, novif
Summary of the bivariate relationships between the dependent variable: price and each of the independent variables: weight mpg rep78 foreign
Casewise deletion deletes : 5 observations.
The analysis uses : 69 observations. The variance inflation factor is: Suppressed
Bivariate table for the dependent variable: price
| Correla~n For D=0 For D=1 t-stat p-value -------------+------------------------------------------------------- weight | .5478396 . . 5.360207 1.10e-06 mpg | -.455949 . . -4.193346 .0000825 rep78 | .0065533 . . .053642 .95738 foreign | . 6179.25 6070.143 -.1421511 .8873872
If Gallup's -frmttable- is installed, click here: frmttable , statmat(r(bivariate))
. * frmttable 命令可以将表格输出至word文件
. frmttable using word, replace statmat(r(bivariate)) rtitles("Vehicle weight" \ "Miles per gallon" \ "Repair record" \ "Foreign or domestic > ") sdec(3,0,0,2,3,1,0) title("Table _. Bivariate relationships between vehicle price and each independent variables")
Table _. Bivariate relationships between vehicle price and each independent variables ----------------------------------------------------------------------- Correlation For D=0 For D=1 t-stat p-value ----------------------------------------------------------------------- Vehicle weight 0.548 5.36 0.000 Miles per gallon -0.456 -4.19 0.000 Repair record 0.007 0.05 0.957 Foreign or domestic 6,179 6,070 -0.14 0.887 -----------------------------------------------------------------------
. * 也可以制定统计量
. bivariate price weight mpg rep78, group(foreign) groupstats(n mean sd)
Summary of the bivariate relationships between the dependent variable: price and each of the independent variables: weight mpg rep78
Casewise deletion deletes : 5 observations.
The analysis uses : 69 observations. The variance inflation factor is: Centered
Bivariate table for the dependent variable: price
| Correla~n t-stat p-value VIF -------------+-------------------------------------------- weight | .5478396 5.360207 1.10e-06 2.905282 mpg | -.455949 -4.193346 .0000825 2.910836 rep78 | .0065533 .053642 .95738 1.217191
If Gallup's -frmttable- is installed, click here: frmttable , statmat(r(bivariate))
Estimation sample discrim lda Summarized by foreign
| foreign | Domestic Foreign | Total -------------+----------------------+---------- price | | Mean | 6179.25 6070.143 | 6146.043 Std dev | 3188.969 2220.984 | 2912.44 -------------+----------------------+---------- weight | | Mean | 3368.333 2263.333 | 3032.029 Std dev | 688.0108 364.7099 | 792.8515 -------------+----------------------+---------- mpg | | Mean | 19.54167 25.28571 | 21.28986 Std dev | 4.753312 6.309856 | 5.866408 -------------+----------------------+---------- rep78 | | Mean | 3.020833 4.285714 | 3.405797 Std dev | .837666 .7171372 | .9899323 -------------+----------------------+---------- | | N | 48 21 | 69
Statistics by group available in the matrix r(grouptab)
| Domestic | Foreign | mean sd | mean sd -------------+----------------------+---------------------- price | 6179.25 3188.969 | 6070.143 2220.984 weight | 3368.333 688.0108 | 2263.333 364.7099 mpg | 19.54167 4.753312 | 25.28571 6.309856 rep78 | 3.020833 .837666 | 4.285714 .7171372
If Gallup's -frmttable- is installed, click on one of the following links: frmttable , statmat(r(grouptab)) frmttable , statmat(r(frmttable)) note(Statistics are -- mean sd) substat(1)
. matrix list r(grouptab)
r(grouptab)[4,4] Domestic: Domestic: Foreign: Foreign: mean sd mean sd price 6179.25 3188.9693 6070.1429 2220.9835 weight 3368.3333 688.0108 2263.3333 364.70993 mpg 19.541667 4.7533116 25.285714 6.3098562 rep78 3.0208333 .83766604 4.2857143 .71713717
. frmttable, statmat(r(grouptab))
-------------------------------------------------- Domestic Domestic Foreign Foreign mean sd mean sd -------------------------------------------------- price 6,179.25 3,188.97 6,070.14 2,220.98 weight 3,368.33 688.01 2,263.33 364.71 mpg 19.54 4.75 25.29 6.31 rep78 3.02 0.84 4.29 0.72 --------------------------------------------------
. frmttable, statmat(r(frmttable)) substat(1)
---------------------------------- Domestic Foreign ---------------------------------- price 6,179.25 6,070.14 (3,188.97) (2,220.98) weight 3,368.33 2,263.33 (688.01) (364.71) mpg 19.54 25.29 (4.75) (6.31) rep78 3.02 4.29 (0.84) (0.72) ----------------------------------
|