*clear all
*macro drop _all
set more off
import delimited "https://github.com/quarcs-lab/data-open/raw/master/auto/auto.csv", case(preserve) clear
*use "https://github.com/quarcs-lab/data-open/raw/master/auto/auto.dta", clear
*sysuse auto, clear
(encoding automatically selected: ISO-8859-1)
(12 vars, 74 obs)
describe
Contains data
Observations: 74
Variables: 12
--------------------------------------------------------------------------------
Variable Storage Display Value
name type format label Variable label
--------------------------------------------------------------------------------
make str17 %17s
price int %8.0g
mpg byte %8.0g
rep78 byte %8.0g
headroom float %9.0g
trunk byte %8.0g
weight int %8.0g
length int %8.0g
turn byte %8.0g
displacement int %8.0g
gear_ratio float %9.0g
foreign byte %8.0g
--------------------------------------------------------------------------------
Sorted by:
Note: Dataset has changed since last saved.
summarize
Variable | Obs Mean Std. dev. Min Max
-------------+---------------------------------------------------------
make | 0
price | 74 6165.257 2949.496 3291 15906
mpg | 74 21.2973 5.785503 12 41
rep78 | 69 3.405797 .9899323 1 5
headroom | 74 2.993243 .8459948 1.5 5
-------------+---------------------------------------------------------
trunk | 74 13.75676 4.277404 5 23
weight | 74 3019.459 777.1936 1760 4840
length | 74 187.9324 22.26634 142 233
turn | 74 39.64865 4.399354 31 51
displacement | 74 197.2973 91.83722 79 425
-------------+---------------------------------------------------------
gear_ratio | 74 3.014865 .4562871 2.19 3.89
foreign | 74 .2972973 .4601885 0 1
format %14.3f gear_ratio
label variable foreign "Car origin (0 for domestic and 1 for foreign)"
label variable price "Price of the car"
label variable weight "Weight of the car"
label variable mpg "Miles per gallon"
label define foreign 0 "domestic" 1 "foreign"
label values foreign foreign
describe
Contains data
Observations: 74
Variables: 12
--------------------------------------------------------------------------------
Variable Storage Display Value
name type format label Variable label
--------------------------------------------------------------------------------
make str17 %17s
price int %8.0g Price of the car
mpg byte %8.0g Miles per gallon
rep78 byte %8.0g
headroom float %9.0g
trunk byte %8.0g
weight int %8.0g Weight of the car
length int %8.0g
turn byte %8.0g
displacement int %8.0g
gear_ratio float %14.3f
foreign byte %8.0g foreign Car origin (0 for domestic and 1
for foreign)
--------------------------------------------------------------------------------
Sorted by:
Note: Dataset has changed since last saved.
generate kpl = mpg*0.425
label variable kpl "Kilometers per liter"
summarize, detail
make
-------------------------------------------------------------
no observations
Price of the car
-------------------------------------------------------------
Percentiles Smallest
1% 3291 3291
5% 3748 3299
10% 3895 3667 Obs 74
25% 4195 3748 Sum of wgt. 74
50% 5006.5 Mean 6165.257
Largest Std. dev. 2949.496
75% 6342 13466
90% 11385 13594 Variance 8699526
95% 13466 14500 Skewness 1.653434
99% 15906 15906 Kurtosis 4.819188
Miles per gallon
-------------------------------------------------------------
Percentiles Smallest
1% 12 12
5% 14 12
10% 14 14 Obs 74
25% 18 14 Sum of wgt. 74
50% 20 Mean 21.2973
Largest Std. dev. 5.785503
75% 25 34
90% 29 35 Variance 33.47205
95% 34 35 Skewness .9487176
99% 41 41 Kurtosis 3.975005
rep78
-------------------------------------------------------------
Percentiles Smallest
1% 1 1
5% 2 1
10% 2 2 Obs 69
25% 3 2 Sum of wgt. 69
50% 3 Mean 3.405797
Largest Std. dev. .9899323
75% 4 5
90% 5 5 Variance .9799659
95% 5 5 Skewness -.0570331
99% 5 5 Kurtosis 2.678086
headroom
-------------------------------------------------------------
Percentiles Smallest
1% 1.5 1.5
5% 1.5 1.5
10% 2 1.5 Obs 74
25% 2.5 1.5 Sum of wgt. 74
50% 3 Mean 2.993243
Largest Std. dev. .8459948
75% 3.5 4.5
90% 4 4.5 Variance .7157071
95% 4.5 4.5 Skewness .1408651
99% 5 5 Kurtosis 2.208453
trunk
-------------------------------------------------------------
Percentiles Smallest
1% 5 5
5% 7 6
10% 8 7 Obs 74
25% 10 7 Sum of wgt. 74
50% 14 Mean 13.75676
Largest Std. dev. 4.277404
75% 17 21
90% 20 21 Variance 18.29619
95% 21 22 Skewness .0292034
99% 23 23 Kurtosis 2.192052
Weight of the car
-------------------------------------------------------------
Percentiles Smallest
1% 1760 1760
5% 1830 1800
10% 2020 1800 Obs 74
25% 2240 1830 Sum of wgt. 74
50% 3190 Mean 3019.459
Largest Std. dev. 777.1936
75% 3600 4290
90% 4060 4330 Variance 604029.8
95% 4290 4720 Skewness .1481164
99% 4840 4840 Kurtosis 2.118403
length
-------------------------------------------------------------
Percentiles Smallest
1% 142 142
5% 154 147
10% 157 149 Obs 74
25% 170 154 Sum of wgt. 74
50% 192.5 Mean 187.9324
Largest Std. dev. 22.26634
75% 204 221
90% 218 222 Variance 495.7899
95% 221 230 Skewness -.0409746
99% 233 233 Kurtosis 2.04156
turn
-------------------------------------------------------------
Percentiles Smallest
1% 31 31
5% 33 32
10% 34 33 Obs 74
25% 36 33 Sum of wgt. 74
50% 40 Mean 39.64865
Largest Std. dev. 4.399354
75% 43 46
90% 45 48 Variance 19.35431
95% 46 48 Skewness .1238259
99% 51 51 Kurtosis 2.229458
displacement
-------------------------------------------------------------
Percentiles Smallest
1% 79 79
5% 86 85
10% 97 86 Obs 74
25% 119 86 Sum of wgt. 74
50% 196 Mean 197.2973
Largest Std. dev. 91.83722
75% 250 350
90% 350 400 Variance 8434.075
95% 350 400 Skewness .5916565
99% 425 425 Kurtosis 2.375577
gear_ratio
-------------------------------------------------------------
Percentiles Smallest
1% 2.19 2.19
5% 2.28 2.24
10% 2.43 2.26 Obs 74
25% 2.73 2.28 Sum of wgt. 74
50% 2.955 Mean 3.014865
Largest Std. dev. .4562871
75% 3.37 3.78
90% 3.72 3.78 Variance .2081979
95% 3.78 3.81 Skewness .2191658
99% 3.89 3.89 Kurtosis 2.101812
Car origin (0 for domestic and 1 for foreign)
-------------------------------------------------------------
Percentiles Smallest
1% 0 0
5% 0 0
10% 0 0 Obs 74
25% 0 0 Sum of wgt. 74
50% 0 Mean .2972973
Largest Std. dev. .4601885
75% 1 1
90% 1 1 Variance .2117734
95% 1 1 Skewness .8869686
99% 1 1 Kurtosis 1.786713
Kilometers per liter
-------------------------------------------------------------
Percentiles Smallest
1% 5.1 5.1
5% 5.95 5.1
10% 5.95 5.95 Obs 74
25% 7.65 5.95 Sum of wgt. 74
50% 8.5 Mean 9.051351
Largest Std. dev. 2.458839
75% 10.625 14.45
90% 12.325 14.875 Variance 6.045888
95% 14.45 14.875 Skewness .9487175
99% 17.425 17.425 Kurtosis 3.975004
histogram mpg
(bin=8, start=12, width=3.625)
histogram mpg, normal
(bin=8, start=12, width=3.625)
histogram mpg, kdensity kdenopts(gaussian)
(bin=8, start=12, width=3.625)
graph pie, over(foreign)
graph box mpg, over(foreign)
graph hbox mpg, over(foreign)
regress mpg weight foreign
Source | SS df MS Number of obs = 74
-------------+---------------------------------- F(2, 71) = 69.75
Model | 1619.2877 2 809.643849 Prob > F = 0.0000
Residual | 824.171761 71 11.608053 R-squared = 0.6627
-------------+---------------------------------- Adj R-squared = 0.6532
Total | 2443.45946 73 33.4720474 Root MSE = 3.4071
------------------------------------------------------------------------------
mpg | Coefficient Std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
weight | -.0065879 .0006371 -10.34 0.000 -.0078583 -.0053175
foreign | -1.650029 1.075994 -1.53 0.130 -3.7955 .4954422
_cons | 41.6797 2.165547 19.25 0.000 37.36172 45.99768
------------------------------------------------------------------------------
regress mpg c.weight##i.foreign
Source | SS df MS Number of obs = 74
-------------+---------------------------------- F(3, 70) = 51.99
Model | 1686.54824 3 562.182746 Prob > F = 0.0000
Residual | 756.911221 70 10.8130174 R-squared = 0.6902
-------------+---------------------------------- Adj R-squared = 0.6770
Total | 2443.45946 73 33.4720474 Root MSE = 3.2883
------------------------------------------------------------------------------
mpg | Coefficient Std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
weight | -.0059751 .0006622 -9.02 0.000 -.0072958 -.0046544
|
foreign |
foreign | 9.271333 4.500409 2.06 0.043 .2955505 18.24711
|
foreign#|
c.weight |
foreign | -.0044509 .0017846 -2.49 0.015 -.0080101 -.0008916
|
_cons | 39.64696 2.243364 17.67 0.000 35.17272 44.12121
------------------------------------------------------------------------------
margins foreign, at(weight=(2000 2500 3000 3500 4000))
Adjusted predictions Number of obs = 74
Model VCE: OLS
Expression: Linear prediction, predict()
1._at: weight = 2000
2._at: weight = 2500
3._at: weight = 3000
4._at: weight = 3500
5._at: weight = 4000
------------------------------------------------------------------------------
| Delta-method
| Margin std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
_at#foreign |
1#domestic | 27.6968 .9841848 28.14 0.000 25.7339 29.65969
1#foreign | 28.06638 .8749718 32.08 0.000 26.32131 29.81146
2#domestic | 24.70926 .7076071 34.92 0.000 23.29798 26.12053
2#foreign | 22.8534 .7645723 29.89 0.000 21.32851 24.37829
3#domestic | 21.72171 .5020333 43.27 0.000 20.72044 22.72299
3#foreign | 17.64042 1.332931 13.23 0.000 14.98198 20.29887
4#domestic | 18.73417 .471814 39.71 0.000 17.79317 19.67518
4#foreign | 12.42745 2.083742 5.96 0.000 8.271553 16.58334
5#domestic | 15.74663 .6422001 24.52 0.000 14.4658 17.02746
5#foreign | 7.214467 2.877568 2.51 0.014 1.475338 12.9536
------------------------------------------------------------------------------
marginsplot
Variables that uniquely identify margins: weight foreign