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


Department of Economics

Winter 2022

ECN 102: Analysis of Economic Data



It is best to use Stata in the following way:

1. Download any data files into your working directory.

2. Start Stata and change the directory to your working directory using the File menu and then Change Working Directory ....

3.   Create a log file that saves results from the session.   e.g.   If it is  ass1results.txt type Stata command log  using  ass1results.txt,  text  replace (The replace means that any previous file named ass1results.txt will be over-written). Immediately after creating the log le, type:  display  "Your  Name  $S DATE" ($S DATE displays today’s date.)

4. Read in the data. For a Stata dataset this is the use command. For other data formats it is often the  import command - for details type help  import.   If typing data in use command input.

Examples: use  xyz.dta,  clear

import  delimited  using  xyz.csv,  comma

5. Once data is read in if it was not a Stata dataset then save it as a Stata dataset.

6. To save any graphs you can cut and paste them into your assignment solutions document. Or directly save the file in Stata.  e.g.  To save the first graph as a PNG graph named ass1q1graph1.png give Stata command graph  export  ass1q1graph1.png,  replace

7. When you leave Stata give the command log  close to save the log file.

8. The Stata output log file is a text file with everything properly aligned if you use a fixed character width font. A good font to use if using e.g. MS Word is Courier New.

9. To save space just turn in the key results for the assignment.

10. It is best to always create a .do file to work out of instead of typing commands directly into the Stata command bar.  This way you can create a  “clean” log file and can rerun things without having to type in the commands multiple times.


1.  Cross-section Data Example

A sample of 20 people aged 30 had the following number of annual doctor visits: 0, 0, 3, 4, 2, 5, 5, 2, 11, 2, 1, 2, 3, 0, 8, 0, 8, 1, 1, 4

(a) Read the data into Stata.

(b) Obtain summary statistics.

(c) Give the inter-quartile range.

(d) List the first five observations, using Stata command list  in  1/5.

(e) Obtain a table of frequencies for these data, using Stata command tabulate               (f) Give a histogram, with a bin width of one for these discrete data. Do the data appear to be normally distributed?

(g) Provide a pie chart - what is the most common number of doctor visits?

 



2.  Time Series Data Example

The Stata dataset PRICEEARNINGS.DTA at has annual data on the price-earnings ratio (variable pe) for S&P500 firms (in real terms) from 1881 to 2012.

(a) Read the data into Stata: give command use  AED PRICEEARNINGS.DTA

(b) Obtain the summary statistics for pe (pe ratio). Do the data appear to be skewed? Do the data appear to have greater kurtosis than the normal distribution? Explain.

(c) Plot the histogram. Do the data appear to be skewed?

(d) Provide a time series plot of the data.  Comment on any unusual features.  Give Stata commands

tsset  year

tsline  pe

(e) Provide a box-and-whisker plot of the data. Comment on any unusual features. (f) Do the data to be unusually high or low in 2012? Explain.


3.  Data Transformation Example

Here we work with annual percentage change in the price-earnings ratio.            Continue with the same data as question 2. You can abbreivate pe ratio to pe (a) Generate pe lagged one year using command: generate  pelag  =  pe[ n-1] (The current observation is observation  n, so lagged on period is  n-1).             (b) Check that this worked, using Stata command list  in  1/5

(c) Now use Stata command generate to generate the annual percentage change in the price-earnings ratio (= (yt − yt − 1 )/yt − 1 ). Note: yt − 1  means variable y lagged one period.   (d) Give a line chart for the annual percentage change in the price-earnings ratio.             Briefly state the usefulness of this compared to the line chart of the original series.

(e) Is the price-earnings ratio in recent years more or less volatile than in the earlier years in the sample? Explain.

(f) A simpler way to do the preceding is to tell Stata that we have time series data, where time is given by the variable year.  The Stata command tsset does this.  Then l.gdp is variable gdp lagged one period and d.gdp is the first difference (yt  − yt − 1 ) of gdp.  Line

plots for data identified as time series can be done using command tsline. Do the following and compare to part (d)


tsset  year

generate  pepercentagechange tsline  pepercentagechange

=  100*d.pe/l.pe


4.  Summary Statistics

(a) Obtain     zi  for the following cases:

(1) zi = 1 and n = 6.

(2) zi = i and n = 6.

(3) zi = 2i2  and n = 6.

(4) zi = 1/i and n = 6.

(b)  Compute from first principles  (i.e.   using the formula and a calculator) the mean, standard deviation, coefficient of variation, symmetry statistic and kurtosis statistic for the sample 7, 2, 0, 3. Show all calculations.

(c) IQ scores have a mean of 100, standard deviation of 14 and are approximately normally distributed. What range of IQ scores do you expect 95% of the population lie in?


5.  Types of Economic Data

For each of the following examples state whether the data are numerical or categorical, and state whether the data are cross-section, time series or panel data.

(a) Quarterly data on the level of U.S. new housing construction from 2000 to 2012. (b) Data on number of doctor visits in 2012 for a sample of 192 individuals.

(c) Data on annual health expenditures for each U.S. state from 2000 to 2012.

(d) Data on usual mode of transportation used to commute to work for a sample of 151 individuals.


6.  Types of Economic Data

For each of the following state whether the data are observational or experimental             (a) Data on earnings for individuals some of whom chose to participate in a training program and some who did not.

(b) Data on earnings for individuals some of whom were randomly assigned to a training program and some who were not.

(c) Data on school outcomes for charter schools and for traditional schools.