SlideShare a Scribd company logo
1 of 12
Hypothesis Testing in R
Codes are in Blue.
For Feedback Mail me: sharmakarishma91@gmail.com
Contents
• One-sample tests
• Two-sample t-Tests
• Paired t-Tests
One-sample t-tests
An outbreak of Salmonella-related illness was attributed to ice
cream produced at a certain factory. Scientists measured the
level of Salmonella in 9 randomly sampled batches of ice
cream.
The levels (in MPN/g) were:
0.593 0.142 0.329 0.691 0.231 0.793 0.519 0.392 0.418
Is there evidence that the mean level of Salmonella in the ice
cream is greater than 0.3 MPN/g?
For Feedback Mail me: sharmakarishma91@gmail.com
Contd..
Let mu be the mean level of Salmonella in all batches of ice
cream. Here the hypothesis of interest can be expressed as:
H0: mu= 0.3
Ha: mu> 0.3
Hence, we will need to include the options
alternative="greater", mu=0.3.
x = c(0.593, 0.142, 0.329, 0.691, 0.231, 0.793, 0.519, 0.392,
0.418)
t.test(x, alternative="greater", mu=0.3)
p-value = 0.029. Hence, there is moderately strong evidence that
the mean Salmonella level in the ice cream is above 0.3
MPN/g.
For Feedback Mail me: sharmakarishma91@gmail.com
Contd..
• The t.test function prints out a confidence interval as well.
• However this function returns a one-sided interval when the
alternative is "greater" or "less".
• When alternative = "greater" is chosen the lower confidence
bound is calculated and the upper bound is given as Inf by
default.
• When alternative = "less" is chosen the upper confidence
bound is calculated and the lower bound is given as -Inf by
default.
• When alternative = "two.sided" is chosen both the upper and
the lower condence bounds are calculated.
For Feedback Mail me: sharmakarishma91@gmail.com
Two-sample t-tests
Subjects were given a drug (treatment group) and an additional
6 subjects a placebo (control group). Their reaction time to a
stimulus was measured (in ms). We want to perform a two-
sample t-test for comparing the means of the treatment and
control groups.
For Feedback Mail me: sharmakarishma91@gmail.com
Contd..
Let mu1 be the mean of the population taking medicine and
mu2 the mean of the untreated population. Here the
hypothesis of interest can be expressed as:
H0: mu1-mu2=0
Ha: mu1-mu2<0
Here we will need to include the data for the treatment group in
x and the data for the control group in y. We will also need to
include the options alternative="less", mu=0.
Finally, we need to decide whether or not the standard
deviations are the same in both groups.
For Feedback Mail me: sharmakarishma91@gmail.com
Contd..
Control = c(91, 87, 99, 77, 88, 91)
Treat = c(101, 110, 103, 93, 99, 104)
t.test(Control,Treat,alternative="less", var.equal=TRUE)
#when not assuming equal standard deviation:
t.test(Control,Treat,alternative="less")
For Feedback Mail me: sharmakarishma91@gmail.com
Paired t-tests
There are many experimental settings where each subject in the
study is in both the treatment and control group. For
example, in a matched pairs design, subjects are matched in
pairs and different treatments are given to each subject in the
pair. The outcomes are thereafter compared pair-wise.
Alternatively, one can measure each subject twice, before
and after a treatment. In either of these situations we can’t
use two-sample t-tests since the independence assumption is
not valid. Instead we need to use a paired t-test. This can be
done using the option paired =TRUE.
For Feedback Mail me: sharmakarishma91@gmail.com
Contd..
PROBLEM
A study was performed to test whether cars get better mileage
on premium gas than on regular gas. Each of 10 cars was first
filled with either regular or premium gas, decided by a coin
toss, and the mileage for that tank was recorded. The mileage
was recorded again for the same cars using the other kind of
gasoline. We use a paired t-test to determine whether cars
get significantly better mileage with premium gas.
For Feedback Mail me: sharmakarishma91@gmail.com
Contd..
reg = c(16, 20, 21, 22, 23, 22, 27, 25, 27, 28)
prem = c(19, 22, 24, 24, 25, 25, 26, 26, 28, 32)
t.test(prem,reg,alternative="greater", paired=TRUE)
The results show that the t-statistic is equal to 4.47 and the p-
value is 0.00075. Since the p-value is very low, we reject the
null hypothesis. There is strong evidence of a mean increase
in gas mileage between regular and premium gasoline.
For Feedback Mail me: sharmakarishma91@gmail.com
THANK YOU.
Reference: http://cran.r-project.org/
For Feedback Mail me: sharmakarishma91@gmail.com

