Advertisement
Guest User

Untitled

a guest
Oct 24th, 2014
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. <pre>
  2. library(outliers)
  3. grubbsFunction = function(x, p.value) {
  4. outliers = NULL
  5. remainedData = NULL
  6. test = x
  7. grubbs.result = grubbs.test(test)
  8. pv = grubbs.result$p.value
  9. while(pv>p.value) {
  10. outliers = c(outliers,as.numeric(strsplit(grubbs.result$alternative," ")[[1]][3]))
  11. test = x[!x %in% outliers]
  12. grubbs.result = grubbs.test(test)
  13. pv = grubbs.result$p.value
  14. }
  15. remainedData = setdiff(x, outliers)
  16. df = data.frame(X=x,Outlier=(x %in% outliers))
  17. return(list(outliers = outliers, remainedData=remainedData, df=df))
  18. }
  19. </pre>
  20.  
  21. <pre>
  22. x= c( 0.0000000, 0.0000000 , 0.0469971 , 0.0000000 , 0.0000000 ,14.0940000,
  23. 0.0000000 , 5.1100000 ,0.0630035, 0.0000000, 34.0150000 ,0.0000000
  24. , 0.0000000, 9.0930000 , 0.0000000 , 1.1090000)
  25. </pre>
  26.  
  27. <pre>
  28. grubbs.test(x, type = 10, opposite = FALSE, two.sided = FALSE)
  29. </pre>
  30.  
  31. <pre>
  32. grubbs.test(x,opposite=FALSE,two.sided=TRUE)
  33. </pre>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement