Advertisement
kukis03

Untitled

Jan 8th, 2024
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. #install.packages("WRS2")
  2. library(WRS2)
  3. data("goggles")
  4. attach(goggles)
  5. levels(alcohol)
  6.  
  7.  
  8. contrasts(alcohol)="contr.treatment"
  9. mod0=lm(attractiveness~alcohol,goggles)
  10. coef(mod0)
  11. contrasts(alcohol)
  12.  
  13. aggregate(attractiveness~alcohol,goggles,FUN=mean)
  14.  
  15. contrasts(alcohol)="contr.sum"
  16. mod0=lm(attractiveness~alcohol)
  17. coef(mod0)
  18.  
  19. boxplot(attractiveness~alcohol,goggles)
  20. mod0=lm(attractiveness~alcohol,goggles)
  21. anova0=anova(mod0)
  22. anova(mod0)
  23.  
  24. mod1=aov(attractiveness~alcohol,goggles)
  25. anova1=summary(mod1)
  26.  
  27. summary(mod1)
  28.  
  29. means=aggregate(attractiveness~alcohol,goggles,FUN=mean)
  30.  
  31. n=nrow(goggles)
  32. mse=anova0$`Mean Sq`[2]
  33. Dnone2=means$attractiveness[2]-means$attractiveness[1]
  34. Dnone4=means$attractiveness[3]-means$attractiveness[1]
  35. D24=means$attractiveness[3]-means$attractiveness[2]
  36.  
  37. q=qtukey(0.05,3,48-3,lower.tail = F)
  38.  
  39. ni=aggregate(attractiveness~alcohol,goggles,length)
  40. nnone=ni$attractiveness[1]
  41. n2=ni$attractiveness[2]
  42. n4=ni$attractiveness[3]
  43.  
  44. #1
  45. Dnone2+c(-1,1)*1/sqrt(2)*q*sqrt(mse*(1/nnone+1/n2))
  46.  
  47. #2
  48. Dnone4+c(-1,1)*1/sqrt(2)*q*sqrt(mse*(1/nnone+1/n4))
  49.  
  50. #3
  51. D24+c(-1,1)*1/sqrt(2)*q*sqrt(mse*(1/n2+1/n4))
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement