In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article shows you how to carry out single-factor analysis in R language, the content is concise and easy to understand, it can definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
When the factors included are explanatory variables, the focus of our attention will usually shift from prediction to analysis of differences among groups. This analysis method is called Analysis of Variance (ANOVA). In addition to the basic package in R, we also need to load car, gplots, HH, rrcov and mvoutlier packages. Install: install.package (), ANOVA generally uses ANOVA model-use aov () function, regression lm () function can also be used to analyze ANOVA model.
The syntax of the aov () function:
Aov (formula,data=dataframe), the following figure lists the special symbols that can be used in expressions. Y is a dependent variable, and A, B, and C represent factors.
The following table lists common research design expressions, lowercase for quantitative variables, uppercase letters for group factors, and Subject as unique identification variables for subjects.
In the ANOVA analysis of variance, the order of the factors to the right of the expression equation is very important, for example, in the two-factor analysis of variance, if the number of observations in different processing methods is different, then the results of the model y ~ B are different from those of the model y ~ B.
The R default type I (sequential) method calculates the ANOVA effect (order is important). The first model can be written as follows: y ~ A + B + Avu B. The results of the ANOVA table in R will be evaluated:
1. The influence of An on y
two。 When controlling A, the influence of B on y
3. When controlling the main effects of An and B, the interaction between An and B.
Single factor analysis of variance
Background: in the cholesterol dataset in the multcomp package, 50 patients received one of the five cholesterol-lowering drug treatments (trt). Three of the treatments used the same drugs, namely, 20mg once a day (1time), 10mg twice a day (2times) and 5mg four times a day (4times). The remaining two ways (drugD and drugE) represent drug candidates. Which drug therapy lowers cholesterol (response variable) the most?
> library (multcomp)
> attach (cholesterol)
> table (trt) # sample size of each group
Trt
1time 2times 4times drugD drugE
10 10 10
> aggregate (response,by=list (trt), FUN=mean) # mean value of each group
Group.1 x
1 1time 5.78197
2 2times 9.22497
3 4times 12.37478
4 drugD 15.36117
5 drugE 20.94752
> aggregate (response,by=list (trt), FUN=sd) # Standard deviation of each group
Group.1 x
1 1time 2.878113
2 2times 3.483054
3 4times 2.923119
4 drugD 3.454636
5 drugE 3.345003
> fit summary (fit)
Df Sum Sq Mean Sq F value Pr (> F)
Trt 4 1351.4 337.8 32.43 9.82e-13 * *
Residuals 45 468.8 10.4
-
Signif. Codes: 0'* * '0.001'.
> library (gplots)
> plotmeans (response~trt,xlab = "Traetment", ylab = "Response", main= "Nean Plot\ nwith 95 CI") # draw the graph of each group's mean and its confidence interval
> detach (cholesterol)
As can be seen from the output, one of the 10 patients received one of the drugs. The mean value showed that drugE reduced cholesterol the most, while ltime reduced cholesterol the least. The standard deviation of each group was relatively constant, fluctuating between 2.88 and 3.48. The F test of ANOVA for treatment (trt) was very significant (p
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.