api-208: stata review session

31
API-208: Stata Review Session Daniel Yew Mao Lim Harvard University Spring 2013

Upload: debbie

Post on 23-Feb-2016

45 views

Category:

Documents


0 download

DESCRIPTION

API-208: Stata Review Session. Daniel Yew Mao Lim Harvard University Spring 2013. Roadmap. Getting Started. Importing Data. Data management. Data analysis. Programming. Getting Started: Orientation. REVIEW WINDOW : past commands appear here. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: API-208:  Stata  Review Session

API-208: Stata Review Session

Daniel Yew Mao LimHarvard University

Spring 2013

Page 2: API-208:  Stata  Review Session

Roadmap

Importing Data

Data analysisData management

ProgrammingGetting Started

Page 3: API-208:  Stata  Review Session

Getting Started: Orientation

COMMAND WINDOW: commands typed here

VARIABLES WINDOW: variable list shown here

RESULTS WINDOW: results and commands displayed here

REVIEW WINDOW: past commands appear here

Page 4: API-208:  Stata  Review Session

Getting Started: Syntax

Page 5: API-208:  Stata  Review Session

Getting Started: Syntax Example

Page 6: API-208:  Stata  Review Session

Getting Started: Syntax Example

Page 7: API-208:  Stata  Review Session

Getting Started: Useful Commands I

if

in

by

sum

help

ssc install

Page 8: API-208:  Stata  Review Session

Getting Started: Useful Commands II

Arithmetic Operators

• “+” addition• “-” subtraction• “*” multiplication• “/” division• “^” power

Page 9: API-208:  Stata  Review Session

Getting Started: Useful Commands III

Relational Operators

• “>” Greater than• “<” Less than• “>=” Equal or greater than• “<=” Equal or less than• “==” Equal to• “~=” Not equal to• “!=” Not equal to

Page 10: API-208:  Stata  Review Session

Getting Started: Useful Commands IV

Logical (Boolean) Operators

• “&” = and– Example: A & B

• “|” = or– Example: A | B

A

A B

B

Page 11: API-208:  Stata  Review Session

Getting Started: Example

Page 12: API-208:  Stata  Review Session

Getting Started: Worked Example

Average share of ADB loans during first and second years on UNSCBetween 1985 and 2004

Average share of ADB loans during first and second years on UNSCBetween 1985 and 2004, for each country

Page 13: API-208:  Stata  Review Session

Getting Started: Creating Do-files

Text file containing all commands relevant to analysis

Useful for batch processing

Page 14: API-208:  Stata  Review Session

Getting Started: Creating Do-files

Page 15: API-208:  Stata  Review Session

Getting Started: Commenting in Do-files

* Ignore stuff written on this line

/* Text Here*/ Ignore stuff written in between

Page 16: API-208:  Stata  Review Session

Getting Started: Commenting in Do-files

Page 17: API-208:  Stata  Review Session

Importing Data: Data Types

Stata Data .xls .csv

Page 18: API-208:  Stata  Review Session

Data Management: Data Structure

Cross-sectional Time-series Panel

Page 19: API-208:  Stata  Review Session

Data Management: Datasets

• merge: add variables across datasets.• append: add observations across datasets.• reshape: convert data from wide/long or

long/wide• rename: change the name of a variable.• drop: eliminate variables or observations.• keep: keep variables or observations.• sort: arrange into ascending order.

Page 20: API-208:  Stata  Review Session

Data Management: Missing Data

Recode List-wise deletion

Multiple Imputation

Page 21: API-208:  Stata  Review Session

Data Management: Outliers

Impossible values

Extreme values

Logarithmic function

Page 22: API-208:  Stata  Review Session

Data Management: Modifying Data

generate: create new variable.replace: replace old values.recode: change values by conditions.label define: defines value labels (or

“dictionary”).label values: attaches value labels (or

“dictionary”) to a variable.

Page 23: API-208:  Stata  Review Session

Data Analysis: Exploring Data

• summarize: descriptive statistics.• codebook: display contents of variables.• describe: display properties of variables.• count: counts cases.• list: show values.

Page 24: API-208:  Stata  Review Session

Data Analysis: Analyzing Data

• tabstat: tables with statistics.• tabulate: one- or two-way frequency tables

(related: tab1 and tab2).• table: calculates and displays tables of

statistics.

Page 25: API-208:  Stata  Review Session

Data Analysis: Worked Example

Exercise 1: Create an aidsize variable with three categories based on the amount of ADB loans received (adbconstant): small (0 to 99), medium (100 to 999), and large (1000 or more). Include labels.

Page 26: API-208:  Stata  Review Session

Data Analysis: MLE

• regress: standard OLS.• Probit/logit: binary dependent variable.• oprobit: ordered probit regression.• ologit: ordered logistic regression.• xtreg: fixed, between, and random effects, and

population averaged linear models.• xtregar: fixed and random effects models with

AR(1) disturbance.

Page 27: API-208:  Stata  Review Session

Data Analysis: Matching

• psmatch2: propensity score matching.• cem: coarsened exact matching.

Page 28: API-208:  Stata  Review Session

Data Analysis: Interpreting Coefficients

Page 29: API-208:  Stata  Review Session

Programming

Page 30: API-208:  Stata  Review Session

Conclusion

Pattern recognition Self-learning Programming

Page 31: API-208:  Stata  Review Session

Q&A

Thank you!