Disc10_Soln

.pdf

School

University of Wisconsin, Madison *

*We aren’t endorsed by this school

Course

371

Subject

Statistics

Date

May 16, 2024

Type

pdf

Pages

12

Uploaded by GrandEchidnaMaster871 on coursehero.com

Discussion 10 Solutions Warm Up Week 9 Quiz Question #9 Researchers studying bone mineral content (BMC) in breast-feeding mothers measured the percent change in BMC in women’s spines over three months. They compared a random sample of 47 breast-feeding women with a random sample of 22 women of similar age who were neither pregnant nor lactating. What tests might you reasonably consider doing to test whether there is significant evidence that the percent change in BMC in breastfeeding women is different from that in non pregnant nor lactating women? Comparative histograms for the data from R are shown below. Figure 1: Week 9 Quiz Question 9 Which of the following tests are reasonable? A two-independent sample bootstrap test True, the assumption of iid samples from independent populations appears to be satisfied Wilcoxon Rank Sum True, the assumption of iid samples 1
from independent populations appears to be satisfied Welch’s T test for the difference in means False, the assumption of normality appears to be violated in both samples. Exercise 1: Revisiting other variables in lbw data set Possible relationships between mothers’ characteristics and birth outcomes have been studied extensively. Using the lbw data set (lbw.csv), consider what inference tools we could apply to address the following ques- tions.This data was collected as part of a larger study at Bayside Medical Center, Springfield, Massachusetts in 1986. It contains information on 189 births to women that were seen in the obstetrics clinic. (Available in LogisticDx package) 1. Load the lbw data into your environment by reading in the CSV file (lbw.csv) to the variable lbw. Make sure the CSV file is in the same folder as your .Rmd file and that folder is set as your working directory. I have included vectors of the relevant data at the bottom of this page if you are having issues importing and would rather just define vectors of data. lbw = read.csv( "lbw.csv" , header = TRUE) 2. Run str(lbw). Confirm that you see the 11 variables types. We will be focusing on the variables lwt (weight of mother at last menstrual cycle) and smoke . Make sure R has read the data type for those variables correctly. Set any of those four variables that should be categorical using the as.factor() command. Check that they have set correctly with str(). str(lbw) ## ’data.frame’: 189 obs. of 11 variables: ## $ ID : int 1 2 3 4 5 6 7 8 9 10 ... ## $ low : int 0 0 0 0 0 0 0 0 0 0 ... ## $ smoke: int 0 0 1 1 1 0 0 0 1 1 ... ## $ race : int 2 3 1 1 1 3 1 3 1 1 ... ## $ age : int 19 33 20 21 18 21 22 17 29 26 ... ## $ lwt : int 182 155 105 108 107 124 118 103 123 113 ... ## $ ptl : int 0 0 0 0 0 0 0 0 0 0 ... ## $ ht : int 0 0 0 0 0 0 0 0 0 0 ... ## $ ui : int 1 0 0 1 1 0 0 0 0 0 ... ## $ ftv : int 0 3 1 2 0 0 1 1 1 0 ... ## $ bwt : int 2523 2551 2557 2594 2600 2622 2637 2637 2663 2665 ... lbw$smoke <- as.factor(lbw$smoke) str(lbw) ## ’data.frame’: 189 obs. of 11 variables: ## $ ID : int 1 2 3 4 5 6 7 8 9 10 ... ## $ low : int 0 0 0 0 0 0 0 0 0 0 ... ## $ smoke: Factor w/ 2 levels "0","1": 1 1 2 2 2 1 1 1 2 2 ... ## $ race : int 2 3 1 1 1 3 1 3 1 1 ... ## $ age : int 19 33 20 21 18 21 22 17 29 26 ... 2
## $ lwt : int 182 155 105 108 107 124 118 103 123 113 ... ## $ ptl : int 0 0 0 0 0 0 0 0 0 0 ... ## $ ht : int 0 0 0 0 0 0 0 0 0 0 ... ## $ ui : int 1 0 0 1 1 0 0 0 0 0 ... ## $ ftv : int 0 3 1 2 0 0 1 1 1 0 ... ## $ bwt : int 2523 2551 2557 2594 2600 2622 2637 2637 2663 2665 ... 3. Knit the document to confirm that the document knits correctly. If it does not, a few things to check: Is your file name in read.csv identical to the file name? Is your .csv file in the same folder as your .Rmd file (or did you include the path to your file in the file name)? We will now focus on the variable lwt (weight of mother at last menstrual cycle) compared across groups with smoke=0 and smoke=1. 4. Create Side by Side boxplots and/or comparative histograms of the variable lwt (weight of mother at last menstrual cycle) between mothers who had smoking status of 0=No and 1=Yes. Compare the center, variability and shape of the samples’ data. Sample mean variance size Non Smokers 130.9043 807.6487 115 Smokers 128.1351 1141.543 74 boxplot(lwt ~ smoke, data = lbw) # students may need to install ggplot2 install.packages( ' ggplot2 ' ) require(ggplot2) ## Loading required package: ggplot2 3
0 1 100 150 200 250 smoke lwt ggplot( data = lbw, aes( x = lwt, fill = smoke)) + geom_density( alpha = 0.2 ) 4
0.000 0.005 0.010 0.015 100 150 200 250 lwt density smoke 0 1 # If Students have saved off the data from the vectors below instead of using the data # frame, here is some code you can use to get the same vectors: define data frames one # for all data that came from mothers who smoked and one for mothers who did not smoke SmokeY = subset(lbw, smoke == 1 ) SmokeN = subset(lbw, smoke == 0 ) # save off lwt for smoking group and non smoking group lwtSmokeY <- SmokeY$lwt lwtSmokeN <- SmokeN$lwt boxplot(lwtSmokeY, lwtSmokeN, names = c( "lwt_Yes" , "lwt_No" )) 5
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