SlideShare a Scribd company logo
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

Distributed datababase Transaction and concurrency control
Distributed datababase Transaction and concurrency controlDistributed datababase Transaction and concurrency control
Distributed datababase Transaction and concurrency control
balamurugan.k Kalibalamurugan
 
Difference between Homogeneous and Heterogeneous
Difference between Homogeneous  and    HeterogeneousDifference between Homogeneous  and    Heterogeneous
Difference between Homogeneous and Heterogeneous
Faraz Qaisrani
 
Synchronization - Election Algorithms
Synchronization  - Election AlgorithmsSynchronization  - Election Algorithms
Synchronization - Election Algorithms
OsaMa Hasan
 
N queen problem
N queen problemN queen problem
N queen problem
Ridhima Chowdhury
 
Knowledge based agent
Knowledge based agentKnowledge based agent
Knowledge based agent
Shiwani Gupta
 
Election algorithms
Election algorithmsElection algorithms
Election algorithmsAnkush Kumar
 
Lecture 1 introduction to parallel and distributed computing
Lecture 1   introduction to parallel and distributed computingLecture 1   introduction to parallel and distributed computing
Lecture 1 introduction to parallel and distributed computing
Vajira Thambawita
 
process creation OS
process creation OSprocess creation OS
process creation OS
Kiran Kumar Thota
 
A presentation on software crisis
A presentation on software crisisA presentation on software crisis
A presentation on software crisis
chandan sharma
 
Lec 7 query processing
Lec 7 query processingLec 7 query processing
Lec 7 query processing
Md. Mashiur Rahman
 
Communication costs in parallel machines
Communication costs in parallel machinesCommunication costs in parallel machines
Communication costs in parallel machines
Syed Zaid Irshad
 
protocols of concurrency control
protocols of concurrency controlprotocols of concurrency control
protocols of concurrency control
MOHIT DADU
 
Course outline of parallel and distributed computing
Course outline of parallel and distributed computingCourse outline of parallel and distributed computing
Course outline of parallel and distributed computing
National College of Business Administration & Economics ( NCBA&E)
 
Graph coloring problem
Graph coloring problemGraph coloring problem
Graph coloring problem
V.V.Vanniaperumal College for Women
 
ADVANCED COMPUTER ARCHITECTURE AND PARALLEL PROCESSING
ADVANCED COMPUTER ARCHITECTUREAND PARALLEL PROCESSINGADVANCED COMPUTER ARCHITECTUREAND PARALLEL PROCESSING
ADVANCED COMPUTER ARCHITECTURE AND PARALLEL PROCESSING
Zena Abo-Altaheen
 
Compiler construction tools
Compiler construction toolsCompiler construction tools
Compiler construction tools
Akhil Kaushik
 
Transaction concurrency control
Transaction concurrency controlTransaction concurrency control
Transaction concurrency controlAnand Grewal
 
Theory of Automata and formal languages unit 2
Theory of Automata and formal languages unit 2Theory of Automata and formal languages unit 2
Theory of Automata and formal languages unit 2
Abhimanyu Mishra
 

What's hot (20)

Distributed datababase Transaction and concurrency control
Distributed datababase Transaction and concurrency controlDistributed datababase Transaction and concurrency control
Distributed datababase Transaction and concurrency control
 
Difference between Homogeneous and Heterogeneous
Difference between Homogeneous  and    HeterogeneousDifference between Homogeneous  and    Heterogeneous
Difference between Homogeneous and Heterogeneous
 
Synchronization - Election Algorithms
Synchronization  - Election AlgorithmsSynchronization  - Election Algorithms
Synchronization - Election Algorithms
 
N queen problem
N queen problemN queen problem
N queen problem
 
Knowledge based agent
Knowledge based agentKnowledge based agent
Knowledge based agent
 
Election algorithms
Election algorithmsElection algorithms
Election algorithms
 
Lecture 1 introduction to parallel and distributed computing
Lecture 1   introduction to parallel and distributed computingLecture 1   introduction to parallel and distributed computing
Lecture 1 introduction to parallel and distributed computing
 
process creation OS
process creation OSprocess creation OS
process creation OS
 
A presentation on software crisis
A presentation on software crisisA presentation on software crisis
A presentation on software crisis
 
Lec 7 query processing
Lec 7 query processingLec 7 query processing
Lec 7 query processing
 
Logic agent
Logic agentLogic agent
Logic agent
 