More Related Content

What's hot

Accenture Salesforce Solutions
Accenture Salesforce SolutionsAccenture Salesforce Solutions
Accenture Salesforce Solutions
Tarik Schmidt
 

What's hot (20)

Cloud computing risk & challenges
Cloud computing risk & challengesCloud computing risk & challenges
Cloud computing risk & challenges
 
IaaS, SaaS, PasS : Cloud Computing
IaaS, SaaS, PasS : Cloud ComputingIaaS, SaaS, PasS : Cloud Computing
IaaS, SaaS, PasS : Cloud Computing
 
Distcp
DistcpDistcp
Distcp
 
Introduction to AWS Cloud Computing
Introduction to AWS Cloud ComputingIntroduction to AWS Cloud Computing
Introduction to AWS Cloud Computing
 
SaaS Presentation at SCIT Conference
SaaS Presentation at SCIT ConferenceSaaS Presentation at SCIT Conference
SaaS Presentation at SCIT Conference
 
Accenture Salesforce Solutions
Accenture Salesforce SolutionsAccenture Salesforce Solutions
Accenture Salesforce Solutions
 
Financial Service Cloud- Release Readiness LIVE, Winter’21
Financial Service Cloud- Release Readiness LIVE, Winter’21Financial Service Cloud- Release Readiness LIVE, Winter’21
Financial Service Cloud- Release Readiness LIVE, Winter’21
 
Getting Started with AWS Database Migration Service
Getting Started with AWS Database Migration ServiceGetting Started with AWS Database Migration Service
Getting Started with AWS Database Migration Service
 
On Premise vs Cloud Computing | Cloud Certification Training | Edureka
On Premise vs Cloud Computing | Cloud Certification Training | EdurekaOn Premise vs Cloud Computing | Cloud Certification Training | Edureka
On Premise vs Cloud Computing | Cloud Certification Training | Edureka
 
Cloud Computing Architecture
Cloud Computing ArchitectureCloud Computing Architecture
Cloud Computing Architecture
 
A non-technical introduction to Cloud Computing
A non-technical introduction to Cloud ComputingA non-technical introduction to Cloud Computing
A non-technical introduction to Cloud Computing
 
CLOUD COMPUTING UNIT-5 NOTES
CLOUD COMPUTING UNIT-5 NOTESCLOUD COMPUTING UNIT-5 NOTES
CLOUD COMPUTING UNIT-5 NOTES
 
Differences between OpenStack and AWS
Differences between OpenStack and AWSDifferences between OpenStack and AWS
Differences between OpenStack and AWS
 
Genetic Algorithm for task scheduling in Cloud Computing Environment
Genetic Algorithm for task scheduling in Cloud Computing EnvironmentGenetic Algorithm for task scheduling in Cloud Computing Environment
Genetic Algorithm for task scheduling in Cloud Computing Environment
 
A New Chapter of Data Processing with CDK
A New Chapter of Data Processing with CDKA New Chapter of Data Processing with CDK
A New Chapter of Data Processing with CDK
 
Fog computing
Fog computingFog computing
Fog computing
 
Introduction to Microsoft Azure Cloud
Introduction to Microsoft Azure CloudIntroduction to Microsoft Azure Cloud
Introduction to Microsoft Azure Cloud
 
Salesforce Multitenant Architecture: How We Do the Magic We Do
Salesforce Multitenant Architecture: How We Do the Magic We DoSalesforce Multitenant Architecture: How We Do the Magic We Do
Salesforce Multitenant Architecture: How We Do the Magic We Do
 
GPSTEC201_Building an Artificial Intelligence Practice for Consulting Partners
GPSTEC201_Building an Artificial Intelligence Practice for Consulting PartnersGPSTEC201_Building an Artificial Intelligence Practice for Consulting Partners
GPSTEC201_Building an Artificial Intelligence Practice for Consulting Partners
 
Cloud Mashup
Cloud MashupCloud Mashup
Cloud Mashup
 

Similar to Hypothesis testing in R

