If you're not familiar with the QB-MLE, I attached the formula as pdf. The idea is to extend the usual MLE with prior beliefs about the values sigma_n and sigma_b. My priors are already included in the code below. I intend to try a mixture of two normal distributions with same mean, and variances 1 and 5 as starting values.
This is what I've done so far:
> R <-read.table("C:\\...\\rendite.txt", header=F) > qbmle <- function(p, data){mu <- mean(data); (-sum(log(p[1]/p[2]*exp(-0.5*(data-mu)^2/p[2]^2)+(1-p[1])/p[3]*exp(-0.5*data^2/p[3]^2)))-2.772*log(p[2]^2)-2.772*log(p[3]^2) - 2.772/p[2]^2 - 13.86/p[3]^2 )}
> start <-c(0.9, 1, 5) > out <- nlm(qbmle, start, data=R)The result is: error in nlm(...): non-finite value for nlm, plus a lot of warnings, and the following output:
> out $minimum [1] -27513.60 $estimate [1] 3.478212e+04 -2.146767e+03 -3.806269e-02 $gradient [1] -5.971628e-02 1.939856e-03 -2.946156e+02 $code [1] 5 $iterations [1] 49So, what did I do wrong? How can I implement any non-negative constraints, and a restriction for p to be between 0 and 1? I'm sorry to bother you with such a beginner's question and am very helpful for any remarks. I don't have to use the qb-mle so if you think there's a better way to do the estimation tell me.
Thanks a lot, Helena
formula.pdf
Description: Adobe PDF document
______________________________________________ R-help@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.