[英]Zero Inflated Poisson Distribution: Fail to estimate the parameter with error code 100
以下是我正在處理的一種數據集:
data <- c(0, 1, 0, 11, 2, 0, 3, 0, 0, 2, 1, 3, 1, 0, 1, 0, 0, 0, 2, 3,
0, 0, 0, 8, 1, 1, 1, 0, 1, 1, 2, 7, 0, 0, 0, 5, 2, 3, 6, 1, 1,
5, 2, 9, 0, 0, 1, 21, 16, 2, 9, 6, 25, 2, 1, 12, 16, 14, 15,
15, 6, 1, 12, 12, 13, 5, 5, 6, 4, 7, 11, 8, 4, 5, 8, 3, 8, 4,
7, 4, 7, 2, 5, 6, 4, 5, 1, 0, 8, 5, 6, 8, 9, 8, 9, 7, 7, 9, 8,
9, 4, 4, 7, 13, 9, 13, 12, 10, 9, 8, 7, 11, 5, 5, 0, 1, 33, 4,
22, 19, 22, 9, 5, 4, 17, 7, 7, 4, 5, 3, 0, 0, 9, 3, 0, 0, 36,
40, 5, 4, 0, 11, 0, 7, 5, 25, 39, 26, 4, 20, 12, 4, 17, 3, 22,
12, 14, 8, 9, 11, 7, 11, 10, 9, 16, 6, 24, 8, 5, 6, 14, 3, 9,
4, 1, 20, 0, 1, 7, 9, 0, 12, 2, 29, 56, 16, 8, 28, 0, 19, 25,
35, 87, 56, 66, 60, 58, 14, 10, 12, 13, 13, 34, 26, 18, 13, 22,
13, 12, 15, 41, 11, 11, 11, 5, 6, 7, 8, 8, 17, 16, 12, 21, 38,
34, 10, 77, 41, 7, 12, 1, 16, 20, 8, 5, 2, 20, 7, 16, 12, 6,
10, 31, 12)
我使用了fitdistrplus
package 來使用最大似然擬合分布。
同樣, gamlss
package 定義了 pdf,CDF 為零膨脹泊松分布。
library(fitdistrplus)
library(gamlss)
這是數據集的平均值和標准差。
mu=mean(data)
sigma=sd(data)
數據集的平均值為 10.75,標准差為 13.050。 我嘗試使用 fitdist function 來擬合零膨脹泊松分布,如下所示。
fit_zip = fitdist(data, 'ZIP', start = list(mu = mu, sigma = sigma))
編譯所述 function 后,編譯器將引發以下錯誤
Error in fitdist(data, "ZIP", start = list(mu = mu, sigma = sigma)) :
the function mle failed to estimate the parameters,
with the error code 100
很明顯mu和sigma的起始值的初始化有問題。 我不確定在什么基礎上初始化起始值。
任何幫助表示贊賞。
您可以使用VGAM::*zipois()
而不是gamlss.dist::*ZIP()
。 起始參數有點不同,請參閱?dzipois
,並且不一定必須是您輸入的平均值。
library('fitdistrplus')
library('VGAM')
fitdist(x, 'zipois', start=list(lambda=1, pstr0=.1))
# $start.arg
# $start.arg$lambda
# [1] 1
#
# $start.arg$pstr0
# [1] 0.1
#
#
# $fix.arg
# NULL
#
# Fitting of the distribution ' zipois ' by maximum likelihood
# Parameters:
# estimate Std. Error
# lambda 12.2009631 0.23823650
# pstr0 0.1187056 0.02069464
# Warning messages:
# 1: In fitdist(x, "zipois", start = list(lambda = 1, pstr0 = 0.1)) :
# The dzipois function should return a zero-length vector when input has length zero
# 2: In fitdist(x, "zipois", start = list(lambda = 1, pstr0 = 0.1)) :
# The pzipois function should return a zero-length vector when input has length zero
不過,我不確定這個警告。
您可以通過使用不會因gamlss.dist
失敗的不同向量x1
(如下)來進行比較。
數據:
x <- c(0, 1, 0, 11, 2, 0, 3, 0, 0, 2, 1, 3, 1, 0, 1, 0, 0, 0, 2, 3,
0, 0, 0, 8, 1, 1, 1, 0, 1, 1, 2, 7, 0, 0, 0, 5, 2, 3, 6, 1, 1,
5, 2, 9, 0, 0, 1, 21, 16, 2, 9, 6, 25, 2, 1, 12, 16, 14, 15,
15, 6, 1, 12, 12, 13, 5, 5, 6, 4, 7, 11, 8, 4, 5, 8, 3, 8, 4,
7, 4, 7, 2, 5, 6, 4, 5, 1, 0, 8, 5, 6, 8, 9, 8, 9, 7, 7, 9, 8,
9, 4, 4, 7, 13, 9, 13, 12, 10, 9, 8, 7, 11, 5, 5, 0, 1, 33, 4,
22, 19, 22, 9, 5, 4, 17, 7, 7, 4, 5, 3, 0, 0, 9, 3, 0, 0, 36,
40, 5, 4, 0, 11, 0, 7, 5, 25, 39, 26, 4, 20, 12, 4, 17, 3, 22,
12, 14, 8, 9, 11, 7, 11, 10, 9, 16, 6, 24, 8, 5, 6, 14, 3, 9,
4, 1, 20, 0, 1, 7, 9, 0, 12, 2, 29, 56, 16, 8, 28, 0, 19, 25,
35, 87, 56, 66, 60, 58, 14, 10, 12, 13, 13, 34, 26, 18, 13, 22,
13, 12, 15, 41, 11, 11, 11, 5, 6, 7, 8, 8, 17, 16, 12, 21, 38,
34, 10, 77, 41, 7, 12, 1, 16, 20, 8, 5, 2, 20, 7, 16, 12, 6,
10, 31, 12)
x1 <- c(0, 63, 1, 4, 1, 44, 2, 2, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 3,
0, 0, 2, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
6, 1, 11, 1, 1, 0, 0, 0, 2)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.