Lecture 7 Hypothesis Testing Two Sample
Lecture 7 Hypothesis Testing Two SampleLecture 7 Hypothesis Testing Two Sample
Lecture 7 Hypothesis Testing Two Sample
Ahmadullah
 
Chapter 11
Chapter 11Chapter 11
Chapter 11
bmcfad01
 
Estimation efficiency in CRM
Estimation efficiency in CRMEstimation efficiency in CRM
Estimation efficiency in CRM
Tian Tian
 
The following calendar-year information is taken from the December.docx
The following calendar-year information is taken from the December.docxThe following calendar-year information is taken from the December.docx
The following calendar-year information is taken from the December.docx
cherry686017
 
Hypothesis Testing techniques in social research.ppt
Hypothesis Testing techniques in social research.pptHypothesis Testing techniques in social research.ppt
Hypothesis Testing techniques in social research.ppt
Solomonkiplimo
 
1192012 155942 f023_=_statistical_inference
1192012 155942 f023_=_statistical_inference1192012 155942 f023_=_statistical_inference
1192012 155942 f023_=_statistical_inference
Dev Pandey
 
T test, independant sample, paired sample and anova
T test, independant sample, paired sample and anovaT test, independant sample, paired sample and anova
T test, independant sample, paired sample and anova
Qasim Raza
 

Similar to Hypothesis testing in R (20)

Chapter11
Chapter11Chapter11
Chapter11
 
Lecture 7 Hypothesis Testing Two Sample
Lecture 7 Hypothesis Testing Two SampleLecture 7 Hypothesis Testing Two Sample
Lecture 7 Hypothesis Testing Two Sample
 
Chapter 11
Chapter 11Chapter 11
Chapter 11
 
Chapter11
Chapter11Chapter11
Chapter11
 
Estimation efficiency in CRM
Estimation efficiency in CRMEstimation efficiency in CRM
Estimation efficiency in CRM
 
Hypothesis testing
Hypothesis testingHypothesis testing
Hypothesis testing
 
The following calendar-year information is taken from the December.docx
The following calendar-year information is taken from the December.docxThe following calendar-year information is taken from the December.docx
The following calendar-year information is taken from the December.docx
 
S05 ad4001
S05 ad4001S05 ad4001
S05 ad4001
 
hypothesisTestPPT.pptx
hypothesisTestPPT.pptxhypothesisTestPPT.pptx
hypothesisTestPPT.pptx
 
One way anova
One way anovaOne way anova
One way anova
 
1624.pptx
1624.pptx1624.pptx
1624.pptx
 
Chapter15
Chapter15Chapter15
Chapter15
 
Hypothesis Testing techniques in social research.ppt
Hypothesis Testing techniques in social research.pptHypothesis Testing techniques in social research.ppt
Hypothesis Testing techniques in social research.ppt
 
8. testing of hypothesis for variable &amp; attribute data
8. testing of hypothesis for variable &amp; attribute  data8. testing of hypothesis for variable &amp; attribute  data
8. testing of hypothesis for variable &amp; attribute data
 
t-test and one way ANOVA.ppt game.ppt
t-test and one way ANOVA.ppt game.pptt-test and one way ANOVA.ppt game.ppt
t-test and one way ANOVA.ppt game.ppt
 
Non Parametric Test by Vikramjit Singh
Non Parametric Test by  Vikramjit SinghNon Parametric Test by  Vikramjit Singh
Non Parametric Test by Vikramjit Singh
 
S06
S06S06
S06
 
1192012 155942 f023_=_statistical_inference
1192012 155942 f023_=_statistical_inference1192012 155942 f023_=_statistical_inference
1192012 155942 f023_=_statistical_inference
 
T test, independant sample, paired sample and anova
T test, independant sample, paired sample and anovaT test, independant sample, paired sample and anova
T test, independant sample, paired sample and anova
 
Cb36469472
Cb36469472Cb36469472
Cb36469472
 

Recently uploaded

Chandigarh Escorts Service 📞8868886958📞 Just📲 Call Nihal Chandigarh Call Girl...
Chandigarh Escorts Service 📞8868886958📞 Just📲 Call Nihal Chandigarh Call Girl...Chandigarh Escorts Service 📞8868886958📞 Just📲 Call Nihal Chandigarh Call Girl...
Chandigarh Escorts Service 📞8868886958📞 Just📲 Call Nihal Chandigarh Call Girl...
Sheetaleventcompany
 
