如何生成r中指数分布的估计参数(标准差和平均值)?



例如:

#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"

假设我认为正态分布/指数分布是适合我的变量的好模型,我如何生成正态分布或指数分布的估计参数(即标准差和平均值)?

指数

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
正常

样本均值和样本标准差给出了正态的均值和SD参数的良好估计(尽管如果我们真的想的话,我们可以使用fitdistr):

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

甘力克

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

经验

我们可以计算观测到的值的概率>30:

mean(Qc>30)  ## 0.469

最新更新