******************************************************************************* * Assignment 3 * BE SURE TO TYPE ALL COMMANDS YOU USE IN THIS DO FILE FOR FULL * CREDIT. * Submit your do-file, log file, and word document on the CLE by 1 pm on 9/1/20 * There are a total of 25 points in this assignment * _Your Name_ ******************************************************************************* /* Set your working directory and load the data */ version 16.1 clear capture log close *Set your working directory here: cd "Your/working/directory" *Open a new log here: log using "assignment3_log", replace *Load the nhanes2 dataset: webuse nhanes2 /* Histograms - 6 pts */ *1a) Create a histogram of systolic blood pressure (bpsystol) (1pt) *Put your commands here: *1b) Plot a histogram with frequencies instead of densities and overlay a normal distribution (1pt) *Put your commands here: *1c) Change the above plot so there are 15 bins and change the scheme to s1mono (1pt) *Put your commands here: *1d) Export the graph from question 1c as an image file (e.g. png or jpg) (1pt) *Put your commands here: *1e) Put the exported graph from question 1d into a Word document. Make sure you center your graph. (2 pts) * Put your commands here: /* Bar Charts - 10 pts */ *2a) Create a bar chart for the mean of systolic blood pressure (bpsystol) over heart attack (heartatk) (1pt) *Put your commands here: *2b) Create and assign a label for heartatk where 0= No heartattack; 1= Heart attack and re-run your bar chart from part 2a (1pt) *Put your commands here: *2c) Now create a bar chart for mean heart attack over sex (1pt) *Put your commands here: *2d) Plot mean heart attack and mean diabetes over sex and add a title, data source (NHANES) as a caption, and change the legend to plain English instead of variable names (1pt) *hint: legend(label(1 "xyz") label(2 "xyz")) *Put your commands here: *2e) Produce the same figure as above, but restrict to only people who are at least 70 years old. Add a subtitle describing this restriction (1pt) *Put your commands here: *2f) Change the color of the heart attack bar to black and the color of the diabetes bar to gray (1pt) *hint: bar(1, color(xxx)) bar(2, color(xxx)) *Put your commands here: *2g) Change the graph region color from light blue to white (1pt) *Put your commands here: *2h) Export the graph from question 2g as an image file (e.g. png or jpg) (1pt) *Put your commands here: *2i) Add the exported graph from question 2h into the Word document you started in question 1. Make sure you center your graph. (2 pts) * hint: use the "append" option when saving your document * Put your commands here: /* Scatter Plots - 8 pts */ *3a) Create a scatter plot of systolic blood pressure as the dependent (y-axis) variable and age as the independent (x-axis) variable (1pt) *Put your commands here: *3b) Change marker size to very tiny and the marker color to gray (1pt) *Put your commands here: *3c) Add a black dashed linear fit line (1pt) *Put your commands here: *3d) Change the line width to thick (1pt) *Put your commands here: *3e) Turn off the legend (1pt) *Put your commands here: *3f) Add a y-axis title (systolic blood pressure) (1pt) *Put your commands here: *3g) Export the graph from question 3f as an image file (e.g. png or jpg) (1pt) *Put your commands here: *3h) Add the exported graph from question 3g into the Word document you started in question 1. Make sure you center your graph. (2 pts) * hint: use the "append" option when saving your document * Put your commands here: /* Wrapping up and turning in the assignment - 1pt */ *Turn in 3 files on the CLE: your do-file, a clean log file, and your Word document (1 pt) *Close log here: log close