楼主: SleepyTom
2467 9

[学术资料] R in Action, Second Edition Data analysis and graphics with R [推广有奖]

  • 3关注
  • 12粉丝

已卖:13753份资源

教授

24%

还不是VIP/贵宾

-

威望
0
论坛币
192371 个
通用积分
1878.3208
学术水平
134 点
热心指数
181 点
信用等级
154 点
经验
1141 点
帖子
783
精华
0
在线时间
450 小时
注册时间
2007-5-8
最后登录
2025-12-26

楼主
SleepyTom 发表于 2016-5-8 00:28:26 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
the .rar document contains the book, code, Bonus chapter 23, and Errata

R in Action Data analysis and graphics with R
Second Edition
by Robert I. Kabacoff

R in Action, Second Edition presents both the R language and the examples that make it so useful for business developers. Focusing on practical solutions, the book offers a crash course in statistics and covers elegant methods for dealing with messy and incomplete data that are difficult to analyze using traditional methods. You'll also master R's extensive graphical capabilities for exploring and presenting data visually. And this expanded second edition includes new chapters on time series analysis, cluster analysis, and classification methodologies, including decision trees, random forests, and support vector machines.
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:Graphics Analysis Edition Analysi GRAPHIC difficult practical business document examples

e85hb8^5.rar
下载链接: https://bbs.pinggu.org/a-2028828.html

18.83 MB

需要: 10 个论坛币  [购买]

沙发
Lisrelchen(未真实交易用户) 发表于 2016-5-8 03:45:09
  1. Listing 8.1. Simple linear regression

  2. > fit <- lm(weight ~ height, data=women)
  3. > summary(fit)

  4. Call:
  5. lm(formula=weight ~ height, data=women)

  6. Residuals:
  7.    Min     1Q Median     3Q    Max
  8. -1.733 -1.133 -0.383  0.742  3.117

  9. Coefficients:
  10.             Estimate Std. Error t value Pr(>|t|)
  11. (Intercept) -87.5167     5.9369   -14.7  1.7e-09 ***
  12. height        3.4500     0.0911    37.9  1.1e-14 ***
  13. ---
  14. Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 '' 1

  15. Residual standard error: 1.53 on 13 degrees of freedom
  16. Multiple R-squared: 0.991,      Adjusted R-squared: 0.99
  17. F-statistic: 1.43e+03 on 1 and 13 DF,  p-value: 1.09e-14

  18. > women$weight

  19. [1] 115 117 120 123 126 129 132 135 139 142 146 150 154 159 164

  20. > fitted(fit)

  21.      1      2      3      4      5      6      7      8      9
  22. 112.58 116.03 119.48 122.93 126.38 129.83 133.28 136.73 140.18
  23.     10     11     12     13     14     15
  24. 143.63 147.08 150.53 153.98 157.43 160.88

  25. > residuals(fit)

  26.     1     2     3     4     5     6     7     8     9    10    11
  27. 2.42  0.97  0.52  0.07 -0.38 -0.83 -1.28 -1.73 -1.18 -1.63 -1.08
  28.    12    13    14    15
  29. -0.53  0.02  1.57  3.12

  30. > plot(women$height,women$weight,
  31.        xlab="Height (in inches)",
  32.        ylab="Weight (in pounds)")
  33. > abline(fit)
复制代码

藤椅
Lisrelchen(未真实交易用户) 发表于 2016-5-8 03:48:46
0.jpg 1.jpg

板凳
Lisrelchen(未真实交易用户) 发表于 2016-5-8 03:52:35
  1. Listing 9.2. Tukey HSD pairwise group comparisons

  2. > TukeyHSD(fit)
  3.   Tukey multiple comparisons of means
  4.     95% family-wise confidence level

  5. Fit: aov(formula = response ~ trt)

  6. $trt
  7.                diff    lwr   upr p adj
  8. 2times-1time   3.44 -0.658  7.54 0.138
  9. 4times-1time   6.59  2.492 10.69 0.000
  10. drugD-1time    9.58  5.478 13.68 0.000
  11. drugE-1time   15.17 11.064 19.27 0.000
  12. 4times-2times  3.15 -0.951  7.25 0.205
  13. drugD-2times   6.14  2.035 10.24 0.001
  14. drugE-2times  11.72  7.621 15.82 0.000
  15. drugD-4times   2.99 -1.115  7.09 0.251
  16. drugE-4times   8.57  4.471 12.67 0.000
  17. drugE-drugD    5.59  1.485  9.69 0.003

  18. > par(las=2)
  19. > par(mar=c(5,8,4,2))
  20. > plot(TukeyHSD(fit))