Communication costs in parallel machines
Communication costs in parallel machinesCommunication costs in parallel machines
Communication costs in parallel machines
 
protocols of concurrency control
protocols of concurrency controlprotocols of concurrency control
protocols of concurrency control
 
Parallel Algorithms
Parallel AlgorithmsParallel Algorithms
Parallel Algorithms
 
Course outline of parallel and distributed computing
Course outline of parallel and distributed computingCourse outline of parallel and distributed computing
Course outline of parallel and distributed computing
 
Graph coloring problem
Graph coloring problemGraph coloring problem
Graph coloring problem
 
ADVANCED COMPUTER ARCHITECTURE AND PARALLEL PROCESSING
ADVANCED COMPUTER ARCHITECTUREAND PARALLEL PROCESSINGADVANCED COMPUTER ARCHITECTUREAND PARALLEL PROCESSING
ADVANCED COMPUTER ARCHITECTURE AND PARALLEL PROCESSING
 
Compiler construction tools
Compiler construction toolsCompiler construction tools
Compiler construction tools
 
Transaction concurrency control
Transaction concurrency controlTransaction concurrency control
Transaction concurrency control
 
Theory of Automata and formal languages unit 2
Theory of Automata and formal languages unit 2Theory of Automata and formal languages unit 2
Theory of Automata and formal languages unit 2
 

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 SampleAhmadullah
 
Chapter 11
Chapter 11Chapter 11
Chapter 11bmcfad01
 
Chapter11
Chapter11Chapter11
Chapter11
Richard Ferreria
 
Estimation efficiency in CRM
Estimation efficiency in CRMEstimation efficiency in CRM
Estimation efficiency in CRMTian Tian
 
Hypothesis testing
Hypothesis testingHypothesis testing
Hypothesis testing
Denni Domingo
 
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
 
S05 ad4001
S05 ad4001S05 ad4001
S05 ad4001
Jorge Ramírez
 
hypothesisTestPPT.pptx
hypothesisTestPPT.pptxhypothesisTestPPT.pptx
hypothesisTestPPT.pptx
dangwalakash07
 
1624.pptx
1624.pptx1624.pptx
1624.pptx
Jyoti863900
 
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
 
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
Hakeem-Ur- Rehman
 
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
MohammedAbdela7
 
Non Parametric Test by Vikramjit Singh
Non Parametric Test by  Vikramjit SinghNon Parametric Test by  Vikramjit Singh
Non Parametric Test by Vikramjit Singh
Vikramjit Singh
 
S06
S06S06
1192012 155942 f023_=_statistical_inference
1192012 155942 f023_=_statistical_inference1192012 155942 f023_=_statistical_inference
1192012 155942 f023_=_statistical_inferenceDev 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 anovaQasim Raza
 
Cb36469472
Cb36469472Cb36469472
Cb36469472
IJERA Editor
 

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

Call 7735293663 Satta Matka Dpboss Matka Guessing Satta batta Matka 420 Satta...
Call 7735293663 Satta Matka Dpboss Matka Guessing Satta batta Matka 420 Satta...Call 7735293663 Satta Matka Dpboss Matka Guessing Satta batta Matka 420 Satta...
Call 7735293663 Satta Matka Dpboss Matka Guessing Satta batta Matka 420 Satta...
bosssp10
 
VAT Registration Outlined In UAE: Benefits and Requirements
VAT Registration Outlined In UAE: Benefits and RequirementsVAT Registration Outlined In UAE: Benefits and Requirements
VAT Registration Outlined In UAE: Benefits and Requirements
uae taxgpt
 
Exploring Patterns of Connection with Social Dreaming
Exploring Patterns of Connection with Social DreamingExploring Patterns of Connection with Social Dreaming
Exploring Patterns of Connection with Social Dreaming
Nicola Wreford-Howard
 
Premium MEAN Stack Development Solutions for Modern Businesses
Premium MEAN Stack Development Solutions for Modern BusinessesPremium MEAN Stack Development Solutions for Modern Businesses
Premium MEAN Stack Development Solutions for Modern Businesses
SynapseIndia
 
3.0 Project 2_ Developing My Brand Identity Kit.pptx
3.0 Project 2_ Developing My Brand Identity Kit.pptx3.0 Project 2_ Developing My Brand Identity Kit.pptx
3.0 Project 2_ Developing My Brand Identity Kit.pptx
tanyjahb
 
