**Setup cd "/Users/kristenaiemjoy/Box Sync/_Teaching/Biostat 212/Biostat212.2017/Assignments/Assignment 4 stats" //modify filepath to your directory capture log close //close any open log files set linesize 120 // for formatting the Markdown document clear quietly log using biostat212_assignment4_name.smcl, replace //open a log file /*** #Biostat 212: Assignment 4 ##Your name here _40 pts + 10 extra credit_ --- The goal of this assignment is to learn how to do basic statistical analysis in Stata. We’ll analyze the NHANES dataset you used in Assignments 1, 2 & 3. Turn in the PDF or DocX you create with MarkDoc. _Remember to include both the command(s) and your answer for each question. See the first question as an example._ _Round to 2 decimal points_ _Report p values of 0.0000 as <0.001_ --- ***/ /*** Load the nhanes2 data set from the web ***/ webuse nhanes2 /*** Temporarily set the scheme for this assignment to make nicer looking graphs ***/ set scheme s1mono /*** --- ##Question 1 [+5] Visualize the distribution of BMI with a histogram or a boxplot. Include the visualization in your MarkDoc. __What is the mean, median and standard deviation of BMI?__ _Answer: mean = 25.54, median = 24.82, sd = 4.91_ ***/ graph box bmi histogram bmi, normal img //place this image in the Markdoc. tabstat bmi, stat(mean median sd) /*** ##Question 2 [+5] Visualize the distribution of systolic blood pressure with a histogram or a boxplot. Include the visualization in your MarkDoc. __What is the mean, median and standard deviation of systolic blood pressure?__ _Answer: _ ***/ /*** ##Question 3 [+5] Visualize the distribution of age with a histogram or a boxplot. Include the visualization in your MarkDoc. __What is the mean, median and standard deviation of age?__ _Answer: _ ***/ /*** ##Question 4 [+5] __What are the 95% confidence intervals around average (mean) systolic blood pressure?__ _Answer: _ ***/ /*** ##Question 5 [+5] __What are the 95% confidence intervals around the proportion of the study population who had a heart attack?__ _Answer: _ ***/ /*** ##Question 6 [+5] Create a dichotomous variable for age (49 and younger / 50 and older). Label the variable and the values. _hint: try the recode command_ Visualize the mean value of systolic blood pressure for each value of the new dichotomous age variable with a bar chart. Include the visualization in your MarkDoc. Conduct a ttest, testing if mean systolic blood pressure is different in the 2 age categories. __What is the mean systolic blood pressure for participants 49 and younger and those 50 and older?__ _Answer: _ __What is the p-value testing the null hypothesis that the difference in systolic blood pressure between those age 49 and younger and those 50 and older is equal to 0?__ _hint: the middle p-value (Ha: diff !=0)_ _Answer: _ \ ***/ /*** ##Question 7 [+5] Create a new variable for quartiles of age. Label the variable and the values. Visualize the mean value of systolic blood pressure for each quartile of age with a bar chart. Include the visualization in your MarkDoc. _hint: graph bar (mean) bpsystol, over(age_Quartile)_ __What is the mean systolic blood pressure for each quartile of age?__ _Answer: _ Conduct an ANOVA (Analysis of variance) _hint: oneway bpsystol age_Quartile_ __What is the P-value?__ _hint: (Pro > F)_ _Answer: _ ***/ /*** ##Question 8 [+5] Visualize the percent of study participants who had a heart attack over the new dichotomous age variable (49 and younger vs. 50 and older) you created in question 6 using a bar chart. Include the visualization in your MarkDoc. _hint: heart attack is coded as 0 and 1. the mean will be the percent who had a heart attack_ __What percent of study participants 49 and younger had a heart attack?__ _Answer: _ __What percent of study participants 50 and older had a heart attack?__ _Answer: _ Conduct a chi-squared test _hint: tab heartatk age_dichotomous, col chi2_ __What is the P-value?__ _Answer: _ ***/ /*** ##Extra credit [+10] Visualize the relationship between age (continuous, in years) and systolic blood pressure (continuous, mmHg) with a scatter plot. Add a linear fit. Change the marker size to very tiny. Add a y-axis label and a title. y axis = age in years x axis = systolic blood pressure Include the visualization in your MarkDoc. Conduct a linear regression of age and systolic blood pressure __What is the coefficient for bpsyst?__ _Answer: _ __Interpret the coefficient for bpsyst in words.__ _Answer: _ __What is the p-value for the bpsyst coefficient?__ _Answer: _ ***/ qui log close //close log (quietly so it won't appear in markdown document /*The following command creates a PDF or word document from your log file. Make sure the name of the file after the word markdown matches the name of your log file If you have an issue loading graphs into your PDF, change the export format to docx*/ markdoc biostat212_assignment4_name, replace export(pdf) date toc //toc adds a table of contents. this is optional.