复制代码

报纸
Lisrelchen(未真实交易用户) 发表于 2016-5-8 03:53:38
  1. Listing 9.3. One-way ANCOVA

  2. > data(litter, package="multcomp")
  3. > attach(litter)
  4. > table(dose)
  5. dose
  6.   0   5  50 500
  7. 20  19  18  17
  8. > aggregate(weight, by=list(dose), FUN=mean)
  9.   Group.1    x
  10. 1       0 32.3
  11. 2       5 29.3
  12. 3      50 29.9
  13. 4     500 29.6
  14. > fit <- aov(weight ~ gesttime + dose)
  15. > summary(fit)
  16.             Df  Sum Sq Mean Sq F value   Pr(>F)
  17. gesttime     1  134.30  134.30  8.0493 0.005971 **
  18. dose         3  137.12   45.71  2.7394 0.049883 *
  19. Residuals   69 1151.27   16.69
  20. ---
  21. Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
复制代码

地板
Lisrelchen(未真实交易用户) 发表于 2016-5-8 03:54:28
  1. Listing 9.4. Multiple comparisons employing user-supplied contrasts

  2. > library(multcomp)
  3. > contrast <- rbind("no drug vs. drug" = c(3, -1, -1, -1))
  4. > summary(glht(fit, linfct=mcp(dose=contrast)))

  5. Multiple Comparisons of Means: User-defined Contrasts

  6. Fit: aov(formula = weight ~ gesttime + dose)

  7. Linear Hypotheses:
  8.                       Estimate Std. Error t value Pr(>|t|)
  9. no drug vs. drug == 0    8.284      3.209   2.581   0.0120 *
  10. ---
  11. Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  12. The contrast c(3, -1, -1, -1) specifies a comparison of the first group with the average of the other three. The hypothesis is tested with a t statistic (2.581 in this case), which is significant at the p < .05 level. Therefore, you can conclude that the no-drug group has a higher birth weight than drug conditions. Other contrasts can be added to the rbind() function (see help(glht) for details).
复制代码

7
Lisrelchen(未真实交易用户) 发表于 2016-5-8 03:56:02
  1. Listing 10.1. Sample sizes for detecting significant effects in a one-way ANOVA

  2. library(pwr)
  3. es <- seq(.1, .5, .01)
  4. nes <- length(es)

  5. samsize <- NULL
  6. for (i in 1:nes){
  7.     result <- pwr.anova.test(k=5, f=es[i], sig.level=.05, power=.9)
  8.     samsize[i] <- ceiling(result$n)
  9. }

  10. plot(samsize,es, type="l", lwd=2, col="red",
  11.      ylab="Effect Size",
  12.      xlab="Sample Size (per cell)",
  13.      main="One Way ANOVA with Power=.90 and Alpha=.05")
  14. Graphs such as these can help you estimate the impact of various conditions on your experimental design. For example, there appears to be little bang for the buck in increasing the sample size above 200 observations per group. We’ll look at another plotting example in the next section.
复制代码

8
Lisrelchen(未真实交易用户) 发表于 2016-5-8 03:59:15


0.jpg

1.jpg

9
三鱼鱼(真实交易用户) 发表于 2016-5-8 08:43:31 来自手机
SleepyTom 发表于 2016-5-8 00:28
the .rar document contains the book, code, Bonus chapter 23, and Errata

R in Action Data analysis ...
谢谢分享

10
Enthuse(真实交易用户) 发表于 2017-5-5 22:58:41
thanks ...

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jr
拉您进交流群
GMT+8, 2025-12-27 05:51