Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
quantile quantile plot
## http://ygc.name/2011/08/02/q-q-plots/
qqplot <- function(y, distribution=qnorm) {
x <- distribution(ppoints(y))
plot(x, sort(y),
xlab="Theoretical Quantiles",
ylab="Sample Quantiles",
main="Normal Q-Q Plot"
)
lines(y,y)
}
qqplot2 <- function(y, distribution=qnorm) {
require(ggplot2)
x <- distribution(ppoints(y))
d <- data.frame(x=x, y=sort(y))
p <- ggplot(d, aes(x=x, y=y)) +
geom_point() +
geom_line(aes(x=x, y=x)) +
opts(title="Normal Q-Q Plot") +
xlab("Theoretical Quantiles") +
ylab("Sample Quantiles")
return(p)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.