﻿ Chapter 1 - The Nature of Econometrics and Economic Data - Computer Exercises

Chapter 1 - The Nature of Econometrics and Economic Data - Computer Exercises

```-------------------------------------------------------------------------------------
name:  SN
log:  ~Wooldridge\intro-econx\iproblem1.smcl
log type:  smcl
opened on:  23 Jan 2019, 01:20:58

. **********************************************
. * Solomon Negash - Solutions to Computer Exercises
. * Wooldridge (2016). Introductory Econometrics: A Modern Approach. 6th ed.
. * STATA Program, version 15.1.

. * Chapter 1  - The Nature of Econometrics and Economic Data
. * Computer Exercises (Problems)
. ******************** SETUP *********************

. **Problem.C1
. use wage1.dta, clear

. *i Average, minimum and maximum years of education
. sum educ

Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
educ |        526    12.56274    2.769022          0         18

. *ii Average hourly wage
. mean wage

Mean estimation                   Number of obs   =        526

--------------------------------------------------------------
|       Mean   Std. Err.     [95% Conf. Interval]
-------------+------------------------------------------------
wage |   5.896103   .1610262      5.579768    6.212437
--------------------------------------------------------------

. *iii. CPI_1976 = 56.9  CPI_2010 = 218.056.  Source: usinflationcalculator.com accessed 071118
. *iv.
. *v. How many women? men?
. describe female

storage   display    value
variable name   type    format     label      variable label
-------------------------------------------------------------------------------------
female          byte    %8.0g                 =1 if female

. count  if female==1
252

. count if female==0
274

. **Problem.C2
. use bwght.dta, clear

. *i. Women in the sample? how many women smoking during pregnancy?
. ddescribe cigs

storage   display    value
variable name   type    format     label      variable label
-------------------------------------------------------------------------------------
cigs            byte    %8.0g                 cigs smked per day while preg

. count  if cigs>0
212

. display _N
1388

. *ii. Average cigs
. mean cigs

Mean estimation                   Number of obs   =      1,388

--------------------------------------------------------------
|       Mean   Std. Err.     [95% Conf. Interval]
-------------+------------------------------------------------
cigs |   2.087176   .1603153      1.772689    2.401663
--------------------------------------------------------------

. *iii. Average cigs among smoking women
. sum cigs  if cigs>0

Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
cigs |        212    13.66509    8.690907          1         50

. *iv. Average fatheduc
. sum fatheduc

Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
fatheduc |      1,192    13.18624    2.745985          1         18

. *v. Average and Standard deviation of Family income
. sum faminc

Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
faminc |      1,388    29.02666    18.73928         .5         65

. **Problem.C3
. u meap01, clear
(Written by R.              )

. *i. max & min of math4
. sum math4

Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
math4 |      1,823      71.909    19.95409          0        100

. *ii. How many schools (%) have a perfect pass rate of math4?
. count if math4==100
38

. display _N
1823

. *iii. exactly 50%?
. count if math4==50
17

. *iv. Average pass rate for math4 & read4

Mean estimation                   Number of obs   =      1,823

--------------------------------------------------------------
|       Mean   Std. Err.     [95% Conf. Interval]
-------------+------------------------------------------------
math4 |     71.909   .4673461      70.99241    72.82559
read4 |   60.06188     .44845      59.18235    60.94141
--------------------------------------------------------------

. *v. Correlation between math4 & read4
(obs=1,823)

-------------+------------------
math4 |   1.0000

. *vi. Average and SD of exppp
. sum exppp

Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
exppp |      1,823    5194.865     1091.89   1206.882   11957.64

. display r(mean) " and " r(sd)
5194.8655 and 1091.8896

. *vii. %age comaparison
. display 100*[(6000-5500)/5500]
9.0909091

. display 100*[ln(6000)-ln(5500)]
8.7011377

. **Problem.C4
. u jtrain2.dta, clear

. *i. Fraction of men receiving job training
. d train

storage   display    value
variable name   type    format     label      variable label
-------------------------------------------------------------------------------------
train           byte    %9.0g                 =1 if assigned to job training

. mean train

Mean estimation                   Number of obs   =        445

--------------------------------------------------------------
|       Mean   Std. Err.     [95% Conf. Interval]
-------------+------------------------------------------------
train |   .4157303   .0233895      .3697624    .4616982
--------------------------------------------------------------

. *ii. Average re78 for men receiving and not receiving job training
. sum re78 if train==1

Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
re78 |        185    6.349145    7.867405          0    60.3079

. sum re78 if train==0

Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
re78 |        260    4.554802    5.483837          0    39.4835

. *iii.
. d unem78

storage   display    value
variable name   type    format     label      variable label
-------------------------------------------------------------------------------------
unem78          byte    %9.0g                 =1 if unem. all of 1978

. count if train==1 & unem78==1
45

. count if train==1
185

. display 45/85
.52941176

. count if train==0 & unem78==1
92

. count if train==0
260

. display 92/260
.35384615

. *iv. was the job training program effective?

. **Problem.C5
. u fertil2, clear

. *i. Max, min & mean of children
. sum children

Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
children |      4,361    2.267828    2.222032          0         13

. *ii. %age of Women who have electricity
. count if electric==1
611

. display 100*r(N)/_N "%"
14.010548%

. *iii. Average of children for women who have and have not electricity
. mean children if electric==1

Mean estimation                   Number of obs   =        611

--------------------------------------------------------------
|       Mean   Std. Err.     [95% Conf. Interval]
-------------+------------------------------------------------
children |   1.898527   .0729547      1.755254      2.0418
--------------------------------------------------------------

. mean children if electric==0

Mean estimation                   Number of obs   =      3,747

--------------------------------------------------------------
|       Mean   Std. Err.     [95% Conf. Interval]
-------------+------------------------------------------------
children |   2.327729   .0372054      2.254784    2.400674
--------------------------------------------------------------

. *iv. can you infer that having electricity “causes” women to have fewer children?

. **Problem.C6
. u countymurders, clear
(Written by R.              )

. keep if year==1996
(35,152 observations deleted)

. *i. How many countries in total? how many with zero murders
. display _N
2197

. count if murders==0
1,051

. *ii. Maximum murders? Maximum executions? Average executions?
. sum murders execs

Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
murders |      2,197    6.390077    39.76102          0       1403
execs |      2,197    .0159308      .14226          0          3

. *iii. Correlation rate between murders & execs
. corr murders execs
(obs=2,197)

|  murders    execs
-------------+------------------
murders |   1.0000
execs |   0.2095   1.0000

. *iv. Do you think that more executions cause more murders to occur?

. **Problem.C7
. u alcohol, clear
(Written by R.              )

. *i. %age of men abusing alcohol? employment rate?
. sum abuse

Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
abuse |      9,822    .0991651    .2988988          0          1

. display 100*r(mean) "%"
9.9165139%

. sum unem

Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
unemrate |      9,822    5.569212    1.505064        2.8       10.9

. display 100-r(mean) "%"
94.430788%

. *ii. Emplyment rate for alcohol abusers?
. sum unem if abuse==1

Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
unemrate |        974    5.515708    1.507293        2.8       10.9

. display 100-r(mean) "%"
94.484292%

. *iii. Emplyment rate for non-abusers
. sum unem if abuse==0

Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
unemrate |      8,848    5.575102    1.504787        2.8       10.9

. display 100-r(mean) "%"
94.424898%

. *iv. Discuss the difference in answers to parts(ii) and (iii).

. log close
name:  SN
log:  ~Wooldridge\intro-econx\iproblem1.smcl
log type:  smcl
closed on:  23 Jan 2019, 01:20:58
-------------------------------------------------------------------------------------
```