SlideShare a Scribd company logo
1 of 10
ANOVA
ANALYSIS OF VARIANCE
What is ANOVA ?
 Analysis of Variance (ANOVA) is a statistical technique,
commonly used to studying differences between two or more group
means.
 ANOVA test is centered on the different sources of variation in a
typical variable.
 ANOVA in R primarily provides evidence of the existence of the
mean equality between the groups.
 This statistical method is an extension of the t-test.
 It is used in a situation where the factor variable has more than one
group.
One-way ANOVA
 There are many situations where you need to compare the mean
between multiple groups. For instance, the marketing department
wants to know if three teams have the same sales performance.
 Team: 3 level factor: A, B, and C
 Sale: A measure of performance
 The ANOVA test can tell if the three groups have similar
performances.
 To clarify if the data comes from the same population, you can
perform a one-way analysis of variance
Hypothesis in one-way ANOVA test
 H0: The means between groups are identical
 H3: At least, the mean of one group is different
 In other words, the H0 hypothesis implies that there is not enough
evidence to prove the mean of the group (factor) are different from
another.
 This test is similar to the t-test, although ANOVA test is
recommended in situation with more than 2 groups.
Initials in R
 install.packages(c("ggplot2", "ggpubr", "tidyverse", "broom",
"AICcmodavg"))
 library(ggplot2)
library(ggpubr)
library(tidyverse)
library(broom)
library(AICcmodavg)
Loading Data in R
 crop.data <- read.csv("path/to/your/file/crop.data.csv", header = TRUE, colClasses
= c("factor", "factor", "factor", "numeric"))
 Specifying within the command whether each of the variables should be
quantitative (“numeric”) or categorical (“factor”).
 Summary(crop.data)
 read.csv(file.choose(), colClasses = c("factor", "factor", "factor", "numeric") )
Applying in R
one.way <- aov(yield ~ fertilizer, data = crop.data)
Summary(one.way)
 The model summary first lists the independent variables being tested in the model (in this case
we have only one, ‘fertilizer’) and the model residuals (‘Residual’). All of the variation that is
not explained by the independent variables is called residual variance.
 The rest of the values in the output table describe the independent variable and the residuals:
 The Df column displays the degrees of freedom for the independent variable (the number of
levels in the variable minus 1), and the degrees of freedom for the residuals (the total number of
observations minus one and minus the number of levels in the independent variables).
 The Sum Sq column displays the sum of squares (a.k.a. the total variation between the group
means and the overall mean).
 The Mean Sq column is the mean of the sum of squares, calculated by dividing the sum of
squares by the degrees of freedom for each parameter.
 The F-value column is the test statistic from the F test. This is the mean square of each
independent variable divided by the mean square of the residuals. The larger the F value, the
more likely it is that the variation caused by the independent variable is real and not due to
chance.
 The Pr(>F) column is the p-value of the F-statistic. This shows how likely it is that the F-value
calculated from the test would have occurred if the null hypothesis of no difference among
group means were true.
 The p-value of the fertilizer variable is low (p < 0.001), so it appears that the type of fertilizer
used has a real impact on the final crop yield
Two way ANOVA
 In the two-way ANOVA example, we are modeling crop yield as a function of