Call Girls From Pari Chowk Greater Noida ❤️8448577510 ⊹Best Escorts Service I...
Call Girls From Pari Chowk Greater Noida ❤️8448577510 ⊹Best Escorts Service I...Call Girls From Pari Chowk Greater Noida ❤️8448577510 ⊹Best Escorts Service I...
Call Girls From Pari Chowk Greater Noida ❤️8448577510 ⊹Best Escorts Service I...
lizamodels9
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
dollysharma2066
 
Russian Call Girls In Rajiv Chowk Gurgaon ❤️8448577510 ⊹Best Escorts Service ...
Russian Call Girls In Rajiv Chowk Gurgaon ❤️8448577510 ⊹Best Escorts Service ...Russian Call Girls In Rajiv Chowk Gurgaon ❤️8448577510 ⊹Best Escorts Service ...
Russian Call Girls In Rajiv Chowk Gurgaon ❤️8448577510 ⊹Best Escorts Service ...
lizamodels9
 
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
lizamodels9
 
Call Now ☎️🔝 9332606886🔝 Call Girls ❤ Service In Bhilwara Female Escorts Serv...
Call Now ☎️🔝 9332606886🔝 Call Girls ❤ Service In Bhilwara Female Escorts Serv...Call Now ☎️🔝 9332606886🔝 Call Girls ❤ Service In Bhilwara Female Escorts Serv...
Call Now ☎️🔝 9332606886🔝 Call Girls ❤ Service In Bhilwara Female Escorts Serv...
Anamikakaur10
 
The Abortion pills for sale in Qatar@Doha [+27737758557] []Deira Dubai Kuwait
The Abortion pills for sale in Qatar@Doha [+27737758557] []Deira Dubai KuwaitThe Abortion pills for sale in Qatar@Doha [+27737758557] []Deira Dubai Kuwait
The Abortion pills for sale in Qatar@Doha [+27737758557] []Deira Dubai Kuwait
daisycvs
 
Call Girls Kengeri Satellite Town Just Call 👗 7737669865 👗 Top Class Call Gir...
Call Girls Kengeri Satellite Town Just Call 👗 7737669865 👗 Top Class Call Gir...Call Girls Kengeri Satellite Town Just Call 👗 7737669865 👗 Top Class Call Gir...
Call Girls Kengeri Satellite Town Just Call 👗 7737669865 👗 Top Class Call Gir...
amitlee9823
 
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756
dollysharma2066
 
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
dlhescort
 
Al Mizhar Dubai Escorts +971561403006 Escorts Service In Al Mizhar
Al Mizhar Dubai Escorts +971561403006 Escorts Service In Al MizharAl Mizhar Dubai Escorts +971561403006 Escorts Service In Al Mizhar
Al Mizhar Dubai Escorts +971561403006 Escorts Service In Al Mizhar
allensay1
 

Recently uploaded (20)

Chandigarh Escorts Service 📞8868886958📞 Just📲 Call Nihal Chandigarh Call Girl...
Chandigarh Escorts Service 📞8868886958📞 Just📲 Call Nihal Chandigarh Call Girl...Chandigarh Escorts Service 📞8868886958📞 Just📲 Call Nihal Chandigarh Call Girl...
Chandigarh Escorts Service 📞8868886958📞 Just📲 Call Nihal Chandigarh Call Girl...
 
Call Girls From Pari Chowk Greater Noida ❤️8448577510 ⊹Best Escorts Service I...
Call Girls From Pari Chowk Greater Noida ❤️8448577510 ⊹Best Escorts Service I...Call Girls From Pari Chowk Greater Noida ❤️8448577510 ⊹Best Escorts Service I...
Call Girls From Pari Chowk Greater Noida ❤️8448577510 ⊹Best Escorts Service I...
 
Organizational Transformation Lead with Culture
Organizational Transformation Lead with CultureOrganizational Transformation Lead with Culture
Organizational Transformation Lead with Culture
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
Russian Call Girls In Rajiv Chowk Gurgaon ❤️8448577510 ⊹Best Escorts Service ...
Russian Call Girls In Rajiv Chowk Gurgaon ❤️8448577510 ⊹Best Escorts Service ...Russian Call Girls In Rajiv Chowk Gurgaon ❤️8448577510 ⊹Best Escorts Service ...
Russian Call Girls In Rajiv Chowk Gurgaon ❤️8448577510 ⊹Best Escorts Service ...
 
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
 