The key differences between the MDR and IVDR in the EU
The key differences between the MDR and IVDR in the EUThe key differences between the MDR and IVDR in the EU
The key differences between the MDR and IVDR in the EU
Allensmith572606
 
Creative Web Design Company in Singapore
Creative Web Design Company in SingaporeCreative Web Design Company in Singapore
Creative Web Design Company in Singapore
techboxsqauremedia
 
Digital Transformation and IT Strategy Toolkit and Templates
Digital Transformation and IT Strategy Toolkit and TemplatesDigital Transformation and IT Strategy Toolkit and Templates
Digital Transformation and IT Strategy Toolkit and Templates
Aurelien Domont, MBA
 
The-McKinsey-7S-Framework. strategic management
The-McKinsey-7S-Framework. strategic managementThe-McKinsey-7S-Framework. strategic management
The-McKinsey-7S-Framework. strategic management
Bojamma2
 
ikea_woodgreen_petscharity_cat-alogue_digital.pdf
ikea_woodgreen_petscharity_cat-alogue_digital.pdfikea_woodgreen_petscharity_cat-alogue_digital.pdf
ikea_woodgreen_petscharity_cat-alogue_digital.pdf
agatadrynko
 
falcon-invoice-discounting-a-premier-platform-for-investors-in-india
falcon-invoice-discounting-a-premier-platform-for-investors-in-indiafalcon-invoice-discounting-a-premier-platform-for-investors-in-india
falcon-invoice-discounting-a-premier-platform-for-investors-in-india
Falcon Invoice Discounting
 
Evgen Osmak: Methods of key project parameters estimation: from the shaman-in...
Evgen Osmak: Methods of key project parameters estimation: from the shaman-in...Evgen Osmak: Methods of key project parameters estimation: from the shaman-in...
Evgen Osmak: Methods of key project parameters estimation: from the shaman-in...
Lviv Startup Club
 
20240425_ TJ Communications Credentials_compressed.pdf
20240425_ TJ Communications Credentials_compressed.pdf20240425_ TJ Communications Credentials_compressed.pdf
20240425_ TJ Communications Credentials_compressed.pdf
tjcomstrang
 
Cree_Rey_BrandIdentityKit.PDF_PersonalBd
Cree_Rey_BrandIdentityKit.PDF_PersonalBdCree_Rey_BrandIdentityKit.PDF_PersonalBd
Cree_Rey_BrandIdentityKit.PDF_PersonalBd
creerey
 
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
taqyed
 
What is the TDS Return Filing Due Date for FY 2024-25.pdf
What is the TDS Return Filing Due Date for FY 2024-25.pdfWhat is the TDS Return Filing Due Date for FY 2024-25.pdf
What is the TDS Return Filing Due Date for FY 2024-25.pdf
seoforlegalpillers
 
Improving profitability for small business
Improving profitability for small businessImproving profitability for small business
Improving profitability for small business
Ben Wann
 
Buy Verified PayPal Account | Buy Google 5 Star Reviews
Buy Verified PayPal Account | Buy Google 5 Star ReviewsBuy Verified PayPal Account | Buy Google 5 Star Reviews
Buy Verified PayPal Account | Buy Google 5 Star Reviews
usawebmarket
 
Meas_Dylan_DMBS_PB1_2024-05XX_Revised.pdf
Meas_Dylan_DMBS_PB1_2024-05XX_Revised.pdfMeas_Dylan_DMBS_PB1_2024-05XX_Revised.pdf
Meas_Dylan_DMBS_PB1_2024-05XX_Revised.pdf
dylandmeas
 
CADAVER AS OUR FIRST TEACHER anatomt in your.pptx
CADAVER AS OUR FIRST TEACHER anatomt in your.pptxCADAVER AS OUR FIRST TEACHER anatomt in your.pptx
CADAVER AS OUR FIRST TEACHER anatomt in your.pptx
fakeloginn69
 

Recently uploaded (20)

Call 7735293663 Satta Matka Dpboss Matka Guessing Satta batta Matka 420 Satta...
Call 7735293663 Satta Matka Dpboss Matka Guessing Satta batta Matka 420 Satta...Call 7735293663 Satta Matka Dpboss Matka Guessing Satta batta Matka 420 Satta...
Call 7735293663 Satta Matka Dpboss Matka Guessing Satta batta Matka 420 Satta...
 
VAT Registration Outlined In UAE: Benefits and Requirements
VAT Registration Outlined In UAE: Benefits and RequirementsVAT Registration Outlined In UAE: Benefits and Requirements
VAT Registration Outlined In UAE: Benefits and Requirements
 
