1
我想找到R中給定Gamma,Weibull和Log正態分佈的數據的對數似然性。我該如何繼續,因爲我已經估計了各個分佈的參數?如何找到Gamma,Log normal和Weibull的日誌可能性?
我想找到R中給定Gamma,Weibull和Log正態分佈的數據的對數似然性。我該如何繼續,因爲我已經估計了各個分佈的參數?如何找到Gamma,Log normal和Weibull的日誌可能性?
下面是一個Gamma的例子。 Weibull和log-Normal遵循完全相同的程序。
set.seed(101)
x <- rgamma(20,shape=3,rate=2.5)
library(MASS)
(ff <- fitdistr(x,"gamma"))
## shape rate
## 4.452775 4.175653
## (1.358630) (1.348722)
fitdistr
擁有數似然訪問方法:
logLik(ff)
## 'log Lik.' -13.14535 (df=2)
或者你可以自己動手完成它:
sum(dgamma(x,shape=coef(ff)["shape"],rate=coef(ff)["rate"],log=TRUE))
## [1] -13.14535
或糖/ R-魔法一點點:
with(as.list(coef(ff)),
sum(dgamma(x,shape=shape,rate=rate,log=TRUE)))
對於其他分佈
densfun="weibull"
- >dweibull()
densfun="lognormal"
- >dlnorm()
在這兩種情況下,參數化/ fitdistr
之間和相應的密度函數的參數匹配的名稱。
非常感謝@Ben Bolker – user3309969
請考慮發佈估計參數的示例數據和功能代碼。 –
這些鏈接[這裏](http://stat.ethz.ch/R-manual/R-devel/library/stats4/html/mle.html),[這裏](http://en.wikibooks.org/ wiki/R_Programming/Maximum_Likelihood)和[here](https://r-forge.r-project.org/scm/viewvc.php/*checkout*/paper/CompStat/maxLik.pdf?revision=1114&root=maxlik&pathrev=1114 )將是一個很好的起點。 – MYaseen208
這聽起來像一個請求做你的功課,但沒有真正的問題。 –