File:DataOutliers.png

From 太極
Jump to navigation Jump to search

Original file(1,020 × 1,096 pixels, file size: 172 KB, MIME type: image/png)

Summary

puree <- read.csv("https://gist.githubusercontent.com/arraytools/47d3a46ae1f9a9cd47db350ae2bd2338/raw/b5cccc8e566ff3bef81b1b371e8bfa174c98ef38/dataOutliers.csv", header = FALSE)

plot(puree[,1], puree[, 2], xlim=c(0,1), ylim=c(0,1), xlab="X", ylab="Y")
abline(0,1, lty=2)
abline(lm(V2 ~ V1, data = puree))
# robust regression
require(MASS)
summary(rlm(V2 ~ V1, data = puree))
abline(rr.huber <- rlm(V2 ~ V1, data = puree), col = "blue")
  # almost overlapped with lm()
# quantile regression
library(quantreg)
abline(rq(V2 ~ V1, data=puree, tau = 0.5), col = "red")
  # even worse 
# theilsen
library(RobustLinearReg)
abline(theil_sen_regression(V2 ~ V1, data=puree), col = "cyan")
# loess
lines(lowess(puree$V1, puree$V2), col='green')
legend(0, 1, c("lm", "rlm", "quantile", "theilsen", "lowess"), 
       col = c("black", "blue", "red", "cyan", "green"), lty=1, lwd=2)

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current15:27, 7 March 2024Thumbnail for version as of 15:27, 7 March 20241,020 × 1,096 (172 KB)Brb (talk | contribs){{Pre}} puree <- read.csv("https://gist.githubusercontent.com/arraytools/47d3a46ae1f9a9cd47db350ae2bd2338/raw/b5cccc8e566ff3bef81b1b371e8bfa174c98ef38/dataOutliers.csv", header = FALSE) plot(puree[,1], puree[, 2], xlim=c(0,1), ylim=c(0,1), xlab="X", ylab="Y") abline(0,1, lty=2) abline(lm(V2 ~ V1, data = puree)) # robust regression require(MASS) summary(rlm(V2 ~ V1, data = puree)) abline(rr.huber <- rlm(V2 ~ V1, data = puree), col = "blue") # almost overlapped with lm() # quantile regressio...

The following page uses this file: