There are two methods that visually compare two distributions. One of them can be the theoretical distribution so the other can be tested if it fits the theoretical one. In both methods, if the distributions are similar, the plots aligns on the y = x line.
QQ plot is much easier to plot. "Most people these days prefer the qqplot to the pp plot, the qq-plot gives more room to the set of points that are generally most interesting."
1. PP plot (P: probability)
Basics
Compare two distributions by plotting the two cumulative distribution functions (CDF) against each other.
---------------------------------------------------------
# Ex.
# Generate dummy distributions
dist_1 <- rvonmises(n=50, mu=circular(0), kappa=0.1)
dist_1 <- as.vector(dist_1)
dist_1 <- dist_1 %% pi
dist_1 <- sort(dist_1)
cdf_dist_1 <- dist_1/pi
# CDF of the uniform distribution
# f(x) = 1/(b-a) (a<x<b)
# 0 (x<a or x>b)
# Generate model distributions
i <- 1 : length(dist_1)
cdf_dist_model <- i/(length(dist_1)+1)
# Plot: This is the PP plot.
plot( cdf_dist_1, cdf_dist_model, xlim=c(0,1), ylim=c(0,1), pty="s" )
abline(0,1)
mtext( side=3, line=1, text=paste("PP plot"), cex=1.5)
---------------------------------------------------------
Extension
pp.plot : Plots the empirical distribution of a data set against the best fitting von Mises distribution function
2. QQ plot (Q: quantile)
Basics
Compare two distributions by plotting their quantiles against each other.
q-quantile (0 =< q =< 1) is the value that divide distribution into q:1-q.
---------------------------------------------------------
# Ex.
# Generate dummy distributions
dist_1 <- rt(200, df = 5)
dist_2 <- rt(200, df = 5)
# SORT two distributions
dist_1 <- sort(dist_1)
dist_2 <- sort(dist_2)
# Just plot: This is the QQ plot.
plot(dist_1, dist_2)
---------------------------------------------------------
Extension
The nb of data of x and y can be different. We just see the quantile data point. This program is prepared in R.
qqplot (dist_1, dist_2)
http://tolstoy.newcastle.edu.au/R/e2/help/07/09/26619.html
http://astrostatistics.psu.edu/datasets/R/html/stats/html/qqnorm.html
http://rss.acs.unt.edu/Rdoc/library/e1071/html/probplot.html : Seems to be PP plot package
http://en.wikipedia.org/wiki/Uniform_distribution_(continuous)
http://cse.naro.affrc.go.jp/takezawa/r-tips/r/60.html : CDF functions in R
QQ plot is much easier to plot. "Most people these days prefer the qqplot to the pp plot, the qq-plot gives more room to the set of points that are generally most interesting."
1. PP plot (P: probability)
Basics
Compare two distributions by plotting the two cumulative distribution functions (CDF) against each other.
---------------------------------------------------------
# Ex.
# Generate dummy distributions
dist_1 <- rvonmises(n=50, mu=circular(0), kappa=0.1)
dist_1 <- as.vector(dist_1)
dist_1 <- dist_1 %% pi
dist_1 <- sort(dist_1)
cdf_dist_1 <- dist_1/pi
# CDF of the uniform distribution
# 0 (x<a or x>b)
# Generate model distributions
i <- 1 : length(dist_1)
cdf_dist_model <- i/(length(dist_1)+1)
# Plot: This is the PP plot.
plot( cdf_dist_1, cdf_dist_model, xlim=c(0,1), ylim=c(0,1), pty="s" )
abline(0,1)
mtext( side=3, line=1, text=paste("PP plot"), cex=1.5)
---------------------------------------------------------
Extension
pp.plot : Plots the empirical distribution of a data set against the best fitting von Mises distribution function
2. QQ plot (Q: quantile)
Basics
Compare two distributions by plotting their quantiles against each other.
q-quantile (0 =< q =< 1) is the value that divide distribution into q:1-q.
---------------------------------------------------------
# Ex.
# Generate dummy distributions
dist_1 <- rt(200, df = 5)
dist_2 <- rt(200, df = 5)
# SORT two distributions
dist_1 <- sort(dist_1)
dist_2 <- sort(dist_2)
# Just plot: This is the QQ plot.
plot(dist_1, dist_2)
---------------------------------------------------------
Extension
The nb of data of x and y can be different. We just see the quantile data point. This program is prepared in R.
qqplot (dist_1, dist_2)
http://tolstoy.newcastle.edu.au/R/e2/help/07/09/26619.html
http://astrostatistics.psu.edu/datasets/R/html/stats/html/qqnorm.html
http://rss.acs.unt.edu/Rdoc/library/e1071/html/probplot.html : Seems to be PP plot package
http://en.wikipedia.org/wiki/Uniform_distribution_(continuous)
http://cse.naro.affrc.go.jp/takezawa/r-tips/r/60.html : CDF functions in R
No comments:
Post a Comment