Stata Tutorial. 1 Introduction. 1.1 Stata Windows and toolbar. Econometrics676, Spring2008



Similar documents
Basics of STATA. 1 Data les. 2 Loading data into STATA

Descriptive Statistics

Linear Regression. use waist

SPSS Tutorial, Feb. 7, 2003 Prof. Scott Allard

A Short Guide to Stata 13

Data Analysis Stata (version 13)

SPSS: Getting Started. For Windows

Getting started with the Stata

ECONOMICS 351* -- Stata 10 Tutorial 2. Stata 10 Tutorial 2

Appendix III: SPSS Preliminary

SHORT COURSE ON Stata SESSION ONE Getting Your Feet Wet with Stata

Trade Flows and Trade Policy Analysis. October 2013 Dhaka, Bangladesh

Introduction to Stata... 2 Stata Sessions Running Stata in Batch Mode...2 Running Stata Interactively...3 Data Management...

Scatter Plots with Error Bars

There are six different windows that can be opened when using SPSS. The following will give a description of each of them.

10 Listing data and basic command syntax

Introduction to STATA 11 for Windows

Using SPSS, Chapter 2: Descriptive Statistics

The Center for Teaching, Learning, & Technology

Data analysis and regression in Stata

INTRODUCTORY LAB: DOING STATISTICS WITH SPSS 21

Before You Begin... 2 Running SAS in Batch Mode... 2 Printing the Output of Your Program... 3 SAS Statements and Syntax... 3

Important Things to Know about Stata

How Does My TI-84 Do That

Introduction to SPSS 16.0

Polynomial Neural Network Discovery Client User Guide

From the help desk: Swamy s random-coefficients model

MS WORD 2007 (PC) Macros and Track Changes Please note the latest Macintosh version of MS Word does not have Macros.

R with Rcmdr: BASIC INSTRUCTIONS

Introduction Course in SPSS - Evening 1

(Least Squares Investigation)

ACCESS 2007 BASICS. Best Practices in MS Access. Information Technology. MS Access 2007 Users Guide. IT Training & Development (818)

This activity will show you how to draw graphs of algebraic functions in Excel.

SPSS 12 Data Analysis Basics Linda E. Lucek, Ed.D

Doing Multiple Regression with SPSS. In this case, we are interested in the Analyze options so we choose that menu. If gives us a number of choices:

System Administration and Log Management

IBM SPSS Statistics 20 Part 4: Chi-Square and ANOVA

An introduction to IBM SPSS Statistics

CentralMass DataCommon

IBM SPSS Statistics 20 Part 1: Descriptive Statistics

SPSS Manual for Introductory Applied Statistics: A Variable Approach

Univariate Regression

Getting Started with Tableau Server 6.1

Getting Started With SPSS

SPSS Introduction. Yi Li

Quick Start to Data Analysis with SAS Table of Contents. Chapter 1 Introduction 1. Chapter 2 SAS Programming Concepts 7

Introduction to SPSS (version 16) for Windows

Module 2 Basic Data Management, Graphs, and Log-Files

Easy Setup Guide for the Sony Network Camera

INTRODUCTION TO SPSS FOR WINDOWS Version 19.0

To Begin Customize Office

EXCEED IEP Goals Product Screen

How to set the main menu of STATA to default factory settings standards

Scientific Graphing in Excel 2010

How to test and debug an ASP.NET application

JAVASCRIPT AND COOKIES

How To Use Spss

Activity 5. Two Hot, Two Cold. Introduction. Equipment Required. Collecting the Data

Data Analysis. Using Excel. Jeffrey L. Rummel. BBA Seminar. Data in Excel. Excel Calculations of Descriptive Statistics. Single Variable Graphs

Display Options in Transaction SE16

Instat Tutorial. by Roger Stern, Sandro Leidi, Ian Dale and Colin Grayer. Contents. Installation 2

Quick Stata Guide by Liz Foster

2: Entering Data. Open SPSS and follow along as your read this description.

CHARTS AND GRAPHS INTRODUCTION USING SPSS TO DRAW GRAPHS SPSS GRAPH OPTIONS CAG08

IBM SPSS Data Preparation 22

KSTAT MINI-MANUAL. Decision Sciences 434 Kellogg Graduate School of Management

MetroBoston DataCommon Training

To begin, visit this URL:

Microsoft Excel 2010 Part 3: Advanced Excel

A Short Guide to R with RStudio

quick start guide A Quick Start Guide inflow Support GET STARTED WITH INFLOW

Set Top Box User Guide. Global Reach with a Local Touch

Directions for Frequency Tables, Histograms, and Frequency Bar Charts

PharmaSUG Paper QT26

Creating an Excel XY (Scatter) Plot

Searching for jobs. The quick search provides a simple form on the home page that is quick to use at any stage.

Efficient and effective management of big databases in Stata

R Commander Tutorial

Summary of important mathematical operations and formulas (from first tutorial):

Curve Fitting in Microsoft Excel By William Lee

Directions for using SPSS

Describing, Exploring, and Comparing Data

Straightening Data in a Scatterplot Selecting a Good Re-Expression Model

AvMed s Physician-to- Physician Referral Program

SonicWALL GMS Custom Reports

EXST SAS Lab Lab #4: Data input and dataset modifications

Bill Burton Albert Einstein College of Medicine April 28, 2014 EERS: Managing the Tension Between Rigor and Resources 1

Pearson's Correlation Tests

Adding Links to Resources

