먼저, FAdist package을보고 싶을 것입니다. 그래서 우리는이 dweibull3
에서 유사
> rweibull3
function (n, shape, scale = 1, thres = 0)
thres + rweibull(n, shape, scale)
<environment: namespace:FAdist>
및 dweibull
> dweibull3
function (x, shape, scale = 1, thres = 0, log = FALSE)
dweibull(x - thres, shape, scale, log)
<environment: namespace:FAdist>
이
> x <- rweibull3(200, shape = 3, scale = 1, thres = 100)
> fitdistr(x, function(x, shape, scale, thres)
dweibull(x-thres, shape, scale), list(shape = 0.1, scale = 1, thres = 0))
shape scale thres
2.42498383 0.85074556 100.12372297
( 0.26380861) ( 0.07235804) ( 0.06020083)
편집 : 그러나, 그 rweibull3
에서 rweibull
에 가서 열심히하지로 의견에 언급 된, distribut에 맞게하려고 할 때 다양한 경고가 나타납니다 이런 식으로 나를 위해
Error in optim(x = c(60.7075705026659, 60.6300379017397, 60.7669410153573, :
non-finite finite-difference value [3]
There were 20 warnings (use warnings() to see them)
Error in optim(x = c(60.7075705026659, 60.6300379017397, 60.7669410153573, :
L-BFGS-B needs finite values of 'fn'
In dweibull(x, shape, scale, log) : NaNs produced
의 이온은 처음 만 NaNs produced
을, 그리고 그것이 내가 그래서 그 추정이 좋은 때문에 그렇게 의미가 아니라고 생각 그것을 볼이 처음이 아니다. 어떤 검색을 한 후에는 꽤 인기있는 문제인 것 같았고 원인이나 해결책을 찾지 못했습니다. 하나의 대안은 stats4
꾸러미와 mle()
기능을 사용할 수 있지만, 역시 약간의 문제가있는 것 같았습니다. http://stackoverflow.com/questions/5963269/ (당신은 [재현 예]를 만든 경우 아마도
thres <- 60
x <- rweibull(200, 3, 1) + thres
EPS = sqrt(.Machine$double.eps) # "epsilon" for very small numbers
llik.weibull <- function(shape, scale, thres, x)
{
sum(dweibull(x - thres, shape, scale, log=T))
}
thetahat.weibull <- function(x)
{
if(any(x <= 0)) stop("x values must be positive")
toptim <- function(theta) -llik.weibull(theta[1], theta[2], theta[3], x)
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])
}
thetahat.weibull(x)
shape scale thres
3.325556 1.021171 59.975470
:하지만 내가 몇 번 확인했다있는 danielmedic에 의해 code의 수정 된 버전을 사용하도록 제공 할 수 있습니다 how-to-make-a-great-r-reproducible-example)을 사용하면 사람들이 쉽게 대답 할 수 있습니다. 특히'x [[6]]는 어떻게 생겼을까요? 적어도'str (x [[6] ') 또는'dput (x [[6])'의 결과를 게시하십시오. – Andrie
R에 내장 된'weibull' 배포본을 사용할 수 없습니다. 두 매개 변수 weibull 분포. 사용자 지정 확률 밀도 함수 (3 매개 변수) 계산하고 대신 사용해야합니다. – dickoa