Beruflich Dokumente
Kultur Dokumente
STARTED WITH
STATA
Sbastien Fontenay
ECON - IRES
THE
SOFTWARE
www.uclouvain.be/438229.html
FINDING
SUPPORT (1)
Best documentation
help command
search keyword
Books
Cahuzac, E., Bontemps, C. (2008). Stata par la pratique: Statistiques,
graphiques et lments de programmation.
Cameron, A.C., Trivedi, P.K. (2009). Microeconometrics using Stata.
Becketti, S. (2013). Time series using Stata.
UCLA : www.ats.ucla.edu/stat/stata
FINDING
SUPPORT (2)
COURSE
Quick tour of
Stata
Working environment
Writing commands
Data
management
Inputting data
Transforming data
Data analysis
Descriptive statistics
Linear regression
Exporting results
TOPICS
SECTION 1
Working environment
Writing commands
WORKING
ENVIRONMENT
Results
of commands
Variables
list and labels
Review
Properties
of commands
of variables and
dataset
Command
window
WORKING
ENVIRONMENT
Viewer
Display log and help files
Do-file Editor
Text editor to save/execute commands
WORKING
Data
ENVIRONMENT
Graphics
Statistics
WORKING
ENVIRONMENT
You can see the current working directory at the bottom left of the main window
log close
log off | on
SECTION 1
Working environment
Writing commands
WRITING
COMMANDS
WRITING
COMMANDS
Arithmetic
Logical
Relational
+
*
/
^
&
|
!
~
>
<
>=
<=
==
~=
!=
addition
subtraction
multiplication
division
raised to power
and
or
not
not
greater than
less than
> or equal
< or equal
equal
not equal
not equal
Pay attention that a double equal sign (==) is used for equality
testing
WRITING
COMMANDS
list
list
list
list
make if foreign==1
if make=="Volvo 260"
make price if price>=5000 & price<=7000
make price if price<5000 | price>7000
WRITING
COMMANDS
1 to 30
1 until last number
first to 5th number before the end
last five numbers
WRITING
COMMANDS
If the dataset is not sorted, you should use the bysort prefix instead
bysort varname: command
SECTION 2
DATA MANAGEMENT
Inputting data
Transforming data
INPUTTING
DATA
INPUTTING
Manipulate variables/observations
keep wage educ exper
drop in 1/10
sort wage
DATA
SECTION 2
DATA MANAGEMENT
Inputting data
Transforming data
TRANSFORMING
DATA
TRANSFORMING
DATA
But before you should tell Stata that you are working with time series
data using the command: tsset
tsset time [, yearly monthly quarterly daily]
TRANSFORMING
DATA
You can also add a brief description to the variable using labels
label variable educ "total years of education"
TRANSFORMING
DATA
Stata treats missing values as large numbers, higher than any other
values of a given variable
In certain cases you should use the if qualifier to exclude missing values
generate rich = (wage>15) if wage<.
|or|
generate rich = (wage>15) if wage!=.
|or|
SECTION 3
DATA ANALYSIS
Descriptive statistics
Linear regression
Exporting results
DESCRIPTIVE
STATISTICS
Categorical variables
One-way table of frequencies
tabulate female
-
Continuous variables
summarize gives the number of observations, the mean, the standard
deviation, the minimum and maximum values
summarize wage educ
-
The option [, detail] displays the main quantiles, the highest and lowest five values, the
variance, as well as the skewness and kurtosis measures
DESCRIPTIVE
STATISTICS
SECTION 3
DATA ANALYSIS
Descriptive statistics
Linear regression
Exporting results
LINEAR
REGRESSION
LINEAR
REGRESSION
In Stata:
regress logwage educ exper tenure
LINEAR
Stata output
REGRESSION
LINEAR
Analysis of variance
Sum of Squares (SS)
Explained variance (model)
Residual variance
Total variance
REGRESSION
LINEAR
REGRESSION
R-squared
proportion of variance in the dependent variable
explained by the independent variables
-
Adjusted R-squared
Standard deviation of the error term
()
LINEAR
REGRESSION
Parameters estimates
Dependent variable (1)
Independent variables and intercept (2)
Coefficients (3)
Standard-errors (4)
t-statistics (5)
p-values associated with the t-statistics (6)
testing the null hypothesis that a given coefficient is 0
(3)
(4)
(5)
(6)
(7)
LINEAR
REGRESSION
predict wage_resid, r
e.g. -0,1735185 = 1,131402 1,304921
logwage
educ
exper
tenure
wage_fitted
wage_resid
1,131402
11
1,304921
-0,1735185
1,175573
12
22
1,523506
-0,3479329
1,098612
11
1,304921
-0,2063083
1,791759
44
28
1,819802
-0,0280429
1,667707
12
1,461690
0,2060172
2,169054
16
1,970451
0,1986027
2,420368
18
15
2,157168
0,2631997
1,609438
12
1,475515
0,1339233
1,280934
12
26
1,584125
-0,3031912
10
2,900322
17
22
21
2,402928
0,4973939
LINEAR
REGRESSION
You can use the prefix ib(x). instead to change the reference category
LINEAR
REGRESSION
Post-estimation tests
Multicollinearity (Wooldridge, 2008 - chapter 3, p99)
estat vif
-
testing the null hypothesis that variable follows a standard normal distribution
swilk|sfrancia varname
-
SECTION 3
DATA ANALYSIS
Descriptive statistics
Linear regression
Exporting results
EXPORTING
RESULTS
EXPORTING
RESULTS