EC2227 Labs, Problem Set 0

Haydar Evren, Dinghe Cui, Arnab Palit

Grading TA: Haydar Evren; [email protected]


Due date: Sunday, February 21, 11:59 pm EST


Instructions

• This homework consists of 1 question, for a total of 10 points.

• Create a do–file with your code and an automated log–file of your answers from that code.

• Submit the two STATA files (i.e. do–file and log–file) online via the Canvas homework tool. Failure to submit 1 out of 2 files will determine a 50% penalty in this homework grade. Remember that your do–file has to work, i.e., its execution should without any errors produce the results, which are reported in the log–file. If the do–file doesn’t work, the points would be subtracted accordingly, with the maximum penalty of 50% of the total score.

• You are allowed to work with one partner, but each student needs to submit solutions on Canvas. If you do work with a partner, you should clearly state your partner’s name in your submission.

• For any questions about this assignment, please contact your instructor. For any questions about your grade, please contact Haydar Evren.


Question 1 (10 points):

Open the do–file editor in STATA and save your new document as “PS0 Solution.do” in the “EC2227” Folder in your BC Apps Storage. Record all commands in your do–file.

1. Give a title to your do-file. Also, mention your name, the current date and your partner’s name. Make sure to comment these first rows of your do–file out by using * at the beginning of each row.

2. Add the three opening commands clear all, set more off, and capture log close to your do–file.

3. Change the directory to the “EC2227” folder in your BC Apps Storage.

4. Open a log–file with the name “PS0 Solution”. Make sure to use the text and replace option as well. Note: If you do not use the text option, your log file will be ”.smlc” extension and you will not be able to upload your solutions on Canvas.

5. Load the bwght data set using the bcuse command. bwght is a natality dataset, containing data on birth weight (in ounces)— a key indicator for infant health— as well as demographic infor-mation about the infant’s parents (education and family income), and the amount of cigarettes smoked daily by the mother while she was pregnant (cigs), for each birth. Summarize the dataset using the summarize command.

6. What is the mean of the bwght in this data? What is the standard deviation of bwght? Write your answer as a comment in your do file.

7. Calculate the correlation between birth weight and the amount of cigarettes smoked daily by the mother while she was pregnant.

8. Load the dataset“affairs.dta”using the bcuse command. Describe the dataset using the describe command. (Hint: Remember to clear Stata’s memory using the clear command, otherwise the dataset will not load.)

9. Calculate the correlation between happiness of marriage and number of affairs using the correlation command. (Hint: The variable ratemarr measures the happiness of marriage and the variable naffairs is the number of affairs.)

10. Add the two closing commands log close and exit to your do–file.

Now run your do–file. Make sure it runs all the way through with no errors. Then, upload both do–file and log–file on Canvas.

Troubleshoot for common problems:

• After you finish your assignment, open your do, and log file without Stata. Check whether there is a problem (the file can not be opened, not readable, your log file shows some error messages, etc).

• After you submit into Canvas, download your submission and recheck your files.