ゼロの割合の予測
私はstatmodパッケージの作成者であり、tweedieパッケージの共同作成者です。例のすべてが正しく機能しています。コードは、データに含まれる可能性のあるゼロを正しく考慮しています。
Glen_bとTimが説明したように、ゼロの確率が100%でない限り、予測平均値は正確にゼロになることはありません。興味深いのはゼロの予測割合であり、これは以下に示すようにモデルの適合から簡単に抽出できます。
より賢明な作業例を次に示します。最初にいくつかのデータをシミュレートします。
> library(statmod)
> library(tweedie)
> x <- 1:100
> mutrue <- exp(-1+x/25)
> summary(mutrue)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
 0.3829  1.0306  2.7737  5.0287  7.4644 20.0855 
> y <- rtweedie(100, mu=mutrue, phi=1, power=1.3)
> summary(y)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
 0.0000  0.8482  2.9249  4.7164  6.1522 24.3897 
> sum(y==0)
[1] 12
データには12個のゼロが含まれています。
次に、Tweedie glmを適合させます。
> fit <- glm(y ~ x, family=tweedie(var.power=1.3, link.power=0))
> summary(fit)
Call:
glm(formula = y ~ x, family = tweedie(var.power = 1.3, link.power = 0))
Deviance Residuals: 
     Min        1Q    Median        3Q       Max  
-2.71253  -0.94685  -0.07556   0.69089   1.84013  
Coefficients:
             Estimate Std. Error t value Pr(>|t|)    
(Intercept) -0.816784   0.168764   -4.84 4.84e-06 ***
x            0.036748   0.002275   16.15  < 2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Dispersion parameter for Tweedie family taken to be 0.8578628)
    Null deviance: 363.26  on 99  degrees of freedom
Residual deviance: 103.70  on 98  degrees of freedom
AIC: NA
Number of Fisher Scoring iterations: 4
もちろん、の回帰は非常に重要です。分散の推定値φが 0.85786です。バツϕ
バツ
> Phi <- 0.85786
> Mu <- fitted(fit)
> Power <- 1.3
> Prob.Zero <- exp(-Mu^(2-Power) / Phi / (2-Power))
> Prob.Zero[1:5]
        1         2         3         4         5 
0.3811336 0.3716732 0.3622103 0.3527512 0.3433024 
> Prob.Zero[96:100]
          96           97           98           99          100 
1.498569e-05 1.121936e-05 8.336499e-06 6.146648e-06 4.496188e-06 
そのため、ゼロの予測割合は、最小平均値での38.1%から最大平均値での4.5e-6まで変化します。
厳密なゼロの確率の公式は、Dunn&Smyth(2001)Tweedie Family Densities:Methods of EvaluationまたはDunn&Smyth(2005)Series Evaluation of Tweedie exponentialdispersion densityにあります。