I know about the fitdist()
function from the fitdistrplus
package in R, however, I am not able to use it to predict a gaussian distribution. I can predict normal, logistic, weibull etc.
How can I use it for gaussian? are there any other ways to predict this?
3 Answers
You can try the following:
The minimum syntax you can use is:
fit.norm <- fitdist(x, "norm")
to fit the normal density function to the data x.
Use the parameters "gamma", "weibull", "lnorm" for fitting gamma, weibull and lognormal distributions respectively.
After doing that, you can use plot()
function on your object fit.norm to visualize the fitted distribution ,q-q plot, p-p plot and empirical and theoretical CDF's.
Normal distribution and Gaussian distribution are one and the same.
The following is the output due to plot()
function on the object generated by fitdist()
function for 1000 standard normal variates.
-
$\begingroup$
fitdist(runif(100),"pnorm")
gives "Error in fitdist(runif(100), "pnorm") : The dpnorm function must be defined". You didn't even try this. The second argument offitdist
has to be"norm"
here, not"pnorm"
or"qnorm"
. $\endgroup$ Commented Nov 10, 2016 at 16:53 -
$\begingroup$ While presenting, I made a mistake. You are right. $\endgroup$– LellaCommented Nov 10, 2016 at 16:58
-
$\begingroup$ @Spacedman I have corrected the typo. I observed that
dnorm
(without quotes) is same as "norm". $\endgroup$– LellaCommented Nov 10, 2016 at 17:15 -
$\begingroup$ @Spacedman Is there a function called dpnorm? $\endgroup$– LellaCommented Nov 10, 2016 at 17:22
-
$\begingroup$ No. It takes the string you give it, sticks "d" on the start, and looks for a function of that name to return a density. So if you can write the density, distribution, and quantile functions
dfoo
,pfoo
, andqfoo
for the fictonalfoo
distribution, thenfitdist
can act as a framework to fit parameters. $\endgroup$ Commented Nov 10, 2016 at 17:34
The Normal distribution is the same as the Gaussian distribution. Its just two names for the same thing. Whatever you do - fit parameters, compute goodness-of-fit, etc - if the documentation says its for a Normal distribution then you can say "Gaussian" instead. Completely and totally identical.
It depends on what you mean by predicting Gaussian/normal distribution.
If you want to check the fit, then you can estimate mean and standard deviation of your sample and plot two histograms: one for your sample and second after generating a sample Gaussian distribution with the mean and standard deviation. By comparing the two you can roughly "see" the fit.
-
$\begingroup$ Have you missed the point about Gaussian and normal distributions being the same? $\endgroup$ Commented Nov 9, 2016 at 15:57
-
1$\begingroup$ No, I did not. I know its the same. Its a simple trick to compare a sample distribution with a known (normal aka Gaussian) one (if mean and std are known). $\endgroup$ Commented Nov 10, 2016 at 8:38
fitdist
come from? Its not in the base R packages. Always specify packages if mentioning an R function not in the base. $\endgroup$Error: object 'fitdist' not found
. There is no such function. Edit your question and put the exact R code, from a clean session, into it. $\endgroup$