Call Now ☎️🔝 9332606886🔝 Call Girls ❤ Service In Bhilwara Female Escorts Serv...
Call Now ☎️🔝 9332606886🔝 Call Girls ❤ Service In Bhilwara Female Escorts Serv...Call Now ☎️🔝 9332606886🔝 Call Girls ❤ Service In Bhilwara Female Escorts Serv...
Call Now ☎️🔝 9332606886🔝 Call Girls ❤ Service In Bhilwara Female Escorts Serv...
 
Unveiling Falcon Invoice Discounting: Leading the Way as India's Premier Bill...
Unveiling Falcon Invoice Discounting: Leading the Way as India's Premier Bill...Unveiling Falcon Invoice Discounting: Leading the Way as India's Premier Bill...
Unveiling Falcon Invoice Discounting: Leading the Way as India's Premier Bill...
 
Value Proposition canvas- Customer needs and pains
Value Proposition canvas- Customer needs and painsValue Proposition canvas- Customer needs and pains
Value Proposition canvas- Customer needs and pains
 
The Abortion pills for sale in Qatar@Doha [+27737758557] []Deira Dubai Kuwait
The Abortion pills for sale in Qatar@Doha [+27737758557] []Deira Dubai KuwaitThe Abortion pills for sale in Qatar@Doha [+27737758557] []Deira Dubai Kuwait
The Abortion pills for sale in Qatar@Doha [+27737758557] []Deira Dubai Kuwait
 
Call Girls Kengeri Satellite Town Just Call 👗 7737669865 👗 Top Class Call Gir...
Call Girls Kengeri Satellite Town Just Call 👗 7737669865 👗 Top Class Call Gir...Call Girls Kengeri Satellite Town Just Call 👗 7737669865 👗 Top Class Call Gir...
Call Girls Kengeri Satellite Town Just Call 👗 7737669865 👗 Top Class Call Gir...
 
SEO Case Study: How I Increased SEO Traffic & Ranking by 50-60% in 6 Months
SEO Case Study: How I Increased SEO Traffic & Ranking by 50-60%  in 6 MonthsSEO Case Study: How I Increased SEO Traffic & Ranking by 50-60%  in 6 Months
SEO Case Study: How I Increased SEO Traffic & Ranking by 50-60% in 6 Months
 
Eluru Call Girls Service ☎ ️93326-06886 ❤️‍🔥 Enjoy 24/7 Escort Service
Eluru Call Girls Service ☎ ️93326-06886 ❤️‍🔥 Enjoy 24/7 Escort ServiceEluru Call Girls Service ☎ ️93326-06886 ❤️‍🔥 Enjoy 24/7 Escort Service
Eluru Call Girls Service ☎ ️93326-06886 ❤️‍🔥 Enjoy 24/7 Escort Service
 
Falcon's Invoice Discounting: Your Path to Prosperity
Falcon's Invoice Discounting: Your Path to ProsperityFalcon's Invoice Discounting: Your Path to Prosperity
Falcon's Invoice Discounting: Your Path to Prosperity
 
PHX May 2024 Corporate Presentation Final
PHX May 2024 Corporate Presentation FinalPHX May 2024 Corporate Presentation Final
PHX May 2024 Corporate Presentation Final
 
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756
 
How to Get Started in Social Media for Art League City
How to Get Started in Social Media for Art League CityHow to Get Started in Social Media for Art League City
How to Get Started in Social Media for Art League City
 
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
 
Al Mizhar Dubai Escorts +971561403006 Escorts Service In Al Mizhar
Al Mizhar Dubai Escorts +971561403006 Escorts Service In Al MizharAl Mizhar Dubai Escorts +971561403006 Escorts Service In Al Mizhar
Al Mizhar Dubai Escorts +971561403006 Escorts Service In Al Mizhar
 
Business Model Canvas (BMC)- A new venture concept
Business Model Canvas (BMC)-  A new venture conceptBusiness Model Canvas (BMC)-  A new venture concept
Business Model Canvas (BMC)- A new venture concept
 

