# UCLA STATS 101A - stats_101a_Hw1 (8 pages)

Previewing pages 1, 2, 3 of 8 page document
View Full Document

## stats_101a_Hw1

Previewing pages 1, 2, 3 of actual document.

View Full Document
View Full Document

## stats_101a_Hw1

322 views

Pages:
8
School:
University of California, Los Angeles
Course:
Stats 101a - Introduction to Design and Analysis of Experiment
##### Introduction to Design and Analysis of Experiment Documents
• 11 pages

• 92 pages

• 14 pages

• 2 pages

• 6 pages

• 9 pages

• 8 pages

• 2 pages

• 6 pages

• 5 pages

• 4 pages

• 17 pages

Unformatted text preview:

Stats 101A HW1 Linda Che 10 10 2017 Problem 1 a library readr Heart read csv Downloads Heart 1 csv hist Heart Oldpeak X1 mean Heart Oldpeak sd1 sd Heart Oldpeak t test Heart Oldpeak alternative two sided mu 0 95 One Sample t test data Heart Oldpeak t 1 3433 df 302 p value 0 1802 alternative hypothesis true mean is not equal to 0 95 95 percent confidence interval 0 9083444 1 1708635 sample estimates mean of x 1 039604 We fail to reject the null because the p value is 0 052 at a 95 confidence interval b Heart sex freq ifelse Heart Sex 0 female male barplot table Heart Sex prop table table Heart Sex 0 1 0 320132 0 679868 prop test sum Heart Sex n 303 alternative two sided conf level 0 9 1 sample proportions test with continuity correction data sum Heart Sex out of 303 null probability 0 5 X squared 38 495 df 1 p value 5 489e 10 alternative hypothesis true p is not equal to 0 5 90 percent confidence interval 0 6326641 0 7237696 sample estimates p 0 679868 reject the null because the p value is 0 05 at a 90 confidence interval meaning that there would be a difference in the heart rates of males vs heart rates of females later we test that this is wrong c n 303 X1 c 1 1 qt 0 975 n 1 sd1 sqrt n 1 0 9083444 1 1708635 d p 0 679868 p c 1 1 qt 0 95 n 1 sqrt p 1 p n 1 0 6356482 0 7240878 Problem 2 a m1 lm MaxHR Oldpeak Heart b plot Heart Oldpeak Heart MaxHR abline m1 c summary m1 Call lm formula MaxHR Oldpeak data Heart Residuals Min 1Q Median 3Q Max 78 875 12 088 3 403 14 912 54 023 Coefficients Estimate Std Error t value Pr t Intercept 156 634 1 661 94 310 2e 16 Oldpeak 6 759 1 067 6 337 8 54e 10 Signif codes 0 0 001 0 01 0 05 0 1 1 Residual standard error 21 52 on 301 degrees of freedom Multiple R squared 0 1177 Adjusted R squared 0 1148 F statistic 40 16 on 1 and 301 DF p value 8 539e 10 The slope represents the increase in one increment of ST depression induced by exercise relative to rest results in a decrese of 6 749bpm in heart rate THe intercept represents if there is no ST depression induce by exercise the heart rate will be 156 634bpm d confint m1 level 0 95 2 5 97 5 Intercept 153 365948 159 902608 Oldpeak 8 858367 4 660277 mres sum m1 residuals 2 n 1 sxx sum Heart Oldpeak X1 2 m1 coefficients 2 c 1 1 qt 0 975 n 1 sqrt mres sxx Manual calculation 1 8 854860 4 663783 m1 coefficients 1 c 1 1 qt 0 975 n 1 sqrt mres 1 n mean Heart Oldpeak 2 sxx Manual Calculation 1 153 3714 159 8971 e sse sum m1 residuals 2 sse 1 139425 4 ssr sum m1 fitted values mean Heart MaxHR 2 ssr 1 18600 89 sst var Heart MaxHR n 1 sst 1 158026 3 sse ssr test to check if sst is correct using sse ssr 1 158026 3 Problem 3 a predict lm m1 newdata data frame Oldpeak 1 5 interval confidence level 0 99 fit lwr upr 1 146 4953 143 0466 149 944 mr 156 634 6 759 1 5 mr c 1 1 qt 0 995 n 1 sqrt mres 1 n 1 5 X1 2 sxx Manual calculation 1 143 0526 149 9384 b predict lm m1 newdata data frame Oldpeak 1 5 interval prediction level 0 99 fit lwr upr 1 146 4953 90 59751 202 3931 pr 156 634 6 759 1 5 pr c 1 1 qt 0 995 n 1 sqrt mres 1 1 n 1 5 X1 2 sxx Manual calculation 1 90 69152 202 29948 c The prediction interval is bigger than the confidence interval Problem 4 a m2 lm Heart MaxHR Heart sex freq m2 Call lm formula Heart MaxHR Heart sex freq Coefficients Intercept Heart sex freqmale 151 227 2 382 b plot Heart Sex Heart MaxHR abline m2 c summary m2 Call lm formula Heart MaxHR Heart sex freq Residuals Min 1Q Median 3Q Max 77 845 16 036 2 773 16 155 53 155 Coefficients Estimate Std Error t value Pr t Intercept 151 227 2 324 65 080 2e 16 Heart sex freqmale 2 382 2 818 0 845 0 399 Signif codes 0 0 001 0 01 0 05 0 1 1 Residual standard error 22 89 on 301 degrees of freedom Multiple R squared 0 002368 Adjusted R squared 0 0009463 F statistic 0 7145 on 1 and 301 DF p value 0 3986 the slope is the difference between the mean heart rates of males and females The intercept is the mean heart rate of females From the summary we can see that the difference is insignificant because the p value is greater than 0 05 d t test Heart MaxHR Heart sex freq var equal TRUE Two Sample t test data Heart MaxHR by Heart sex freq t 0 84528 df 301 p value 0 3986 alternative hypothesis true difference in means is not equal to 0 95 percent confidence interval 3 163682 7 927970 sample estimates mean in group female mean in group male 151 2268 148 8447 the t test claims the same as the simple linear regression model The difference between the average hear rates of males and females is insignificant We fail to reject the null because the p value 0 399 is greater than the significance level at 0 05

View Full Document

Unlocking...