二分法求最大似然估计r语言,r中三参数威布尔分布的最大似然估计

I want to estimate the scale, shape and threshold parameters of a 3p Weibull distribution.

What I've done so far is the following:

I've used the functions

EPS = sqrt(.Machine$double.eps) # "epsilon" for very small numbers

llik.weibull

{

sum(dweibull(x - thres, shape, scale, log=T))

}

thetahat.weibull

{

if(any(x <= 0)) stop("x values must be positive")

toptim

mu = mean(log(x))

sigma2 = var(log(x))

shape.guess = 1.2 / sqrt(sigma2)

scale.guess = exp(mu + (0.572 / shape.guess))

thres.guess = 1

res = nlminb(c(shape.guess, scale.guess, thres.guess), toptim, lower=EPS)

c(shape=res$par[1], scale=res$par[2], thres=res$par[3])

}

to "pre-estimate" my Weibull parameters, such that I can use them as initial values for the argument "start" in the "fitdistr" function of the MASS-Package.

You might ask why I want to estimate the parameters twice... reason is that I need the variance-covariance-matrix of the estimates which is also estimated by the fitdistr function.

EXAMPLE:

set.seed(1)

thres

dat

pre_mle

my_wb

dweibull(x - thres, shape, scale)

}

ml

thres = round(pre_mle[3], digits = 0)))

ml

> ml

shape scale thres

2.942548 779.997177 419.996196 ( 0.152129) ( 32.194294) ( 28.729323)

> ml$vcov

shape scale thres

shape 0.02314322 4.335239 -3.836873

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值