Full_Name: bernardo moises lagos alvarez
Version: 2.4.0
OS: Windows XP professional
Submission from: (NULL) (152.74.219.16)
I need obtained the MLE of weibull parameters using the nlm with exact gradient
an
hessian. I am doing. bug report :Erro en log(b) : el argumento "b"
est? ausente,
sin default
1.Construction to objectiv functin with n=1 data
>fllwform<-formula(~log(a)-log(b)-(a-1)*(log(x)-log(b))- (x^a)/(b^a))
> fllwfuncH
<-deriv(fllwform,c("a","b"),function(a,b,x){})
> fllwfuncH
function (a, b, x)
{
.expr2 <- log(b)
.expr4 <- a - 1
.expr5 <- log(x)
.expr6 <- .expr5 - .expr2
.expr9 <- x^a
.expr10 <- b^a
.expr19 <- .expr10^2
.expr23 <- 1/b
.value <- log(a) - .expr2 - .expr4 * .expr6 - .expr9/.expr10
.grad <- array(0, c(length(.value), 2), list(NULL, c("a",
"b")))
.grad[, "a"] <- 1/a - .expr6 - (.expr9 * .expr5/.expr10 -
.expr9 * (.expr10 * .expr2)/.expr19)
.grad[, "b"] <- -(.expr23 - .expr4 * .expr23 - .expr9 *
(b^.expr4 *
a)/.expr19)
attr(.value, "gradient") <- .grad
.value
}
2. change the x argument on fllwfuncH function to data with n>1 (on fnlmw
file)
fllwfuncHnew <-
function (a, b, x)
{
.n<-length(x)
.expr2 <- log(b)
.expr4 <- a - 1
.expr5 <- log(x)
.expr6 <- .expr5 - .expr2
.expr9 <- x^a
.expr10 <- b^a
.expr19 <- .expr10^2
.expr23 <- 1/b
.value <- .n*(log(a) - .expr2) - .expr4 *sum(.expr6) -
sum(.expr9)/.expr10
.grad <- array(0, c(length(.value), 2), list(NULL, c("a",
"b")))
.grad[, "a"] <- .n/a - sum(.expr6) - (sum(.expr9 *
.expr5)/.expr10 -
sum(.expr9) * (.expr10 * .expr2)/.expr19)
.grad[, "b"] <- -(.n*.expr23 - .n*.expr4 * .expr23 -
sum(.expr9) * (b^.expr4
*
a)/.expr19)
attr(.value, "gradient") <- .grad
.value
}
> set.seed(99)
> xdat <-rweibull(42,shape=1,scale=20)
> sum(dweibull(xdat,1,20,log=T))
[1] -174.6415
3. Use the fllwfuncHnew function on nlm:
> source("fnlmw")
> fllwfuncHnew(1,20,xdat)
[1] -174.6415
attr(,"gradient")
a b
[1,] 30.88661 0.3410358
> nlm(fllwfuncHnew,p=c(1,20),x=xdat)
Erro en log(b) : el argumento "b" est? ausente, sin default