Wooldridge, Introductory Econometrics, 4th ed. Chapter 7: Multiple regression analysis with qualitative information: Binary (or dummy) variables

ECON 142 SKETCH OF SOLUTIONS FOR APPLIED EXERCISE #2

Introduction to Word 2007

Forecasting in STATA: Tools and Tricks

Using This Reference Manual Chapter 1 to Issue ACL Commands

Using the JNIOR with the GDC Digital Cinema Server. Last Updated November 30, 2012

Excel Tutorial. Bio 150B Excel Tutorial 1

Transcription:

1 Introduction Stata Tutorial Econometrics676, Spring2008 1.1 Stata Windows and toolbar Review : past commands appear here Variables : variables list Command : where you type your commands Results : results are displayed here 1.1.1 Toolbar log: start / stop a log le viewer: open viewer window results: open results window graph: open graph window do- le editor: open do- le editor data editor data browser more: continue when paused in long output break: stop the current task 1

1.2 Stata File management 1.2.1 FILES EXTENTIONS Data le lename.dta Do le lename.do (program le) Log le lename.scml (only readable in stata) lename.log (text le) 1.2.2 WORKING DIRECTORY The working directory displayed at the bottom left hand corner of the window. To change your working directory, use the cd command cd c:n dir To open a le use lename, clear use varlist using lename, clear for a subset of the data le To save a data le save, replace save lename, replace 1.2.3 MEMORY save "c:nexample1.dta", replace STATA opens with a default memory of 1m. overwrites current le saves le as lename. Replace is optional but necessary if a le of that name already exists In some cases you may get the message no room to add more observations This is because not enough memory has been assigned to STATA. To change the memory assigned to STATA: set mem #m 1.2.4 LOG FILES set mem 16m All output appearing in the Results window can be can be captured in a log le. The log le can be saved as a STATA formatted (SMCL) or as a text le. By default, logs are written in SMCL (Stata Markup and Control Language). 2

To translate a log le created in smcl to text, go to nfilenlogntranslate To start a log log using lename log using lename, replace log using lename.log starts an smcl log overwrites lename.smcl starts a text log To pause and resume a log log o temporarily suspends log le log on resumes log le These commands can be useful to create a log that contains only results and not intermediate programming. To close a log log close closes current log le You can add comments to your log as you work by entering any comments in the command line (or in your do- le) preceded by a * *unemployment rate 1.2.5 CONTROLLING OUTPUT -moremay appear in your results window when you are trying to output a long listing To see the next line: press Enter To see the next screen: press any key or click on the more- To interrupt a STATA command at any time uses the Break button 2 Manupulating Data 2.1 Destrictive Commands 2.1.1 Describe There are various ways of examining a dataset in Stata, including describe, list, and summarise. produces a summary of the contents of a dataset d d using lename d varlist describes dataset in current memory describes a stored STATA format dataset describe a subset of a dataset 3

2.1.2 Summarise summarize statistics su su varlist su varlist, d calculates and displays a variety of univariate summarise whole dataset summarise subset varlist summarise with the detail command 2.1.3 List most detailed of the commonly used descriptive commands. L displays the values of variables 2.1.4 Graph twoway plot_type varl1 var2 draws scatterplots, line plots, etc Plot type: Scatter, Line, Connected twoway scatter lincome lincomea, t1("graph 1") 2.1.5 SORT and BY Commands sort varlist by varlist : sort region Arranges the observations of the current data into ascending order of the values of the variables of varlist causes the command that follows to be repeated for each unique set of values of the variables in varlist 1 by region: su income (Note) Data must be sorted by varlist, before you use by command. 2.1.6 Cross Tabulation tabulate tab var1 var2 [weight] [if exp] produces one- and two-way tables of frequency counts 2.2 Creating New Variables Generate can create a new variable that is an algebraic expression of other variables. gen newvar = expression 4

To change the contents of an existing variable you must use the replace command. replace oldvar = expression gen agerange =. if age<16 replace agerange=1 if 16<=age & age<25 replace agerange=2 if 25<= age & age<45 gen age16=0 replace age16=1 if age==16 Values for a string variable are denoted by inverted commas gen age= young if agerange==1 replace age= if agerange~=1 The default code for a missing value in STATA is a single period (.) or a blank in the case of a string. replace var =. if var == 99 replace string = if string == not answered 3 Linear Regression regress y X [, noconstant robust] estimates a linear regression y = c + X + predict [type] newvar calculates predictions, residuals and statistics after estimation predict_type xb res stdp Linear prediction (default) residual standard error of prediction reg lwage exper age kid reg lwage exper age kids, robust reg lwage exper age kids, nocons predict u, res (Robust Estimation) (No constant term) (save u=residual) 5

3.1 Ivreg Instrumental variables (two-stage least-squares) regression Syntax ivreg depvar [varlist1] (varlist2 = varlist_iv) [if] [in] [weight] [, options] ivreg y1 x1 x2 (y2 y3 = z1 z2 z3) ivreg y1 x1 x2 (y2 = z1 z2 z3) x3 test x3=5 test y2=x3-x2 predict y1hat 3.2 Hypothesis Testing ttest var t tests test varlist F tests ttest income=180, level(99) ttest group1_income=group2_income ttest income, by(male) test exper age kids 4 Stata Resources Stata Textbook s Econometric Analysis of Cross Section and Panel Data by Je rey M. Wooldridge http : ==www:ats:ucla:edu=stat=stata=examples=eacspd= UCLA Stata Starter Kit http : ==www:ats:ucla:edu=stat=stata= 6