Evaluation of Public Policy

Slides:



Advertisements
Similar presentations
1 Research Methods Lecture 2 The dummies’ guide to STATA Wiji Arulampalam 18/10/2006.
Advertisements

Statistical Methods Lynne Stokes Department of Statistical Science Lecture 7: Introduction to SAS Programming Language.
Stata and logit recap. Topics Introduction to Stata – Files / directories – Stata syntax – Useful commands / functions Logistic regression analysis with.
Microsoft Excel The Basics. spreadsheet A type of application program which manipulates numerical and string data in rows and columns of cells. The value.
 Statistics package  Graphics package  Programming language  Can be used to share/reproduce analyses  Many new packages being created - can be downloaded.
I NTRO TO S TATA James Ng Center for Digital Scholarship Hesburgh Libraries.
Introduction to C Programming
1 An Introduction to IBM SPSS PSY450 Experimental Psychology Dr. Dwight Hennessy.
Introduction to Spreadsheets Presented by Frank H. Osborne, Ph. D. © 2005 Bio 2900 Computer Applications in Biology.
Introduction to SPSS Descriptive Statistics. Introduction to SPSS Statistics Program for the Social Sciences (SPSS) Commonly used statistical software.
A Guide to MySQL 3. 2 Objectives Start MySQL and learn how to use the MySQL Reference Manual Create a database Change (activate) a database Create tables.
Concepts of Database Management Sixth Edition
Getting Started with your data
SPSS 1: An Introduction to the Statistical Package SPSS Suzie Cro MRC Clinical Trials Unit.
SPSS Statistical Package for the Social Sciences is a statistical analysis and data management software package. SPSS can take data from almost any type.
Introduction to SPSS Short Courses Last created (Feb, 2008) Kentaka Aruga.
State of Connecticut Core-CT Project Query 4 hrs Updated 1/21/2011.
Objectives Understand what MATLAB is and why it is widely used in engineering and science Start the MATLAB program and solve simple problems in the command.
P366: Lecture #1 Use of Excel for analysis Lei Chen, MD Jan 6, 2002.
Spreadsheets and Non- Spatial Databases Unit 4: Module 15, Lecture 1- Spreadsheet Software.
Copyright © 2008 Pearson Prentice Hall. All rights reserved. 1 1 Copyright © 2008 Prentice-Hall. All rights reserved. What Can I Do with a Spreadsheet.
Lesson 1: Exploring Access Learning Objectives After studying this lesson, you will be able to: Start Access and identify elements of the application.
Basic Editing Lesson 2.
Introduction to SPSS. Object of the class About the windows in SPSS The basics of managing data files The basic analysis in SPSS.
VIDEO: INTRODUCTION TO STATA EMBA Data Analysis Professor Timothy Simcoe Boston University School of Management.
Dr. Engr. Sami ur Rahman Research Methods in Computer Science Lecture: Data Analysis (Introduction to SPSS)
Lesson 10 - Mail Merge and Reviewing Documents Advanced Microsoft Word.
SPSS- Tutorial The following power-point slides show you how to use some of the features in SPSS. A survey of 20 randomly selected companies asked them.
McGraw-Hill/Irwin The Interactive Computing Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. Microsoft Excel 2002 Working with Data Lists.
1 PEER Session 02/04/15. 2  Multiple good data management software options exist – quantitative (e.g., SPSS), qualitative (e.g, atlas.ti), mixed (e.g.,
1 EPIB 698C Lecture 1 Instructor: Raul Cruz-Cano
Using a set-up file to read ASCII data into Stata
3 A Guide to MySQL.
ECDL ECDL is an important building block, equipping you with the digital skills needed to progress to further education and employment. ECDL teaches you.
Chapter 3: Getting Started with Tasks
Excel Tutorial 8 Developing an Excel Application
Getting Started with Application Software
Spreadsheet – Microsoft Excel 2010
Release Numbers MATLAB is updated regularly
Microsoft Excel.
By Dr. Madhukar H. Dalvi Nagindas Khandwala college
Lesson 2 Tables and Charts
Statistical Analysis with Excel
Guide To UNIX Using Linux Third Edition
Metadata Editor Introduction
DEPARTMENT OF COMPUTER SCIENCE
Presentation Graphics
Boeing Supply Chain Platform (BSCP) Detailed Training
Central Document Library Quick Reference User Guide View User Guide
An Introduction to Using
ECONOMETRICS ii – spring 2018
Statistical Analysis with Excel
Introduction Introduction to Stata 2016.
Creating Database Tables
EndNote by: fatimah alotaibi.
Microsoft Excel All editions of Microsoft office.
Creating and Modifying Queries
Statistical Analysis with Excel
Microsoft Official Academic Course, Access 2016
Microsoft Excel 101.
Introduction to Stata Spring 2017.
Microsoft Official Academic Course, Access 2016
Microsoft Excel 101.
Objectives This is an introduction to the statistical software STATA aiming at: Preparing the participants in STATA basics (interphase and commands) for.
Stata Basic Course Lab 4.
Stata Basic Course Lab 2.
To access our web services, go to……
Executive Admin Assistant
Executive Admin Assistant
TERMS AND CONDITIONS   These PowerPoint slides are a tool for lecturers, and as such: YOU MAY add content to the slides, delete content from the slides,
Presentation transcript:

Evaluation of Public Policy Introduction to Stata Evaluation of Public Policy

What is Stata? Stata is a statistical software, widely used in academic research and in private companies, able to perform a variety of functions: database management; statistical-econometric analysis; graphic analysis. Stata is able to respond to the most different statistical-econometric problems, thanks to already available commands and its own programming language that allows advanced users to create customized routines. A useful Stata User’s guide is available at: https://www.stata.com/manuals13/u.pdf All analyses can be reproduced and documented for publication and review © Copyright 1996–2018 StataCorp LLC

Start and shut down STATA To start simply click on the Stata icon or select the program from the Windows menu To exit, type exit in the command bar Start and shut down STATA Exercise: start and stop STATA on your PC exit

The layout of the windows The first screen that Stata offers consists of several windows: 1. Stata Results 2. Review 3. Variables 4. Stata Command The layout of the windows Stata Results: window in which Stata presents the results of the commands given Review: records the history of the commands given by the Stata Command. By clicking on one of them, the mouse is returned to the Stata Command Variables: when a dataset is loaded here is a list of the variables that compose it Stata Command: window in which the commands Stata must execute are written

Open STATA on the PC and find the meaning of tab and sort commands To see what the commands in Stata indicate, their options or in general all the features in Stata, there is the Help! To access to the Help, select from the top bar or type help ### in the command bar Help !!! Attention !!! The controls are Case Sensitive! Exercise: Open STATA on the PC and find the meaning of tab and sort commands The first Help that Stata provides is online, for more details you can consult the PDF manual help

Upload data 01 Stata needs data, these come from datasets Stata expects the dataset to be rectangular with the variables in the columns (m) and the observations / statistic units in the rows (n). Datasets can have different origins, we focus on those formats: .dta and excel origin. Upload data 01 M2 is a string variable M3 is a integer variable (int) M4 is a float variable

Upload data 02 To load data in .dta format you need: tell Stata where the dataset is located with the command cd “path directory ###" Open the dataset with the command use file.dta Put the command ,clear after the use command to delete the dataset previously memorized by Stata For example to open the dataset today.dta in the directory Lecture1 the command are: cd “C:\Users\user\Dropbox\Lecture1” use today.dta, clear Upload data 02 Attention !!! Only one dataset at time is stored by Stata

To view the dataset click on the data editor or type the command br To save a dataset type save file.dta, replace The command , replace allows to rewriting over the previous dataset Upload data 03 Exercise: Put the file ethiopian_regions.dta into a PC folder, upload the dataset in STATA, see what is the capital of the region Afar, save the previous dataset with the name new_dataset.dta

Upload data 04 To see the imported dataset click on data editor or br To upload data from an Excel file, the shortest way is to: Open the Excel file and copy only the data of interest; Open the data editor in Stata; Paste the dataset, if dataset has the columns with the name of the variables press the option "Treat first row as variable names” To see the imported dataset click on data editor or br Or directly with the import excel command: import excel “path folder\excel.file.name.xls", firstrow Upload data 04 Create a dataset in Excel with 2 or more variables, upload this dataset on Stata datetime translation — String to numeric date translation functions gen date_hire=date(date, "YMD") format date_hire %tdMonth dd, CCYY

Data editor Data editor

Data editor (browse)

The command sum var1 var2 allows to display the number of observations and some descriptive statistics For some variables it is also convenient to use the command tab var1 to analyze the frequency distribution of a single variable To rename a variable: rename oldvar newvar To enter a description of a variable label var var “description” To delete a variable from the dataset: drop var1 A first look at the data Excercise: from the dataset ethiopian_regions.dta report the summary statistics of the variables population and area, see the frequency of the variable administrativezones, rename the variable accesstosafedrinkingwater in water, insert a description for the variable water drop the variable n_region

STATA has an editor that allows you to create do files The do files are simple text files with the extension .do which contain a series of commands to be passed to the program for execution Each line only one command Anticipated by * the line is not read as a command but only a comment – not processed by the software Use the run command to start the command Use the do files 01 ASTERISK (*)

Apertura do file Do file

Do file2 Run

Why use do files and not direct iteration with «Stata Command»: All the steps that are made in data processing are documented The reproducibility of the results is obtained Possible to repair mistakes To open a do file select from the top bar, then its management is like that of a text file .txt Use the do files 02 Exercise: Open a new do file, repeat the operations of slide 6, save the do file in a folder

Order and count on STATA You can sort the observations in ascending order for a variable with the command sort var1 You can count the observations of a variable given certain conditions with the command count if var1 ? x1 Order and count on STATA from the dataset ethiopian_regions.dta, sort the region by area, count the number of regions with area greater than 100,000; count the number of regions without information on the special zones ? Syntax to remember: > greater than < less than >= greater or equal <= less or equal == equal to ! = different from & is the boolean operators "and" | is the boolean operators "or" AMPERSAND (&) BROKEN BAR (|)

Manipulate data on STATA 1 With the command gen it’s possible to create new variables through an expression, for example: Create a new variable as a sum: gen newvar = var1 + var2 Create a difference variable: gen newvar = var1 - var2 Create a product variable: gen newvar = var1 * var2 Create a ratio variable: gen newvar = var1 / var2 Create the square of a variable: gen newvar = var1 ^ 2 Manipulate data on STATA 1

Manipulate data on STATA 2 With the command replace, you can replace values ​​according to a certain function For example, to replace a variable with the value zero when it becomes 10, the command is replace oldvar = 0 if oldvar == 10 Manipulate data on STATA 2 From the dataset ethiopian_regions.dta create the new variable pop1000 as a product between population and 1.000, create the density variable as a ratio between pop1000 and area, create the dummy variable high_density equal to 1 when the variable density assumes values greater than 500

Manipulate data on STATA 3 The generate command provides an enhanced version (egen) that should be used only in conjunction with a series of functions specifically provided for. To see which functions are combined: help egen For example: to create an average variable of var1: egen newvar1= mean(var1) To create an average variable of var1 for different groups of observations, classified by var2: bysort var2: egen newvar1=mean(var1) Manipulate data on STATA 3 Exercise: from the dataset ethiopian_regions.dta, create a variable with the population average, create a variable with the population average divided by regions with a high/low population density

Often data has different origins and sometimes it’s necessary to use at the same time information coming from two different datasets, that we call dataset master.dta and dataset slave.dta. A necessary condition for adding to a dataset (master) variables coming from another dataset (slave) is that in both are present one or more variables that allow to establish a relationship between the observations of the first and second dataset (key_var). The command merge allows us to add new variables to the master dataset coming from the slave dataset using one or more key variables use master.dta, clear merge key_var using slave.dta Attention !!! The datasets used in the merge must be sorted according to the key variable Merge dataset Exercise: Merge the dataset ethiopian_region with the dataset ethiopia_agri.dta

from the dataset ethiopian_regions.dta, It’s possible to make several graphs in STATA, most "ready-to-use" packages are in the bar at the top under graphics The most used graphs are (where var1is on y-axis and is on var2 x-axis): Scatter, with the command twoway(scatter var1 var2) Line, with the command twoway(line var1 var2) A graph on STATA from the dataset ethiopian_regions.dta, sort data for the population, create a graph that relates the population to the number of administrative zones

Graph population - administrative zones

Ripasso finale exit twoway sort rename by sort count if cd tab help sum .do file egen != drop clear "D:\ use and scatter gen | br save replace label

Some useful websites Stata’s own resources for learning STATA: Stata website, Stata library, Statalist archive www.stata.com/links/resources1.html Stata YouTube Channel http://www.youtube.com/user/statacorp University of North Carolina: www.cpc.unc.edu/research/tools/data_analysis/statatutorial Princeton: www.princeton.edu/~otorres/Stata