Re: [R] Fitting Beta Distribution

2017-12-22 Thread peter dalgaard
Stop right there and rethink! The normalization factor depends on the parameter that you are maximizing over. -pd > On 21 Dec 2017, at 11:29 , Lorenzo Isella wrote: > > In the code, dbeta1 is the density of the beta distribution for > shape1=shape2=shape. > In the code, dbeta2 is the same quan

[R] Fitting Beta Distribution

2017-12-21 Thread Lorenzo Isella
I answer my own question: I had overlooked the fact that the normalization factor is also a function of the parameters I want to optimise, hence I should write dbeta2 <- function(x, shape){ res <- x^(shape-1)*(1-x)^(shape-1)/beta(shape, shape) return(res) } after which the results ar

[R] Fitting Beta Distribution

2017-12-21 Thread Lorenzo Isella
Dear All, I need to fit a custom probability density (based on the symmetric beta distribution B(shape, shape), where the two parameters shape1 and shape2 are identical) to my data. The trouble is that I experience some problems also when dealing with the plain vanilla symmetric beta distribution.