In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Today, I would like to share with you how R language to achieve analysis of variance and visualization of the relevant knowledge, detailed content, clear logic, I believe that most people still know too much about this knowledge, so share this article for your reference, I hope you can learn something after reading this article, let's take a look at it.
Analysis of variance (Analysis of Variance, abbreviated as ANOVA), also known as "analysis of variance", is invented by R.A.Fisher and is used to test the significance of the difference in the mean of two or more samples. Due to the influence of various factors, the data obtained in the study fluctuated. The causes of fluctuations can be divided into two categories, one is uncontrollable random factors, and the other is the controllable factors imposed in the study to affect the results.
Classification of analysis of variance:
Analysis of variance is commonly used for single-factor analysis of variance and two-way analysis of variance, while multi-factor analysis of variance is less complex. Here, the first two kinds of analysis of variance are mainly introduced.
Single factor analysis of variance
One-way ANOVA compares the mean values of dependent variables in two or more groups defined by classification factors. Different from t-test: t-test is suitable for the comparison of the mean of two columns of data. One-way ANOVA is suitable for the mean comparison of two or more columns of data. But for the comparison of the mean of two columns of data, one-way analysis of variance = double-tailed t-test of equal variance hypothesis.
Take the built-in data PlantGrowth set in R as an example. Weight data of plants planted in different plots ('ctrl',' trt1', and 'trt2'); the problems solved are as follows
1. Is there any difference in yield among different plots?
Which is the bigger difference between 2.trt1 and trt2?
# # normality test my_data 0.05accepts the original hypothesis, indicating that the data are normally distributed at multiple levels. # # Variance homogeneity test bartlett.test (weight~group,data=my_data) # the results show that pair0.2371 > 0.05.It accepts the original hypothesis, indicating that the data are equal variance at different levels. # # one-way ANOVA fitF) # group 2 3.766 1.8832 4.846 0.0159 * # Residuals 27 10.492 0.3886 #-# Signif. Codes: 0'* * '0.001'. The results showed that there were significant differences in yield among different plots. # if you use the nonparametric test Kruskal-Wallis testkruskal.test (weight ~ group, data = my_data) # # multiple comparison (multiple T test), which part of the difference is more obvious? the TukeyHSD () function in the R language provides a pairwise test for the mean difference of each group. TukeyHSD (fit) # if you use KW to verify multiple comparisons, pairwise.wilcox.test (PlantGrowth$weight, PlantGrowth$group, p.adjust.method = "BH") is a better method + drawing display:
Ggpubr package is used for analysis of variance, and the results can be visualized.
Library ("ggpubr") compare_means (weight ~ group, data = PlantGrowth,method= "anova") compare_means (weight ~ group, data = PlantGrowth,method= "kruskal.test") my_comparisons
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.