This is for R (RStudio). This is how the dataset looks like for \"birthwt\" > bi
ID: 2933340 • Letter: T
Question
This is for R (RStudio).
This is how the dataset looks like for "birthwt"
> birthwt
low age lwt race smoke ptl ht ui ftv bwt
85 0 19 182 2 0 0 0 1 0 2523
86 0 33 155 3 0 0 0 0 3 2551
87 0 20 105 1 1 0 0 0 1 2557
88 0 21 108 1 1 0 0 1 2 2594
89 0 18 107 1 1 0 0 1 0 2600
91 0 21 124 3 0 0 0 0 0 2622
92 0 22 118 1 0 0 0 0 1 2637
93 0 17 103 3 0 0 0 0 1 2637
94 0 29 123 1 1 0 0 0 1 2663
95 0 26 113 1 1 0 0 0 0 2665
96 0 19 95 3 0 0 0 0 0 2722
97 0 19 150 3 0 0 0 0 1 2733
98 0 22 95 3 0 0 1 0 0 2751
99 0 30 107 3 0 1 0 1 2 2750
100 0 18 100 1 1 0 0 0 0 2769
101 0 18 100 1 1 0 0 0 0 2769
102 0 15 98 2 0 0 0 0 0 2778
103 0 25 118 1 1 0 0 0 3 2782
104 0 20 120 3 0 0 0 1 0 2807
105 0 28 120 1 1 0 0 0 1 2821
106 0 32 121 3 0 0 0 0 2 2835
107 0 31 100 1 0 0 0 1 3 2835
108 0 36 202 1 0 0 0 0 1 2836
109 0 28 120 3 0 0 0 0 0 2863
111 0 25 120 3 0 0 0 1 2 2877
112 0 28 167 1 0 0 0 0 0 2877
113 0 17 122 1 1 0 0 0 0 2906
114 0 29 150 1 0 0 0 0 2 2920
115 0 26 168 2 1 0 0 0 0 2920
116 0 17 113 2 0 0 0 0 1 2920
117 0 17 113 2 0 0 0 0 1 2920
118 0 24 90 1 1 1 0 0 1 2948
119 0 35 121 2 1 1 0 0 1 2948
120 0 25 155 1 0 0 0 0 1 2977
121 0 25 125 2 0 0 0 0 0 2977
123 0 29 140 1 1 0 0 0 2 2977
124 0 19 138 1 1 0 0 0 2 2977
125 0 27 124 1 1 0 0 0 0 2922
126 0 31 215 1 1 0 0 0 2 3005
127 0 33 109 1 1 0 0 0 1 3033
128 0 21 185 2 1 0 0 0 2 3042
129 0 19 189 1 0 0 0 0 2 3062
130 0 23 130 2 0 0 0 0 1 3062
131 0 21 160 1 0 0 0 0 0 3062
132 0 18 90 1 1 0 0 1 0 3062
133 0 18 90 1 1 0 0 1 0 3062
134 0 32 132 1 0 0 0 0 4 3080
135 0 19 132 3 0 0 0 0 0 3090
136 0 24 115 1 0 0 0 0 2 3090
137 0 22 85 3 1 0 0 0 0 3090
138 0 22 120 1 0 0 1 0 1 3100
139 0 23 128 3 0 0 0 0 0 3104
140 0 22 130 1 1 0 0 0 0 3132
141 0 30 95 1 1 0 0 0 2 3147
142 0 19 115 3 0 0 0 0 0 3175
143 0 16 110 3 0 0 0 0 0 3175
144 0 21 110 3 1 0 0 1 0 3203
145 0 30 153 3 0 0 0 0 0 3203
146 0 20 103 3 0 0 0 0 0 3203
147 0 17 119 3 0 0 0 0 0 3225
148 0 17 119 3 0 0 0 0 0 3225
149 0 23 119 3 0 0 0 0 2 3232
150 0 24 110 3 0 0 0 0 0 3232
151 0 28 140 1 0 0 0 0 0 3234
154 0 26 133 3 1 2 0 0 0 3260
155 0 20 169 3 0 1 0 1 1 3274
156 0 24 115 3 0 0 0 0 2 3274
159 0 28 250 3 1 0 0 0 6 3303
160 0 20 141 1 0 2 0 1 1 3317
161 0 22 158 2 0 1 0 0 2 3317
162 0 22 112 1 1 2 0 0 0 3317
163 0 31 150 3 1 0 0 0 2 3321
164 0 23 115 3 1 0 0 0 1 3331
166 0 16 112 2 0 0 0 0 0 3374
167 0 16 135 1 1 0 0 0 0 3374
168 0 18 229 2 0 0 0 0 0 3402
169 0 25 140 1 0 0 0 0 1 3416
170 0 32 134 1 1 1 0 0 4 3430
172 0 20 121 2 1 0 0 0 0 3444
173 0 23 190 1 0 0 0 0 0 3459
174 0 22 131 1 0 0 0 0 1 3460
175 0 32 170 1 0 0 0 0 0 3473
176 0 30 110 3 0 0 0 0 0 3544
177 0 20 127 3 0 0 0 0 0 3487
179 0 23 123 3 0 0 0 0 0 3544
180 0 17 120 3 1 0 0 0 0 3572
181 0 19 105 3 0 0 0 0 0 3572
182 0 23 130 1 0 0 0 0 0 3586
183 0 36 175 1 0 0 0 0 0 3600
184 0 22 125 1 0 0 0 0 1 3614
185 0 24 133 1 0 0 0 0 0 3614
186 0 21 134 3 0 0 0 0 2 3629
187 0 19 235 1 1 0 1 0 0 3629
188 0 25 95 1 1 3 0 1 0 3637
189 0 16 135 1 1 0 0 0 0 3643
190 0 29 135 1 0 0 0 0 1 3651
191 0 29 154 1 0 0 0 0 1 3651
192 0 19 147 1 1 0 0 0 0 3651
193 0 19 147 1 1 0 0 0 0 3651
195 0 30 137 1 0 0 0 0 1 3699
[ reached getOption("max.print") -- omitted 89 rows ]
Explanation / Answer
The complete R snippet is as follows
library(MASS)
data("birthwt")
birthwt
names(birthwt)
smoke<-subset(birthwt, birthwt$smoke=="1")
nosmoke<-subset(birthwt,birthwt$smoke=="0")
t.test(smoke$bwt,nosmoke$bwt,conf.level = 0.99)
## means
mean(smoke$bwt)
mean(nosmoke$bwt)
## sd
sd(smoke$bwt)
sd(nosmoke$bwt)
The results are
t.test(smoke$bwt,nosmoke$bwt,conf.level = 0.99)
Welch Two Sample t-test
data: smoke$bwt and nosmoke$bwt
t = -2.7299, df = 170.1, p-value = 0.007003 ## as this is less than 0.01 , hence we reject the null hypothesis in favor of alternate hypothesis
alternative hypothesis: true difference in means is not equal to 0
99 percent confidence interval:
-554.57562 -12.97784 , the difference does not include zero
sample estimates:
mean of x mean of y
2771.919 3055.696
H0 : The mean values of bwt are equal
H1 : The mean values of bwt are not equal
Other stats of interest are
## means
> mean(smoke$bwt)
[1] 2771.919
> mean(nosmoke$bwt)
[1] 3055.696
>
> ## sd
> sd(smoke$bwt)
[1] 659.6349
> sd(nosmoke$bwt)
[1] 752.6566
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.