Hypothesis testing in R

  • 1. Hypothesis Testing in R Codes are in Blue. For Feedback Mail me: sharmakarishma91@gmail.com
  • 2. Contents • One-sample tests • Two-sample t-Tests • Paired t-Tests
  • 3. One-sample t-tests An outbreak of Salmonella-related illness was attributed to ice cream produced at a certain factory. Scientists measured the level of Salmonella in 9 randomly sampled batches of ice cream. The levels (in MPN/g) were: 0.593 0.142 0.329 0.691 0.231 0.793 0.519 0.392 0.418 Is there evidence that the mean level of Salmonella in the ice cream is greater than 0.3 MPN/g? For Feedback Mail me: sharmakarishma91@gmail.com
  • 4. Contd.. Let mu be the mean level of Salmonella in all batches of ice cream. Here the hypothesis of interest can be expressed as: H0: mu= 0.3 Ha: mu> 0.3 Hence, we will need to include the options alternative="greater", mu=0.3. x = c(0.593, 0.142, 0.329, 0.691, 0.231, 0.793, 0.519, 0.392, 0.418) t.test(x, alternative="greater", mu=0.3) p-value = 0.029. Hence, there is moderately strong evidence that the mean Salmonella level in the ice cream is above 0.3 MPN/g. For Feedback Mail me: sharmakarishma91@gmail.com
  • 5. Contd.. • The t.test function prints out a confidence interval as well. • However this function returns a one-sided interval when the alternative is "greater" or "less". • When alternative = "greater" is chosen the lower confidence bound is calculated and the upper bound is given as Inf by default. • When alternative = "less" is chosen the upper confidence bound is calculated and the lower bound is given as -Inf by default. • When alternative = "two.sided" is chosen both the upper and the lower condence bounds are calculated. For Feedback Mail me: sharmakarishma91@gmail.com
  • 6. Two-sample t-tests Subjects were given a drug (treatment group) and an additional 6 subjects a placebo (control group). Their reaction time to a stimulus was measured (in ms). We want to perform a two- sample t-test for comparing the means of the treatment and control groups. For Feedback Mail me: sharmakarishma91@gmail.com
  • 7. Contd.. Let mu1 be the mean of the population taking medicine and mu2 the mean of the untreated population. Here the hypothesis of interest can be expressed as: H0: mu1-mu2=0 Ha: mu1-mu2<0 Here we will need to include the data for the treatment group in x and the data for the control group in y. We will also need to include the options alternative="less", mu=0. Finally, we need to decide whether or not the standard deviations are the same in both groups. For Feedback Mail me: sharmakarishma91@gmail.com
  • 8. Contd.. Control = c(91, 87, 99, 77, 88, 91) Treat = c(101, 110, 103, 93, 99, 104) t.test(Control,Treat,alternative="less", var.equal=TRUE) #when not assuming equal standard deviation: t.test(Control,Treat,alternative="less") For Feedback Mail me: sharmakarishma91@gmail.com
  • 9. Paired t-tests There are many experimental settings where each subject in the study is in both the treatment and control group. For example, in a matched pairs design, subjects are matched in pairs and different treatments are given to each subject in the pair. The outcomes are thereafter compared pair-wise. Alternatively, one can measure each subject twice, before and after a treatment. In either of these situations we can’t use two-sample t-tests since the independence assumption is not valid. Instead we need to use a paired t-test. This can be done using the option paired =TRUE. For Feedback Mail me: sharmakarishma91@gmail.com
  • 10. Contd.. PROBLEM A study was performed to test whether cars get better mileage on premium gas than on regular gas. Each of 10 cars was first filled with either regular or premium gas, decided by a coin toss, and the mileage for that tank was recorded. The mileage was recorded again for the same cars using the other kind of gasoline. We use a paired t-test to determine whether cars get significantly better mileage with premium gas. For Feedback Mail me: sharmakarishma91@gmail.com
  • 11. Contd.. reg = c(16, 20, 21, 22, 23, 22, 27, 25, 27, 28) prem = c(19, 22, 24, 24, 25, 25, 26, 26, 28, 32) t.test(prem,reg,alternative="greater", paired=TRUE) The results show that the t-statistic is equal to 4.47 and the p- value is 0.00075. Since the p-value is very low, we reject the null hypothesis. There is strong evidence of a mean increase in gas mileage between regular and premium gasoline. For Feedback Mail me: sharmakarishma91@gmail.com
  • 12. THANK YOU. Reference: http://cran.r-project.org/ For Feedback Mail me: sharmakarishma91@gmail.com