[R] Log likelihood of Gamma distributions

Xiaohui Chen chenxh007 at gmail.com
Wed May 21 03:40:24 CEST 2008


The scale of log-likelihood depends on the number of your data samples, 
you should sum over the log-densities from individual points:

sum(llgm)

Xiaohui

Edward Wijaya 写道:
> Dear all,
>
> How can I compute the log likelihood of a gamma
> distributions of a vector.
>
> I tried the following. But it doesn't seem to work:
>
> samples<-c(6.1, 2.2, 14.9, 9.9, 24.6, 13.2)
> llgm <- dgamma(samples, scale=1, shape=2, log = TRUE)
>
> It gives
>
> [1]  -4.291711  -1.411543 -12.198639  -7.607465 -21.397254 -10.619783
>
> I expect it only returns "one" value instead of vector.
> What's wrong with my command above?
>
> - Edward
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>



More information about the R-help mailing list