stat 425 6 - 1(a > BFHS <...

This preview shows page 1 - 2 out of 4 pages.

1. (a) > BFHS <- read.table("~/Downloads/BFHS.dat", header=TRUE, quote="\"") >View(BFHS) > fit <-(BFHS) > summary(fit,header=TRUE) Town Intervention ExternalComparison Bridgend :1 Min. :5.370 Min. :5.415 Burton :1 1st Qu.:5.530 1st Qu.:5.619 Bury :1 Median :5.574 Median :5.702 Carlisle :1 Mean :5.574 Mean :5.685 Darlington :1 3rd Qu.:5.629 3rd Qu.:5.742 Dunfermline:1 Max. :5.812 Max. :6.067 (Other) :7 (b) > with(fit, t.test(ExternalComparison-Intervention)) One Sample t-test data: ExternalComparison - Intervention t = 2.0702, df = 12, p-value = 0.06067 alternative hypothesis: true mean is not equal to 0 95 percent confidence interval: -0.005844657 0.228613888 sample estimates: mean of x 0.1113846 #The p-value is 0.06067, which is larger than 0.05, so we can do not reject null hypnosis; the model does not have mean difference in the cholesterol levels of the intervention and comparison groups. (c) > tstats<-replicate(100000,t.test( (fit$ExternalComparison-fit$Intervention)*sample(c(-1,1),13,replace=TRUE) ) $statistic) > t.observed <- t.test(fit$Intervention-fit$ExternalComparison)$statistic > approx.pval <- mean(abs(tstats) >= abs(t.observed)) > approx.pval [1] 0.03888 #The p-value is 0.03888, which is samller than 0.05, reject null hypnosis, the there is mean difference.

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture