Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

Econ 310 Discussion Section

Stata Handout*

1    Overview

There are many software packages used for statistical analysis, the most popular being SAS, SPSS, R, and Stata. Each has a devoted following and is arguably “best” according to certain criteria or when used for a particular application. If you become a professional researcher, data analyst, economist, or statistician, you will  likely  learn  several packages.   Because  Stata  is  currently the  most popular statistical package among economists, it is what we’ll be learning and using for this class.  (If you go on to take Econ 410, you will likely continue to use Stata in that class as well.)

One  of the  best  resources  for  you  as  you  seek  to  learn  Stata  by  doing this assignment is a guide created by UW-Madison’s own Social Science Com- puting Cooperative especially for this Econ 310 assignment.   The guide can be found  at https://www .ssc .wisc .edu/sscc/pubs/sfs/sfs-econ310 .htm. That page has tutorials for many of the tasks you will be performing and com- mands you will be using in this assignment.

2    Accessing Stata

There are several ways to access Stata as a student in Econ 310:

UW-Madison has a site-license for Stata, allowing you to install the pack- age on your own computer for free.   If you wish to do this, go to the Campus  Software Library to download  Stata.   Make a note of the se- rial number,  code,  and authorization number on the download screen, which will be needed when you launch Stata for the rst time.  Again, you’ll need access to a printer to print out your assignment using this method.   The following link will take you to the Campus Software Li- brary: https://software .wisc .edu/cgi-bin/ssl/csl .cgi

● An SSCC account has been created for you, which gives you access to the computers in the SSCC Instructional Labs.  Using these labs allows you to avoid installing software on your laptop, so if you aren’t partic- ularly tech-savvy, this could be a good bet.   The main lab is in Social Science 4218 and is open 8:00am - 8:00pm Monday-Thursday and 8:00am - 6:00pm on Friday.  These computers have Stata pre-installed and you can print using GoPrint, which is a campus wide pay-for-print system. The following link has more information on the SSCC Instructional Labs: http://www.ssc.wisc.edu/sscc/instruction/labusers.htm

If you prefer to work from home, your SSCC account also enables you to access Stata remotely using Winstat. To use Winstat, you must install a software package known as Citrix Receiver on your computer. You’ll also need to have a printer at home, as Winstat can only print to your default local printer. The following link has more information on using Winstat: http://www.ssc.wisc.edu/sscc/pubs/winstat.htm

3    Stata Commands

Let’s do a dry run of the commands you’ll be needing for the Stata problem set.

1.  Launch Stata and re-size your Stata window to make sure it isn’t too small (which leads to unsightly line-wrapping in your results window).

2. You may wish to create a log le to save your output (this is recommended) to make it easier to print out and turn in by typing

log  using  filename .log,  replace

where filename can be replaced by whatever le name you choose.  For more details on organizing and logging your commands and results, see https://www.ssc.wisc.edu/sscc/pubs/sfs/sfs-do files .htm

3.  Just to make sure your name is somewhere in your results, use the display command to write your name in the log.   For example,  assuming you happen to be Bart Simpson, you would type the following command:       display  "Bart  Simpson"

4.  Before we do any statistical analysis, we’ll need some data to work with. On the problem set, we tell you exactly what command you should use to load the appropriate dataset.  But for today, let’s load a sample dataset known as auto:

sysuse  auto

5.  Use the describe command to determine which variable in this dataset contains “Price” and which contains Trunk space in cubic feet”:             describe

6.  Use the histogram command to graph a histogram of price and assess whether the distribution is symmetric or skewed:

histogram  price

7.  Use the summarize command to calculate the mean, median, and standard deviation of trunk space:

summarize  trunk

8.  Did the previous command have all the information you needed? Now try the same command with the detail option:

summarize  trunk,  detail

9.  Use the ci command to calculate a 95% confidence interval for the mean of price:

ci means  price

10.  Use the ttest command to test whether the population mean of trunk

space is equal to 13 using a 10% signicance level:

ttest  trunk=13,  level(90)

11.  Use the ttest command to test whether the population mean of trunk space is greater than 13 using a 10% significance level.  Note:  Will this command differ from the one above? Why or why not?

12.  Use the sdtest command to test whether the population variance of trunk space differs between domestic and foreign cars using a 10% significance level:

sdtest  trunk,  by(foreign)  level(90)

13.  Use the ttest command to test whether the population mean of trunk space differs between domestic and foreign cars using a 10% significance level:

ttest  trunk,  by(foreign)  level(90)

14.  Use the correlate command to calculate the correlation coefficient be- tween price and trunk space:

correlate  price  trunk

15.  Use the scatter command to graph a scatterplot of price (on the y-axis) and trunk space (on the x-axis) and assess the relationship between the two variables (note that the order of variables in the following command


matters):

scatter  price  trunk


16.  Use the regress command to run  a regression of price on trunk space (this language means price should be the dependent variable while trunk should be the explanatory variable, so the order of variables in the follow- ing command matters):

regress  price  trunk

4    Printing your Results

When you’re working on your Stata problem set, you’ll need to print out your results window along with any graphs you’ve generated to turn in with your assignment.  For the graphs, you’ll need to print each graph immediately after you type the command that produces it.  To practice, let’s repeat one of the graphing commands from above:

histogram  price

You’ll notice a graph window pop up with this histogram.  To print it, just click on the printer icon in the toolbar of this graph window.  For your results window (also known as the Stata log), once you’ve nished doing all the Stata work for your assignment, click on the printer icon at the top of the results window and select Results” from the pull-down menu.