How to generate the estimate parameters (Standard deviation and mean) for an exponential distribution in r?

Viewed 53

For example:

#Using QQ-plots to decide which of the Normal, Gumbel and Exponential distribution best fits Qc
qqplot(x=qexp(ppoints(length(data$Qc))), y=data$Qc, main="Exponential Q-Q Plot",
       xlab="Theoretical Quantiles", ylab= "Data Quantiles")
qqplot(x=qnorm(ppoints(length(data$Qc))), y=data$Qc, main="Normal Q-Q Plot",
       xlab="Theoretical Quantiles", ylab= "Data Quantiles")
qqplot(x=qgumbel(ppoints(length(data$Qc))), y=data$Qc, main="Gumbel Q-Q Plot",
       xlab="Theoretical Quantiles", ylab= "Data Quantiles"

How can I generate the estimate parameters (ie the standard deviation and the mean) for normal distribution or the exponential distribution after suppose that I think a normal/exponential distribution is a good model to fit my variable?

1 Answers

exponential

MASS::fitdistr(Qc, dexp, start = list(rate = 0.1))
## 0.0338
## however, the maximum likelihood estimate of the exponential rate parameter
##  is just 1/mean(x):
(r <- 1/mean(Qc))
## 0.0338
pexp(30, rate = r, lower.tail = FALSE)  ## 0.362

normal

The sample mean and sample standard deviation give good estimates of the mean and SD parameters of the Normal (although we could use fitdistr if we really want to):

MASS::fitdistr(Qc, dnorm, start = list(mean = 25, sd = 7))
pnorm(30, mean = mean(Qc), sd = sd(Qc), lower.tail = FALSE)  ## 0.473

Gumbel

library(fitdistrplus)
library(VGAM)
fitdist(Qc, "gumbel", start = list(location = 25, scale = 1)) 
pgumbel(30, location = 27.03, scale = 7.56, lower.tail = FALSE) ## 0.491

empirical

We could just compute the observed probability of values > 30:

mean(Qc>30)  ## 0.469
Related