**Setup cd "/Users/kristenaiemjoy/Box Sync/_Teaching/Biostat 212/Biostat212.2018/Assignments/Assignment 4" //modify filepath to your directory capture log close //close any open log files clear quietly log using biostat212_assignment4_name.smcl, replace //open a log file /*** #Biostat 212: Assignment 4 ##Your name here _38 pts + 5 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 HTML, 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 /*** Set the scheme (your choice) for this assignment to make nicer looking graphs ***/ /*** ##EXAMPLE QUESTION __a. Visualize the distribution of BMI with a histogram or a boxplot.__ (Include the visualization in your MarkDoc) ***/ histogram bmi, normal img //place this image in the Markdoc. /*** __b. What is the mean, median and standard deviation of BMI?__ _Answer: mean = 25.54, median = 24.82, sd = 4.91_ ***/ tabstat bmi, stat(mean median sd) /*** ##QUESTION 1 [+4] __1a. Visualize the distribution of systolic blood pressure with a histogram or a boxplot.__ (Include the visualization in your MarkDoc) ***/ /*** __1b. What is the mean, median and standard deviation of systolic blood pressure?__ _Answer: XX_ ***/ /*** ##QUESTION 2 [+2] __What are the 95% confidence intervals around average (mean) systolic blood pressure?__ _Answer: XX_ ***/ /*** ##QUESTION 3 [+2] __What are the 95% confidence intervals around the proportion of the study population who had a heart attack?__ _Answer: XX_ ***/ /*** ##QUESTION 4 [+8] __4a. Create a dichotomous variable for age (49 and younger / 50 and older).__ Label the variable and the values. ***/ /*** __4b. 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 __4c. What is the mean systolic blood pressure for participants 49 and younger and those 50 and older?__ _Answer: XX_ __4d. 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: XX_ ***/ /*** ##QUESTION 5 [+8] __5a.Create a new variable for quartiles of age. Label the variable and the values.__ ***/ /*** __5b. Visualize the mean value of systolic blood pressure for each quartile of age with a bar chart.__ *hint: graph bar (mean) bpsystol, over(age_Quartile) (Include the visualization in your MarkDoc) ***/ /*** __5c. What is the mean systolic blood pressure for each quartile of age?__ _Answer: XX_ ***/ /*** Conduct an ANOVA (Analysis of variance) *hint: oneway bpsystol age_Quartile, tabulate __5d. What is the P-value?__ *hint: (Pro > F) _Answer:XX_ ***/ /*** ##QUESTION 6 [+8] __6a. 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 4 using a bar chart.__ *hint: heart attack is coded as 0 and 1. the mean will be the proportion of observations who had a heart attack (Include the visualization in your MarkDoc) ***/ /*** __6b. What percent of study participants 49 and younger had a heart attack?__ _Answer: XX_ __6c.What percent of study participants 50 and older had a heart attack?__ _Answer: XX_ ***/ /*** Conduct a chi-squared test *hint: tab heartatk age_dichotomous, col chi2 __6d. What is the p-value?__ _Answer: XX_ ***/ /*** ##QUESTION 7 [+6] __7a. What is the total sample size you would need to evaluate the following comparion in mean systolic blood pressure between 2 groups?__ * Group 1 mean = 130 * Group 2 mean = 150 * Common SD = 40 * Allocation ratio = 1 * Significance level = 0.05 * Power = 0.8 _Answer: XX_ ***/ /*** Now vary the mean in the second group from 140 to 170 by 10 and the standard deviation from 30 to 50 by 10. *hint: , sd(30(10)50) __7b. What total sample size do you need when the mean in the second group is 140 and the standard deviation is 50?__ _Answer: XX_ ***/ /*** __7c. Plot your previous command using the graph option and include it in your MarkDoc.__ ***/ /*** ##Extra credit [+5] 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 = systolic blood pressure * x axis = age in years (Include the visualization in your MarkDoc) Conduct a linear regression of age and systolic blood pressure __What is the coefficient for age?__ _Answer: _ __Interpret the coefficient for age in words.__ _Answer: _ __What is the p-value for the age 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 statax export(docx) //toc adds a table of contents. this is optional.