Exploring Patterns of Connection with Social Dreaming
Exploring Patterns of Connection with Social DreamingExploring Patterns of Connection with Social Dreaming
Exploring Patterns of Connection with Social Dreaming
 
Premium MEAN Stack Development Solutions for Modern Businesses
Premium MEAN Stack Development Solutions for Modern BusinessesPremium MEAN Stack Development Solutions for Modern Businesses
Premium MEAN Stack Development Solutions for Modern Businesses
 
3.0 Project 2_ Developing My Brand Identity Kit.pptx
3.0 Project 2_ Developing My Brand Identity Kit.pptx3.0 Project 2_ Developing My Brand Identity Kit.pptx
3.0 Project 2_ Developing My Brand Identity Kit.pptx
 
The key differences between the MDR and IVDR in the EU
The key differences between the MDR and IVDR in the EUThe key differences between the MDR and IVDR in the EU
The key differences between the MDR and IVDR in the EU
 
Creative Web Design Company in Singapore
Creative Web Design Company in SingaporeCreative Web Design Company in Singapore
Creative Web Design Company in Singapore
 
Digital Transformation and IT Strategy Toolkit and Templates
Digital Transformation and IT Strategy Toolkit and TemplatesDigital Transformation and IT Strategy Toolkit and Templates
Digital Transformation and IT Strategy Toolkit and Templates
 
The-McKinsey-7S-Framework. strategic management
The-McKinsey-7S-Framework. strategic managementThe-McKinsey-7S-Framework. strategic management
The-McKinsey-7S-Framework. strategic management
 
ikea_woodgreen_petscharity_cat-alogue_digital.pdf
ikea_woodgreen_petscharity_cat-alogue_digital.pdfikea_woodgreen_petscharity_cat-alogue_digital.pdf
ikea_woodgreen_petscharity_cat-alogue_digital.pdf
 
falcon-invoice-discounting-a-premier-platform-for-investors-in-india
falcon-invoice-discounting-a-premier-platform-for-investors-in-indiafalcon-invoice-discounting-a-premier-platform-for-investors-in-india
falcon-invoice-discounting-a-premier-platform-for-investors-in-india
 
Evgen Osmak: Methods of key project parameters estimation: from the shaman-in...
Evgen Osmak: Methods of key project parameters estimation: from the shaman-in...Evgen Osmak: Methods of key project parameters estimation: from the shaman-in...
Evgen Osmak: Methods of key project parameters estimation: from the shaman-in...
 
20240425_ TJ Communications Credentials_compressed.pdf
20240425_ TJ Communications Credentials_compressed.pdf20240425_ TJ Communications Credentials_compressed.pdf
20240425_ TJ Communications Credentials_compressed.pdf
 
Cree_Rey_BrandIdentityKit.PDF_PersonalBd
Cree_Rey_BrandIdentityKit.PDF_PersonalBdCree_Rey_BrandIdentityKit.PDF_PersonalBd
Cree_Rey_BrandIdentityKit.PDF_PersonalBd
 
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
 
What is the TDS Return Filing Due Date for FY 2024-25.pdf
What is the TDS Return Filing Due Date for FY 2024-25.pdfWhat is the TDS Return Filing Due Date for FY 2024-25.pdf
What is the TDS Return Filing Due Date for FY 2024-25.pdf
 
Improving profitability for small business
Improving profitability for small businessImproving profitability for small business
Improving profitability for small business
 
Buy Verified PayPal Account | Buy Google 5 Star Reviews
Buy Verified PayPal Account | Buy Google 5 Star ReviewsBuy Verified PayPal Account | Buy Google 5 Star Reviews
Buy Verified PayPal Account | Buy Google 5 Star Reviews
 
Meas_Dylan_DMBS_PB1_2024-05XX_Revised.pdf
Meas_Dylan_DMBS_PB1_2024-05XX_Revised.pdfMeas_Dylan_DMBS_PB1_2024-05XX_Revised.pdf
Meas_Dylan_DMBS_PB1_2024-05XX_Revised.pdf
 
CADAVER AS OUR FIRST TEACHER anatomt in your.pptx
CADAVER AS OUR FIRST TEACHER anatomt in your.pptxCADAVER AS OUR FIRST TEACHER anatomt in your.pptx
CADAVER AS OUR FIRST TEACHER anatomt in your.pptx
 

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