Reputation: 11
The task:
To draw a quantile-quantile (Q-Q) plot to check whether the gamma distribution is a good model for my data without relying on qqplot. To judge the goodness of fit in this Q-Q plot, draw Q-Q plots for three sets of 150 observations generated from your fitted Gamma distribution.
So I have 150 observations which I have modelled as a Gamma distribution and found estimates for k and lambda:
pp = c(1:150)/151
qq= qgamma(pp,k,rate=lambda)
layout(matrix(c(1,1,2,3), 2, 2, byrow = TRUE))
plot(qq,sort(x),main="Q-Q plot with gamma distribution",xlab='Quantiles of gamma distribution',ylab="Ordered data")
However when I plot qq individually 3 times it comes up with exactly the same graph?
Upvotes: 1
Views: 7951
Reputation: 50668
I assume you have a vector x
with your observed Gamma-distributed observations; I further assume you know the shape
and rate
parameters of the underlying Gamma distribution, and that you want to compare your observed quantiles to theoretical quantiles from a Gamma distribution with the same shape
and rate
parameters.
Here is an example, where I generate data x
from a Gamma distribution with shape = 2
and rate = 1
parameter.
# Set seed for reproducibility
set.seed(2017);
# Generate some Gamma distributed data
x <- rgamma(100, shape = 2, rate = 1);
# Sort x values
x <- sort(x);
# Theoretical distribution
x0 <- qgamma(ppoints(length(x)), shape = 2, rate = 1);
plot(x = x0, y = x, xlab = "Theoretical quantiles", ylab = "Observed quantiles");
abline(a = 0, b = 1, col = "red");
Upvotes: 1