2017-12-21 30 views
0

対称ベータ分布B(形状、形状)に基づいて、2つのパラメータshape1とshape2が同一のカスタム確率密度を自分のデータに合わせる必要があります。 問題は、プレーンなバニラ対称ベータ版を扱うときにいくつかの問題が発生することです。 投稿の最後にコードを入力してください。 このコードでは、dbeta1はshape1 = shape2 = shapeのベータ分布の密度です。 コードでは、dbeta2は正規化係数なしで明示的に書かれた量と同じです(数量を最大化することについては全く問題ありません)。 stats4Rでのベータ分布フィッティング

結果から

I次いでベータ(0.2、0.2)によれば、いくつかの乱数を生成し、Iは

1を用いて形状パラメータを推定しようとする)MASS

2)からfitdistr MLE :一般的に言えば、dbeta1の代わりにdbeta2を使用した場合、シェイプパラメータの推定値は意味を持ちません。理由を理解できません。 それに加えて、mleはdbeta2でクラッシュし、乱数のxシーケンスをどのようにシードするかによって数値問題が発生することがよくあります。

私は何かを誤解する必要がありますので、どんな提案も感謝します。

library(MASS) 
library(stats4) 

dbeta1 <- function(x, shape, ...) 
    dbeta(x, shape, shape, ...) 

dbeta2 <- function(x, shape){ 
    res <- x^(shape-1)*(1-x)^(shape-1) 
    return(res) 
} 

LL1 <- function(shape){ 
    R <- dbeta1(x, shape) 
    res <- -sum(log(R)) 
    return(res) 
} 

LL2 <- function(shape){ 
    R <- dbeta2(x, shape) 
    res <- -sum(log(R)) 
    return(res) 
} 

set.seed(124) 
x <- rbeta(1000, 0.2, 0.2) 

fit_dbeta1 <- fitdistr(x , dbeta1, start=list(shape=0.5) ,  method="Brent", lower=c(0), upper=c(1)) 
print("estimate of shape from fit_dbeta1 is") 
print(fit_dbeta1$estimate) 

fit_dbeta2 <- fitdistr(x , dbeta2, start=list(shape=0.5) , method="Brent", lower=c(0), upper=c(1)) 
print("estimate of shape from fit_dbeta2 is") 
print(fit_dbeta2$estimate) 

fit_LL1 <- mle(LL1, start=list(shape=0.5)) 
print("estimate of from fit_LL1") 
print(summary(fit_LL1)) 

## this does not work 
fit_LL2 <- mle(LL2, start=list(shape=0.5)) 

答えて

0

さて、私はこの問題を理解しました。この量は形状にも依存するため、dbeta2の正規化係数が不足しているという問題がありました。 私は

dbeta2 <- function(x, shape){ 


res <- x^(shape-1)*(1-x)^(shape-1)/beta(shape, shape) 

return(res) 

} 

を使用する場合は、結果が一致しています。

関連する問題