An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20120129/b6eeb35a/attachment.pl>
r-help; weibull parameter estimate
2 messages · Christopher Kelvin, Peter Dalgaard
On Jan 29, 2012, at 12:17 , Christopher Kelvin wrote:
Hello, If i write a function as below using log of weibull distribution i do not get the required results in estimating the parameters what do i do, please
Presumably find and fix the error in your likelihood function!
z2 <- function(p)-sum(dweibull(x,p[1],p[2],log=TRUE)) z2(c(2,1))
[1] 1359.169
z2(c(2,2))
[1] 634.8413
z(c(2,1))
[1] 736251.1
z(c(2,2))
[1] 184012
optim(c(.5,.5),z2)
$par
[1] 1.971611 1.938388
$value
[1] 633.9709
$counts
function gradient
79 NA
$convergence
[1] 0
$message
NULL
a/b * (t/b)^a-1 * exp(-t/b)^a
n=500
x<-rweibull(n,2,2)
z<-function(p) {(-n*log(p[1])+n*log(p[2])-
(p[1]-1)*sum(log(x))+(p[1]-1)*log(p[2])+(sum(x/p[2])^(p[1])) )}
zz<-optim(c(0.5,0.5),z)
zz
[[alternative HTML version deleted]]
______________________________________________ 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.
Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com