Fitting distributions
Now that we have seen how to plot and gain statistical information from probability distributions, we will show you how to use R to fit your data to theoretical distributions. There are several methods you can use to test whether your sample distribution fits a theoretical distribution. For example, you may want to see if your sample distribution fits a normal distribution using a Quantile-Quantile plot (Q-Q plot). In R, you can use the qqnorm()
function to create a Q-Q plot to evaluate the data. R also has a more generic version of this function called qqplot()
to create Q-Q plots for any theoretical distribution. To illustrate the use of these functions, let's create a Q-Q plot to test whether the gene expression values of probeA
follow a normal or gamma distribution.
First, let's set the plot settings to display two figures in the same layout:
> par(mfrow=c(1,2))
Use qqnorm()
to fit the data to a normal distribution:
qqnorm(probeA)
Add the theoretical line...