HW1

.docx

School

University of Louisville *

*We aren’t endorsed by this school

Course

680

Subject

Statistics

Date

Feb 20, 2024

Type

docx

Pages

8

Uploaded by CoachCaterpillarMaster1073 on coursehero.com

Homework Assignment 1: Descriptive Statistics require (mosaic) require (lattice) Hypertension # Systolic Blood Pressure Data in the recumbent position rSystolic = c ( 99 , 126 , 108 , 122 , 104 , 108 , 116 , 106 , 118 , 92 , 110 , 138 , 120 , 142 , 118 , 134 , 118 , 126 , 108 , 136 , 110 , 120 , 108 , 132 , 102 , 118 , 116 , 118 , 110 , 122 , 106 , 146 ) # Diastolic Blood Pressure Data in the recumbent position rDiastolic = c ( 71 , 74 , 72 , 68 , 64 , 60 , 70 , 74 , 82 , 58 , 78 , 80 , 70 , 88 , 58 , 76 , 72 , 78 , 78 , 86 , 78 , 74 , 74 , 92 , 68 , 70 , 76 , 80 , 74 , 72 , 62 , 90 ) # Systolic Blood Pressure Data in the standing position sSystolic = c ( 105 , 124 , 102 , 114 , 96 , 96 , 106 , 106 , 120 , 88 , 102 , 124 , 118 , 136 , 92 , 126 , 108 , 114 , 94 , 144 , 100 , 106 , 94 , 128 , 96 , 102 , 88 , 100 , 96 , 118 , 94 , 138 ) # Diastolic Blood Pressure Data in the standing position sDiastolic = c ( 79 , 76 , 68 , 72 , 62 , 56 , 70 , 76 , 90 , 60 , 80 , 76 , 84 , 90 , 58 , 68 , 68 , 76 , 70 , 88 , 64 , 70 , 74 , 88 , 64 , 68 , 60 , 84 , 70 , 78 , 56 , 94 ) # Combining all variables into one data frame bloodPressureData = data.frame (rSystolic, rDiastolic, sSystolic, sDiastolic) # Storing difference in systolic and diastolic blood pressures as variables systolicDiff = bloodPressureData $ rSystolic - bloodPressureData $ sSystolic diastolicDiff = bloodPressureData $ rDiastolic - bloodPressureData $ sDiastolic print (systolicDiff) ## [1] -6 2 6 8 8 12 10 0 -2 4 8 14 2 6 26 8 10 12 14 -8 10 14 14 4 6 ## [26] 16 28 18 14 4 12 8 Problem 2.19 The average blood pressure difference (recumbent - standing) for systolic blood pressure is 8.8125 mm Hg, while for diastolic blood pressure it is 0.9375 mm Hg. The median blood
pressure difference for systolic blood pressure is 8 mm Hg, and for diastolic blood pressure, it is 1 mm Hg. # Store the mean of the differences as variables systolicDiffMean = mean (systolicDiff) diastolicDiffMean = mean (diastolicDiff) #Store the median of the differences as variables systolicDiffMedian = median (systolicDiff) diastolicDiffMedian = median (diastolicDiff) Problem 2.20 The diastolic difference (recumbent - standing) displays a range from a minimum of -14 mm Hg to a maximum of 16 mm Hg. The lower quartile (Q1) is -2 mm Hg, the median is 1 mm Hg, and the upper quartile (Q3) is 4 mm Hg. On the other hand, the systolic difference (recumbent - standing) ranges from a minimum of -8 mm Hg to a maximum of 28 mm Hg. The Q1 is 4 mm Hg, the median is 8 mm Hg, and the Q3 is 14 mm Hg. # Storing box and whisker plots for the diastolic and systolic blood pressure differences diastolicDiffBoxPlot = bwplot (diastolicDiff, main= "Berhe: Diastolic Difference BWPlot" ) systolicDiffBoxPlot = bwplot (systolicDiff, main= "Berhe: Systolic Difference BWPlot" ) Problem 2.21 Examining the variances in systolic blood pressure between the recumbent and standing positions reveals a slight elevation in blood pressure while in the recumbent position. Conversely, analyzing diastolic blood pressure across both positions yields inconsistent findings, suggesting that position exerts minimal influence on diastolic blood pressure overall. print (diastolicDiff) ## [1] -8 -2 4 -4 2 4 0 -2 -8 -2 -2 4 -14 -2 0 8 4 2 8 ## [20] -2 14 4 0 4 4 2 16 -4 4 -6 6 -4 print (systolicDiff) ## [1] -6 2 6 8 8 12 10 0 -2 4 8 14 2 6 26 8 10 12 14 -8 10 14 14 4 6 ## [26] 16 28 18 14 4 12 8
Problem 2.22 An atypical change in systolic blood pressure when transitioning from a recumbent to standing position is defined as any deviation outside the normal range of 0 to 16 units. # Using the quantile function to get the bottom and lower decile of the systolic difference dataset upperSystolicDecile = quantile (systolicDiff, 0.9 , type= 2 ) lowerSystolicDecile = quantile (systolicDiff, 0.1 , type= 2 ) Environmental Health, Pediatrics # Set Working Directory to gain access to lead data file setwd ( "C: \\ Users \\ ggber \\ OneDrive \\ Desktop \\ R Work \\ PHST680 \\ Week 1 Homework \\ " ) # Read the LEAD.DAT file and convert it to a table leadData = read.table ( file= "LEAD.DAT.txt" , header= TRUE , sep = "," ) newVars = c ( "area" , "sex" , "iq_type" , "lead_grp" , "Group" , "fst2yrs" , "pica" , "colic" , "irrit" , "convul" ) leadData[,newVars] = lapply (leadData[,newVars],factor) Problem 2.31 The average age of children in the control group is 9.33 years, whereas those in the exposed group average 8.27 years. Typically, children in the control group are older by approximately one year compared to those in the exposed group. This contrast is visually represented through parallel box plots, with the exposed group's plot positioned above the control group's. These plots offer a clear comparison of the 25th and 75th percentiles as well as the median age for both groups. In both numerical and graphical summaries, the control group consistently displays higher age values than the exposed group. Regarding lead exposure based on gender, a greater proportion of males than females have been exposed to lead. Additionally, regardless of gender, the number of individuals without exposure surpasses those who have been exposed. # Numeric Summary of age by group favstats ( ~ ageyrs | Group, data= leadData) ## Group min Q1 median Q3 max mean sd n missing ## 1 1 3.75 6.5000 9.420 12.560 15.92 9.327308 3.572386 78 0 ## 2 2 3.75 5.2725 7.835 10.335 15.25 8.269783 3.411756 46 0 # Graphic Summary of age by group bwplot (Group ~ ageyrs, data= leadData)
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help