participants of the diet program and measures their weight in kg just before

Participants of the diet program and measures their

This preview shows page 58 - 60 out of 171 pages.

participants of the diet program and measures their weight (in kg) just before enrolling in theprogram and immediately after the completion of the program. Based on this evidence, is theNewdietprogrameffectiveinreducingweight?A healthchaincanrecommendaconventional low-calorie diet for free or can recommend New diet by paying a licensing fee.The firm has determined that it is worth paying the licensing fee if they can gain enoughadditional members, which is possible if New diet reduces average weight by 3 Kg or morecompared to the conventional low-calorie diet. The firm collects weight loss data from twosimple random samples of people, one of whom goes through New diet and the other throughthe conventional diet for 6 months5.10 T-TESTOne-sample t-test is used to compare the mean value of a sample with a constant valuedenoted m0. It has the null hypothesis that the population mean is equal to m0, and the thealternative hypothesis that it is not.# One sample t-testsetwd(“D:/R data”)WR_Trt <- read.csv(“Wt_red.csv”)fix(WR_Trt)OS_ttest <- WR_Trt[which(WR_Trt$Treatment==”Dummy Pill”),]OS_ttest$Change <- OS_ttest$Before-OS_ttest$After
Image of page 58
fix(OS_ttest)OS_tt_res<- t.test(OS_ttest$Change, mu=3)The mu argument gives the value with which you want to compare the sample mean. It isoptional and has a default value of 0. By default, R performs a two-tailed test. To perform aone-tailed test, set the alternative argument to “greater” or “less”. To adjust the size of theinterval, use the conf.level argument:t.test(OS_ttest$Change, mu=1, alternative=”greater”)t.test(OS_ttest$Change, mu=1, conf.level=0.99)Two-sample t-test is used to compare the mean values of two independent samples, todetermine whether they are drawn from populations with equal means. It has the null thehypothesis that the two means are equal, and the alternative hypothesis that they are not equal.Toperformatwo-samplet-testwithdatainstackedform,usethecommand:t.test(values~groups, dataset), where values are the name of the variable containing the datavalues and groups is the variable containing the sample names. If the grouping variable hasmore than two levels, then you must specify which two groups you want to compare.t.test(WR_Trt$Change~WR_Trt$Treatment,WR_Trt,Treatment%in%c(“Old_Trt”,“Test_Drug”))By default, R uses separate variance estimates when performing two-sample and paired t-tests. If you believe the variances for the two groups are equal, you can use the pooledvariance estimate. To use the pooled variance estimate, set the var.equal argument to T.Paired T-test:Paired t-test is used to compare the mean values for two samples, where eachvalue in one sample corresponds to a particular value in the other sample. It has the nullhypothesis that the two means are equal, and the alternative hypothesis that they are not equal.# paired t-testt.test(WR_Trt$Before,WR_Trt$After,paired=T)It is natural and also feasible to take before and after measurements on the same subjects, inthis case, we use Paired test.
Image of page 59
Image of page 60

You've reached the end of your free preview.

Want to read all 171 pages?

  • Summer '16
  • panut mulyono
  • Data Mining, Data Scientist

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture