[英]How can I estimate scale and shape parameter of Generalized exponential function using 'maxlik' package?
I want to test the closeness of my sample data with the Generalized Exponential (GE) distribution.我想用广义指数 (GE) 分布测试我的样本数据的接近程度。 For that, I am using ks test in R. In the documentation of ks.gen.exp (reliaR package), its is given : ## Estimates of alpha & lambda using 'maxLik' package.为此,我在 R 中使用 ks 测试。在 ks.gen.exp(reliaR 包)的文档中,给出了:## 使用 'maxLik' 包对 alpha 和 lambda 的估计。 Example code from R package reliaR R 包 reliaR 中的示例代码
## Load data sets
data(bearings)
## Estimates of alpha & lambda using 'maxLik' package
## alpha.est = 5.28321139, lambda.est = 0.03229609
ks.gen.exp(bearings, 5.28321139, 0.03229609, alternative = "two.sided", plot = TRUE)
Can anyone tell me how to estimate alpha(shape parameter) and lambda(scale parameter) using maxLik package?谁能告诉我如何使用 maxLik 包估计 alpha(形状参数)和 lambda(比例参数)?
This is not the most elegant solution but following the examples found in ?maxLik
, the code below is one such solution.这不是最优雅的解决方案,但按照?maxLik
的示例,下面的代码就是这样的解决方案之一。 Note that the method "BFGS" may (not) be the best, but it reproduced the results of the example in ?ks.gen.exp
.请注意,方法“BFGS”可能(不是)是最好的,但它复制了?ks.gen.exp
示例的结果。
loglik.genExp <- function(theta){
# Just incase you don't want to give the input names
if(is.null(names(theta))){
names(theta) <- c("alpha", "lambda")
}
# generate a numeric vector of probability densities from a general
# exponential distribution
rrgs <- c(list(x = z), as.list(theta))
l <- do.call("dgen.exp", rrgs)
# return the log-likelihood
sum(log(l))
}
# Assign your sample to the variable z
z <- bearings
maxLik(logLik = loglik.genExp, start = c(5.3, 0.03), method = "BFGS")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.