如何计算DRPS离散等级概率得分

问题描述

我正在复制论文Forecasting the intermittent demand for slow-moving inventories: A modelling approach

中的评分规则

本文对评分规则进行了如下描述:


enter image description here


这是我的尝试

y <- rpois(n = 100,lambda = 10) # forecasted distribution
x <- 10 # actual value

drps_score <- function(x = value,y = q){
  # x = actual value (single observation); y = quantile forecasted value (vector)
  Fy = ecdf(y) # cdf function
  indicator <- ifelse(y - x > 0,1,0) # Heaviside
  score <- sum((indicator - Fy(y))^2)
  return(score)
}

> drps_score(x = x,y = y)
[1] 53.028

在我提供如下所示的0的矢量之前,这似乎工作得很好:

y <- rep(x = 0,100)
> drps_score(x = x,y = y)
[1] 0

我知道他们在本文中使用的一种方法是0s预测,其DRPS的结果未显示0。这使我认为计算已关闭

解决方法

我认为这里有一些问题。

首先,我认为您没有在计分函数中计算正确的总和。分数要求您对y的所有可能值(即所有正整数)求和,而不是对y的所有预测样本求和。

第二,我不认为上面的定义会提供理想的结果,当y = x时\ hat F(y)定义为0,那么点质量为的预测不会得到零分真正的价值。 (是的,我是说source是“错误的”,或者至少具有不能给出预期结果的定义。)这是一个重新构造的函数,我认为可以解决两个问题:

x <- 10 # actual value

drps_score <- function(x = value,y = q,nsum=100){
    # x = actual value (single observation); y = quantile forecasted value (vector)
    Fy = ecdf(y) # cdf function
    ysum <- 0:nsum
    indicator <- ifelse(ysum - x >= 0,1,0) # Heaviside
    score <- sum((indicator - Fy(ysum))^2)
    return(score)
}



> drps_score(x = x,y = rpois(n = 1000,lambda = 8))
[1] 1.248676
> drps_score(x = x,lambda = 9))
[1] 0.878183
> drps_score(x = x,lambda = 10))
[1] 0.692667
> drps_score(x = x,y = rep(10,100))
[1] 0
> drps_score(x = x,lambda = 11))
[1] 0.883333

上面的结果表明,对于不是点质量的分布,以真实值(lambda = 10)为中心的分布得分最低。