type of fertilizer and planting density.
 two.way <- aov(yield ~ fertilizer + density, data = crop.data
 summary(two.way)
 Adding planting density to the model seems to have made the model better: it
reduced the residual variance (the residual sum of squares went from 35.89 to
30.765), and both planting density and fertilizer are statistically significant (p-
values < 0.001)
Adding interactions between variables
 Sometimes you have reason to think that two of your independent
variables have an interaction effect rather than an additive effect.
 For example, in our crop yield experiment, it is possible that
planting density affects the plants’ ability to take up fertilizer. This
might influence the effect of fertilizer type in a way that isn’t
accounted for in the two-way model.
 To test whether two variables have an interaction effect in ANOVA,
simply use an asterisk instead of a plus-sign in the model

More Related Content

What's hot

Cluster spss week7
Cluster spss week7Cluster spss week7
Cluster spss week7Birat Sharma
 
Presentation On Regression
Presentation On RegressionPresentation On Regression
Presentation On Regressionalok tiwari
 
Linear Regression With R
Linear Regression With RLinear Regression With R
Linear Regression With REdureka!
 
9. basic concepts_of_one_way_analysis_of_variance_(anova)
9. basic concepts_of_one_way_analysis_of_variance_(anova)9. basic concepts_of_one_way_analysis_of_variance_(anova)
9. basic concepts_of_one_way_analysis_of_variance_(anova)Irfan Hussain
 
Simple linear regression
Simple linear regressionSimple linear regression
Simple linear regressionpankaj8108
 
Data Science - Part XII - Ridge Regression, LASSO, and Elastic Nets
Data Science - Part XII - Ridge Regression, LASSO, and Elastic NetsData Science - Part XII - Ridge Regression, LASSO, and Elastic Nets
Data Science - Part XII - Ridge Regression, LASSO, and Elastic NetsDerek Kane
 
Analysis of variance (ANOVA) everything you need to know
Analysis of variance (ANOVA) everything you need to knowAnalysis of variance (ANOVA) everything you need to know
Analysis of variance (ANOVA) everything you need to knowStat Analytica
 
Simple Linear Regression (simplified)
Simple Linear Regression (simplified)Simple Linear Regression (simplified)
Simple Linear Regression (simplified)Haoran Zhang
 
Linear regression
Linear regressionLinear regression
Linear regressionSreerajVA
 
Regression (Linear Regression and Logistic Regression) by Akanksha Bali
Regression (Linear Regression and Logistic Regression) by Akanksha BaliRegression (Linear Regression and Logistic Regression) by Akanksha Bali
Regression (Linear Regression and Logistic Regression) by Akanksha BaliAkanksha Bali
 
4.5. logistic regression
4.5. logistic regression4.5. logistic regression
4.5. logistic regressionA M
 
Binary OR Binomial logistic regression
Binary OR Binomial logistic regression Binary OR Binomial logistic regression
Binary OR Binomial logistic regression Dr Athar Khan
 
Chart and graphs in R programming language
Chart and graphs in R programming language Chart and graphs in R programming language
Chart and graphs in R programming language CHANDAN KUMAR
 
Exploratory data analysis in R - Data Science Club
Exploratory data analysis in R - Data Science ClubExploratory data analysis in R - Data Science Club
Exploratory data analysis in R - Data Science ClubMartin Bago
 

What's hot (20)

Cluster spss week7
Cluster spss week7Cluster spss week7
Cluster spss week7
 
Linear regression
Linear regressionLinear regression
Linear regression
 
Presentation On Regression
Presentation On RegressionPresentation On Regression
Presentation On Regression
 
Data Management in R
Data Management in RData Management in R
Data Management in R
 
Linear regression
Linear regressionLinear regression
Linear regression
 
Linear Regression With R
Linear Regression With RLinear Regression With R
Linear Regression With R
 
9. basic concepts_of_one_way_analysis_of_variance_(anova)
9. basic concepts_of_one_way_analysis_of_variance_(anova)9. basic concepts_of_one_way_analysis_of_variance_(anova)
9. basic concepts_of_one_way_analysis_of_variance_(anova)
 
Simple linear regression
Simple linear regressionSimple linear regression
Simple linear regression
 
Logistic regression
Logistic regressionLogistic regression
Logistic regression
 
Data Science - Part XII - Ridge Regression, LASSO, and Elastic Nets
Data Science - Part XII - Ridge Regression, LASSO, and Elastic NetsData Science - Part XII - Ridge Regression, LASSO, and Elastic Nets
Data Science - Part XII - Ridge Regression, LASSO, and Elastic Nets
 
Analysis of variance (ANOVA) everything you need to know
Analysis of variance (ANOVA) everything you need to knowAnalysis of variance (ANOVA) everything you need to know
Analysis of variance (ANOVA) everything you need to know
 
Simple Linear Regression (simplified)
Simple Linear Regression (simplified)Simple Linear Regression (simplified)
Simple Linear Regression (simplified)
 
Linear regression
Linear regressionLinear regression
Linear regression
 
Regression (Linear Regression and Logistic Regression) by Akanksha Bali
Regression (Linear Regression and Logistic Regression) by Akanksha BaliRegression (Linear Regression and Logistic Regression) by Akanksha Bali
Regression (Linear Regression and Logistic Regression) by Akanksha Bali
 
R decision tree
R   decision treeR   decision tree
R decision tree
 
4.5. logistic regression
4.5. logistic regression4.5. logistic regression
4.5. logistic regression
 
Simple linear regression
Simple linear regressionSimple linear regression
Simple linear regression
 
Binary OR Binomial logistic regression
Binary OR Binomial logistic regression Binary OR Binomial logistic regression
Binary OR Binomial logistic regression
 
Chart and graphs in R programming language
Chart and graphs in R programming language Chart and graphs in R programming language
Chart and graphs in R programming language
 
Exploratory data analysis in R - Data Science Club
Exploratory data analysis in R - Data Science ClubExploratory data analysis in R - Data Science Club
Exploratory data analysis in R - Data Science Club
 

Similar to ANOVA in R by Aman Chauhan

Medical Statistics Part-II:Inferential statistics
Medical Statistics Part-II:Inferential  statisticsMedical Statistics Part-II:Inferential  statistics
Medical Statistics Part-II:Inferential statisticsRamachandra Barik
 
Whats New in SigmaXL Version 8
Whats New in SigmaXL Version 8Whats New in SigmaXL Version 8
Whats New in SigmaXL Version 8John Noguera
 
test_using_one-way_analysis_of_varianceANOVA_063847.pptx
test_using_one-way_analysis_of_varianceANOVA_063847.pptxtest_using_one-way_analysis_of_varianceANOVA_063847.pptx
test_using_one-way_analysis_of_varianceANOVA_063847.pptxRaquelMaacap
 
Anova (f test) and mean differentiation
Anova (f test) and mean differentiationAnova (f test) and mean differentiation
Anova (f test) and mean differentiationSubramani Parasuraman
 
Variance component analysis by paravayya c pujeri
Variance component analysis by paravayya c pujeriVariance component analysis by paravayya c pujeri
Variance component analysis by paravayya c pujeriParavayya Pujeri
 
multiple Regression
multiple Regressionmultiple Regression
multiple RegressionAnniqah
 
Anova by Hazilah Mohd Amin
Anova by Hazilah Mohd AminAnova by Hazilah Mohd Amin
Anova by Hazilah Mohd AminHazilahMohd
 
Statistical inference: Statistical Power, ANOVA, and Post Hoc tests
Statistical inference: Statistical Power, ANOVA, and Post Hoc testsStatistical inference: Statistical Power, ANOVA, and Post Hoc tests
Statistical inference: Statistical Power, ANOVA, and Post Hoc testsEugene Yan Ziyou
 
Elementary statistics for Food Indusrty
Elementary statistics for Food IndusrtyElementary statistics for Food Indusrty
Elementary statistics for Food IndusrtyAtcharaporn Khoomtong
 
SPSS statistics - get help using SPSS
SPSS statistics - get help using SPSSSPSS statistics - get help using SPSS
SPSS statistics - get help using SPSScsula its training
 
BasicStatistics.pdf
BasicStatistics.pdfBasicStatistics.pdf
BasicStatistics.pdfsweetAI1
 

Similar to ANOVA in R by Aman Chauhan (20)

Medical Statistics Part-II:Inferential statistics
Medical Statistics Part-II:Inferential  statisticsMedical Statistics Part-II:Inferential  statistics
Medical Statistics Part-II:Inferential statistics
 
Whats New in SigmaXL Version 8
Whats New in SigmaXL Version 8Whats New in SigmaXL Version 8
Whats New in SigmaXL Version 8
 
Analysis of variance anova
Analysis of variance anovaAnalysis of variance anova
Analysis of variance anova
 
Analysis of Variance
Analysis of VarianceAnalysis of Variance
Analysis of Variance
 
Anova; analysis of variance
Anova; analysis of varianceAnova; analysis of variance
Anova; analysis of variance
 
test_using_one-way_analysis_of_varianceANOVA_063847.pptx
test_using_one-way_analysis_of_varianceANOVA_063847.pptxtest_using_one-way_analysis_of_varianceANOVA_063847.pptx
test_using_one-way_analysis_of_varianceANOVA_063847.pptx
 
One_-ANOVA.ppt
One_-ANOVA.pptOne_-ANOVA.ppt
One_-ANOVA.ppt
 
Quantitative Data analysis
Quantitative Data analysisQuantitative Data analysis
Quantitative Data analysis
 
Anova (f test) and mean differentiation
Anova (f test) and mean differentiationAnova (f test) and mean differentiation
Anova (f test) and mean differentiation
 
Variance component analysis by paravayya c pujeri
Variance component analysis by paravayya c pujeriVariance component analysis by paravayya c pujeri
Variance component analysis by paravayya c pujeri
 
6SigmaReferenceMaterials
6SigmaReferenceMaterials6SigmaReferenceMaterials
6SigmaReferenceMaterials
 
Chi2 Anova
Chi2 AnovaChi2 Anova
Chi2 Anova
 
multiple Regression
multiple Regressionmultiple Regression
multiple Regression
 
Applied statistics part 3
Applied statistics part 3Applied statistics part 3
Applied statistics part 3
 
Anova by Hazilah Mohd Amin
Anova by Hazilah Mohd AminAnova by Hazilah Mohd Amin
Anova by Hazilah Mohd Amin
 
Statistical inference: Statistical Power, ANOVA, and Post Hoc tests
Statistical inference: Statistical Power, ANOVA, and Post Hoc testsStatistical inference: Statistical Power, ANOVA, and Post Hoc tests
Statistical inference: Statistical Power, ANOVA, and Post Hoc tests
 
Elementary statistics for Food Indusrty
Elementary statistics for Food IndusrtyElementary statistics for Food Indusrty
Elementary statistics for Food Indusrty
 
SPSS statistics - get help using SPSS
SPSS statistics - get help using SPSSSPSS statistics - get help using SPSS
SPSS statistics - get help using SPSS
 
spss.pptx
spss.pptxspss.pptx
spss.pptx
 
BasicStatistics.pdf
BasicStatistics.pdfBasicStatistics.pdf
BasicStatistics.pdf
 

Recently uploaded

Catalogue ONG NUOC PPR DE NHAT .pdf
Catalogue ONG NUOC PPR DE NHAT      .pdfCatalogue ONG NUOC PPR DE NHAT      .pdf
Catalogue ONG NUOC PPR DE NHAT .pdfOrient Homes
 
Socio-economic-Impact-of-business-consumers-suppliers-and.pptx
Socio-economic-Impact-of-business-consumers-suppliers-and.pptxSocio-economic-Impact-of-business-consumers-suppliers-and.pptx
Socio-economic-Impact-of-business-consumers-suppliers-and.pptxtrishalcan8
 
Sales & Marketing Alignment: How to Synergize for Success
Sales & Marketing Alignment: How to Synergize for SuccessSales & Marketing Alignment: How to Synergize for Success
Sales & Marketing Alignment: How to Synergize for SuccessAggregage
 
VIP Call Girls In Saharaganj ( Lucknow ) 🔝 8923113531 🔝 Cash Payment (COD) 👒
VIP Call Girls In Saharaganj ( Lucknow  ) 🔝 8923113531 🔝  Cash Payment (COD) 👒VIP Call Girls In Saharaganj ( Lucknow  ) 🔝 8923113531 🔝  Cash Payment (COD) 👒
VIP Call Girls In Saharaganj ( Lucknow ) 🔝 8923113531 🔝 Cash Payment (COD) 👒anilsa9823
 
Mondelez State of Snacking and Future Trends 2023
Mondelez State of Snacking and Future Trends 2023Mondelez State of Snacking and Future Trends 2023
Mondelez State of Snacking and Future Trends 2023Neil Kimberley
 
Pharma Works Profile of Karan Communications
Pharma Works Profile of Karan CommunicationsPharma Works Profile of Karan Communications
Pharma Works Profile of Karan Communicationskarancommunications
 
Call Girls in Gomti Nagar - 7388211116 - With room Service
Call Girls in Gomti Nagar - 7388211116  - With room ServiceCall Girls in Gomti Nagar - 7388211116  - With room Service
Call Girls in Gomti Nagar - 7388211116 - With room Servicediscovermytutordmt
 
VIP Kolkata Call Girl Howrah 👉 8250192130 Available With Room
VIP Kolkata Call Girl Howrah 👉 8250192130  Available With RoomVIP Kolkata Call Girl Howrah 👉 8250192130  Available With Room
VIP Kolkata Call Girl Howrah 👉 8250192130 Available With Roomdivyansh0kumar0
 
A DAY IN THE LIFE OF A SALESMAN / WOMAN
A DAY IN THE LIFE OF A  SALESMAN / WOMANA DAY IN THE LIFE OF A  SALESMAN / WOMAN
A DAY IN THE LIFE OF A SALESMAN / WOMANIlamathiKannappan
 
Tech Startup Growth Hacking 101 - Basics on Growth Marketing
Tech Startup Growth Hacking 101  - Basics on Growth MarketingTech Startup Growth Hacking 101  - Basics on Growth Marketing
Tech Startup Growth Hacking 101 - Basics on Growth MarketingShawn Pang
 
Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...
Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...
Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...lizamodels9
 
Best VIP Call Girls Noida Sector 40 Call Me: 8448380779
Best VIP Call Girls Noida Sector 40 Call Me: 8448380779Best VIP Call Girls Noida Sector 40 Call Me: 8448380779
Best VIP Call Girls Noida Sector 40 Call Me: 8448380779Delhi Call girls
 
Monte Carlo simulation : Simulation using MCSM
Monte Carlo simulation : Simulation using MCSMMonte Carlo simulation : Simulation using MCSM
Monte Carlo simulation : Simulation using MCSMRavindra Nath Shukla
 
VIP Call Girl Jamshedpur Aashi 8250192130 Independent Escort Service Jamshedpur
VIP Call Girl Jamshedpur Aashi 8250192130 Independent Escort Service JamshedpurVIP Call Girl Jamshedpur Aashi 8250192130 Independent Escort Service Jamshedpur
VIP Call Girl Jamshedpur Aashi 8250192130 Independent Escort Service JamshedpurSuhani Kapoor
 
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...Dave Litwiller
 
Cash Payment 9602870969 Escort Service in Udaipur Call Girls
Cash Payment 9602870969 Escort Service in Udaipur Call GirlsCash Payment 9602870969 Escort Service in Udaipur Call Girls
Cash Payment 9602870969 Escort Service in Udaipur Call GirlsApsara Of India
 
Ensure the security of your HCL environment by applying the Zero Trust princi...
Ensure the security of your HCL environment by applying the Zero Trust princi...Ensure the security of your HCL environment by applying the Zero Trust princi...
Ensure the security of your HCL environment by applying the Zero Trust princi...Roland Driesen
 
Keppel Ltd. 1Q 2024 Business Update Presentation Slides
Keppel Ltd. 1Q 2024 Business Update  Presentation SlidesKeppel Ltd. 1Q 2024 Business Update  Presentation Slides
Keppel Ltd. 1Q 2024 Business Update Presentation SlidesKeppelCorporation
 

Recently uploaded (20)

Catalogue ONG NUOC PPR DE NHAT .pdf
Catalogue ONG NUOC PPR DE NHAT      .pdfCatalogue ONG NUOC PPR DE NHAT      .pdf
Catalogue ONG NUOC PPR DE NHAT .pdf
 
Socio-economic-Impact-of-business-consumers-suppliers-and.pptx
Socio-economic-Impact-of-business-consumers-suppliers-and.pptxSocio-economic-Impact-of-business-consumers-suppliers-and.pptx
Socio-economic-Impact-of-business-consumers-suppliers-and.pptx
 
Sales & Marketing Alignment: How to Synergize for Success
Sales & Marketing Alignment: How to Synergize for SuccessSales & Marketing Alignment: How to Synergize for Success
Sales & Marketing Alignment: How to Synergize for Success
 
VIP Call Girls In Saharaganj ( Lucknow ) 🔝 8923113531 🔝 Cash Payment (COD) 👒
VIP Call Girls In Saharaganj ( Lucknow  ) 🔝 8923113531 🔝  Cash Payment (COD) 👒VIP Call Girls In Saharaganj ( Lucknow  ) 🔝 8923113531 🔝  Cash Payment (COD) 👒
VIP Call Girls In Saharaganj ( Lucknow ) 🔝 8923113531 🔝 Cash Payment (COD) 👒
 
Mondelez State of Snacking and Future Trends 2023
Mondelez State of Snacking and Future Trends 2023Mondelez State of Snacking and Future Trends 2023
Mondelez State of Snacking and Future Trends 2023
 
Pharma Works Profile of Karan Communications
Pharma Works Profile of Karan CommunicationsPharma Works Profile of Karan Communications
Pharma Works Profile of Karan Communications
 
Call Girls in Gomti Nagar - 7388211116 - With room Service
Call Girls in Gomti Nagar - 7388211116  - With room ServiceCall Girls in Gomti Nagar - 7388211116  - With room Service
Call Girls in Gomti Nagar - 7388211116 - With room Service
 
VIP Kolkata Call Girl Howrah 👉 8250192130 Available With Room
VIP Kolkata Call Girl Howrah 👉 8250192130  Available With RoomVIP Kolkata Call Girl Howrah 👉 8250192130  Available With Room
VIP Kolkata Call Girl Howrah 👉 8250192130 Available With Room
 
A DAY IN THE LIFE OF A SALESMAN / WOMAN
A DAY IN THE LIFE OF A  SALESMAN / WOMANA DAY IN THE LIFE OF A  SALESMAN / WOMAN
A DAY IN THE LIFE OF A SALESMAN / WOMAN
 
Tech Startup Growth Hacking 101 - Basics on Growth Marketing
Tech Startup Growth Hacking 101  - Basics on Growth MarketingTech Startup Growth Hacking 101  - Basics on Growth Marketing
Tech Startup Growth Hacking 101 - Basics on Growth Marketing
 
Best Practices for Implementing an External Recruiting Partnership
Best Practices for Implementing an External Recruiting PartnershipBest Practices for Implementing an External Recruiting Partnership
Best Practices for Implementing an External Recruiting Partnership
 
Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...
Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...
Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...
 
Best VIP Call Girls Noida Sector 40 Call Me: 8448380779
Best VIP Call Girls Noida Sector 40 Call Me: 8448380779Best VIP Call Girls Noida Sector 40 Call Me: 8448380779
Best VIP Call Girls Noida Sector 40 Call Me: 8448380779
 
Monte Carlo simulation : Simulation using MCSM
Monte Carlo simulation : Simulation using MCSMMonte Carlo simulation : Simulation using MCSM
Monte Carlo simulation : Simulation using MCSM
 
VIP Call Girl Jamshedpur Aashi 8250192130 Independent Escort Service Jamshedpur
VIP Call Girl Jamshedpur Aashi 8250192130 Independent Escort Service JamshedpurVIP Call Girl Jamshedpur Aashi 8250192130 Independent Escort Service Jamshedpur
VIP Call Girl Jamshedpur Aashi 8250192130 Independent Escort Service Jamshedpur
 
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
 
Nepali Escort Girl Kakori \ 9548273370 Indian Call Girls Service Lucknow ₹,9517
Nepali Escort Girl Kakori \ 9548273370 Indian Call Girls Service Lucknow ₹,9517Nepali Escort Girl Kakori \ 9548273370 Indian Call Girls Service Lucknow ₹,9517
Nepali Escort Girl Kakori \ 9548273370 Indian Call Girls Service Lucknow ₹,9517
 
Cash Payment 9602870969 Escort Service in Udaipur Call Girls
Cash Payment 9602870969 Escort Service in Udaipur Call GirlsCash Payment 9602870969 Escort Service in Udaipur Call Girls
Cash Payment 9602870969 Escort Service in Udaipur Call Girls
 
Ensure the security of your HCL environment by applying the Zero Trust princi...
Ensure the security of your HCL environment by applying the Zero Trust princi...Ensure the security of your HCL environment by applying the Zero Trust princi...
Ensure the security of your HCL environment by applying the Zero Trust princi...
 
Keppel Ltd. 1Q 2024 Business Update Presentation Slides
Keppel Ltd. 1Q 2024 Business Update  Presentation SlidesKeppel Ltd. 1Q 2024 Business Update  Presentation Slides
Keppel Ltd. 1Q 2024 Business Update Presentation Slides
 

ANOVA in R by Aman Chauhan

  • 2. What is ANOVA ?  Analysis of Variance (ANOVA) is a statistical technique, commonly used to studying differences between two or more group means.  ANOVA test is centered on the different sources of variation in a typical variable.  ANOVA in R primarily provides evidence of the existence of the mean equality between the groups.  This statistical method is an extension of the t-test.  It is used in a situation where the factor variable has more than one group.
  • 3. One-way ANOVA  There are many situations where you need to compare the mean between multiple groups. For instance, the marketing department wants to know if three teams have the same sales performance.  Team: 3 level factor: A, B, and C  Sale: A measure of performance  The ANOVA test can tell if the three groups have similar performances.  To clarify if the data comes from the same population, you can perform a one-way analysis of variance
  • 4. Hypothesis in one-way ANOVA test  H0: The means between groups are identical  H3: At least, the mean of one group is different  In other words, the H0 hypothesis implies that there is not enough evidence to prove the mean of the group (factor) are different from another.  This test is similar to the t-test, although ANOVA test is recommended in situation with more than 2 groups.
  • 5. Initials in R  install.packages(c("ggplot2", "ggpubr", "tidyverse", "broom", "AICcmodavg"))  library(ggplot2) library(ggpubr) library(tidyverse) library(broom) library(AICcmodavg)
  • 6. Loading Data in R  crop.data <- read.csv("path/to/your/file/crop.data.csv", header = TRUE, colClasses = c("factor", "factor", "factor", "numeric"))  Specifying within the command whether each of the variables should be quantitative (“numeric”) or categorical (“factor”).  Summary(crop.data)  read.csv(file.choose(), colClasses = c("factor", "factor", "factor", "numeric") )
  • 7. Applying in R one.way <- aov(yield ~ fertilizer, data = crop.data) Summary(one.way)
  • 8.  The model summary first lists the independent variables being tested in the model (in this case we have only one, ‘fertilizer’) and the model residuals (‘Residual’). All of the variation that is not explained by the independent variables is called residual variance.  The rest of the values in the output table describe the independent variable and the residuals:  The Df column displays the degrees of freedom for the independent variable (the number of levels in the variable minus 1), and the degrees of freedom for the residuals (the total number of observations minus one and minus the number of levels in the independent variables).  The Sum Sq column displays the sum of squares (a.k.a. the total variation between the group means and the overall mean).  The Mean Sq column is the mean of the sum of squares, calculated by dividing the sum of squares by the degrees of freedom for each parameter.  The F-value column is the test statistic from the F test. This is the mean square of each independent variable divided by the mean square of the residuals. The larger the F value, the more likely it is that the variation caused by the independent variable is real and not due to chance.  The Pr(>F) column is the p-value of the F-statistic. This shows how likely it is that the F-value calculated from the test would have occurred if the null hypothesis of no difference among group means were true.  The p-value of the fertilizer variable is low (p < 0.001), so it appears that the type of fertilizer used has a real impact on the final crop yield
  • 9. Two way ANOVA  In the two-way ANOVA example, we are modeling crop yield as a function of type of fertilizer and planting density.  two.way <- aov(yield ~ fertilizer + density, data = crop.data  summary(two.way)  Adding planting density to the model seems to have made the model better: it reduced the residual variance (the residual sum of squares went from 35.89 to 30.765), and both planting density and fertilizer are statistically significant (p- values < 0.001)
  • 10. Adding interactions between variables  Sometimes you have reason to think that two of your independent variables have an interaction effect rather than an additive effect.  For example, in our crop yield experiment, it is possible that planting density affects the plants’ ability to take up fertilizer. This might influence the effect of fertilizer type in a way that isn’t accounted for in the two-way model.  To test whether two variables have an interaction effect in ANOVA, simply use an asterisk instead of a plus-sign in the model