You are on page 1of 23

Econometrics I

Nicolás Corona Juárez Ph.D


14.10.2020
Stata

• This Stata- Handout aim is to provide you with an overview of the software used
in our course.

• I will be describing the way in which Stata works with the Aid for Health-Children
Mortality example of class.

• We need to know first the different types of screens in Stata.


This is the main
Stata Screen.
Here you will see your
estimations and all
type of actions you
ask Stata to do.
Instructions window:
• It replicates each of
the actions you
have ordered Stata
to perform.
• We are not going to
be that much
interested in using
it.
• I will show you in
class one example
of its use.
Variables window:
• It will show the list
of variables
contained in your
dataset after you
have uploaded it.
• Each variable has a
“Name” and a
“Label”.
• Name: this one is
used for model
estimation.
• Label: it shows a
definition for the
variable.
Properties window:
• It describes the
properties of each
variable individually
once it has been
selected.
• Variable properties
are Name of the
variable and type
etc.
• Type: Stata
recognizes when
one variable is a
numerical variable
or a string variable.
• String variable:
Entry of non-
numerical data.
How do we upload data in Stata?

• We can do it directly in the Command Window (not recommended)…. or….


• We can use a Do-file to upload the data.

• Disadvantage of using the Command Window: You can not save your work and
keep track of what you are doing.

• Instead, the Do-file provides you with a way to save your work.
What is a Do-file?

• The Do-file is a list of orders from us to Stata.


• Basically we tell Stata what to do with the data:
- Upload data
- Merge or append data
- Clean data: delete, rename or replace data
- Estimate models.

Advantage: We can save the Do-file.


Writing a Do-file is like a type of “programming” in Stata.
Programming in Stata

• Stata uses a programming language called “Mata”.


• This programming language works with vectors and matrices.
• Programming with Mata requires a deeper knowledge of Stata.
• For instance, we can design Stata-commands on our own if we know Mata.

• Stata-commands: User´s orders given to Stata.


• Examples:
a. The OLS estimator requires the command "𝒓𝒆𝒈“.
b. The commands for uploading data are: "𝒖𝒔𝒆“ and "𝒊𝒏𝒔𝒉𝒆𝒆𝒕" .
Starting a Do-file
1. Go to the main
menu and select
“window.”
2. Select the option
“Do-file editor.”
3. You will see there a
small side-window
“New Do-file
editor”.
4. Click on that.
The Do-file
• This is the Do-file window.
• On it you will be writing the
Stata commands (i.e. orders).
• Basically, in the Do-file you tell
Stata what to do.
The data editor

You can access the


data editor by clicking
on either one of these
two icons.
Data Editor
• It will show the
dataset.
• Each column will
contain the data for
each of the
variables used in
your analysis.

• The columns can


also contain the
names of the units
of analysis under
study (i.e. cities,
countries, firms,
households, etc.
Stata: learning by doing an applied exercise

• Let us retake the class example on the effectiveness of Aid for Health on Children
Mortality.
• Dependent variable: Children Mortality = 𝑌𝑖
• Control variable of interest: 𝐴𝑖𝑑 𝑓𝑜𝑟 𝐻𝑒𝑎𝑙𝑡ℎ = 𝐴𝑖𝑑𝐻𝑖
• Other control variables:

𝑃𝑜𝑝𝑢𝑙𝑎𝑡𝑖𝑜𝑛 = 𝑃𝑜𝑝𝑖
𝐺𝐷𝑃 = 𝐺𝐷𝑃𝑖

Note: For simplicity consider only those two control variables.


𝐼𝑑𝑝𝑏 = 𝛽መ1 + 𝛽መ2 𝑝𝑖𝑏𝑖 + 𝑢ො 𝑖
Scales and measurement units
𝑌𝑖 = 𝛽መ1 + 𝛽መ2 𝑋𝑖 + 𝑢ො 𝑖
Do the results from a regression model change if
we change the units of measurement? Idpb1: Private Domestic Investment (Gross)
(Billions of US Dollars as of 2000)
(Miles de Millones de dólares de 2000)

pib1: GDP
(Billions of US Dollars as of 2000)
(Miles de Millones de dólares de 2000).

Idpb2: Private Domestic Investment (Gross)


(Millons of dollars as of 2000)
(Millones de dólares de 2000)

pib2: GDP
(Millons of dollars as of 2000)
(Millones de dólares de 2000)

16
1. Model in Billions of US 3. Is there any difference in 2. Model in Millions of
Dollars both results? dollars

Model 1 Model 2

4. The intercept and its 4. The intercept and its


standard error have been standard error are
divided by 1000 compared 1000 times the values of
to model 2. model 1.
17
Model in Billions of US Model 1
Dollars

The slope is 0.2535

If the GDP changes in a unit of


1000 millions of dollars,
the Private Domestic
Investment
changes on average 0.2535
Billions of US Dollars.

18
1. Model with Y in Billions of 3. Is there any difference in 2. Model with Y in Millions of
dollars and X in Millions of dollars and X in Billions of dollars
both results?
dollars

Model 3 Model 4

4. The slope and its 4. The intercept, the slope


standard error have been and their standard errors
multiplied by (1/1000) are 1000 times the values
compared to model 1. of model 1.

19
Scales and measurement units

• In general, the model is: 𝑌𝑖 = 𝛽መ1 + 𝛽መ2 𝑋𝑖 + 𝑢ො 𝑖

• Define 𝑤1 and 𝑤2 to be some constants (these are the “scaling factors”).

• Both could be equal or not.

• Using those constants:

𝑌𝑖∗ = 𝑤1 𝑌𝑖
𝑋𝑖∗ = 𝑤2 𝑋𝑖

20
Scales and measurement units

𝑌𝑖 Measured in billions of dollars 𝑌𝑖∗ Measured in millions of dollars


𝑋𝑖 Measured in billions of dollars 𝑋𝑖∗ Measured in millions of dollars

𝑌𝑖∗ = 1000𝑌𝑖
𝑋𝑖∗ = 1000𝑋𝑖

Transformed Model

𝑌𝑖∗ = 𝛽መ1∗ + 𝛽መ2∗ 𝑋𝑖∗ + 𝑢ො 𝑖∗

21
Scales and measurement units: Final comment

If we change the scale of 𝑌, 𝑋 to the scale 𝑌 ∗ , 𝑋 ∗ the properties of the OLS


estimators are not affected.

22
Reference

Author: These notes have been prepared by myself.

23

You might also like