Chapter 01 - The Nature of Econometrics and Economic Data#

import stata_setup
stata_setup.config("C:/Program Files/Stata18/", "se", splash=False)

Problem C1#

i Average, minimum and maximum years of education

%%stata
use wage1.dta, clear
sum educ
. use wage1.dta, clear

. sum educ

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

. 

ii Average hourly wage

%%stata
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 07112018

v. How many women? men?

%%stata
d female
count  if female==1
count if female==0 
. d female

Variable      Storage   Display    Value
    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#

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

%%stata
use bwght.dta, clear
d cigs
count  if cigs>0
display _N
. use bwght.dta, clear

. d cigs

Variable      Storage   Display    Value
    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

%%stata
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

%%stata
sum cigs  if cigs>0 
    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
        cigs |        212    13.66509    8.690907          1         50

iv. Average fatheduc

%%stata
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

%%stata
sum faminc
    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
      faminc |      1,388    29.02666    18.73928         .5         65

Problem C3#

i. max & min of math4

vi. Average and SD of exppp sum exppp display r(mean) ” and ” r(sd) vii. %age comaparison display 100[(6000-5500)/5500] display 100[ln(6000)-ln(5500)]

%%stata
u meap01, clear
sum math4
. u meap01, clear
(Written by R.              )

. 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?

%%stata
count if math4==100 
display _N
. count if math4==100 
  38

. display _N
1823

. 

iii. exactly 50%?

%%stata
count if math4==50 
  17

iv. Average pass rate for math4 & read4

%%stata
mean 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

%%stata
corr math4 read4 
(obs=1,823)

             |    math4    read4
-------------+------------------
       math4 |   1.0000
       read4 |   0.8427   1.0000

Problem C4#

i. Fraction of men receiving job training

%%stata
u jtrain2.dta, clear
d train
mean train
. u jtrain2.dta, clear

. d train

Variable      Storage   Display    Value
    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

%%stata
sum re78 if train==1 
sum re78 if train==0
. 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.

%%stata

d unem78 
count if train==1 & unem78==1
count if train==1
display 45/85
count if train==0 & unem78==1
count if train==0
display 92/260
. 
. d unem78 

Variable      Storage   Display    Value
    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#

i. Max, min & mean of children

%%stata
u fertil2, clear
sum children
. u fertil2, clear

. sum children

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

. 

ii. Percentage of Women who have electricity

%%stata
count if electric==1
display 100*r(N)/_N "%"
. count if electric==1
  611

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

. 

iii. Average of children for women who have and have not electricity

%%stata
mean children if electric==1
mean children if electric==0
. 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#

i. How many countries in total? how many with zero murders

%%stata
u countymurders, clear
keep if year==1996
display _N
count if murders==0 
. u countymurders, clear
(Written by R.              )
. keep if year==1996
(35,152 observations deleted)

. display _N
2197

. count if murders==0 
  1,051

. 

ii. Maximum murders? Maximum executions? Average executions?

%%stata
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

%%stata
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#

i. %age of men abusing alcohol? employment rate?

%%stata
u alcohol, clear
sum abuse
display 100*r(mean) "%"
sum unem
display 100-r(mean) "%"
. u alcohol, clear
(Written by R.              )

. 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?

%%stata
sum unem if abuse==1
display 100-r(mean) "%"
. 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

%%stata
sum unem if abuse==0
display 100-r(mean) "%"
. 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).