Dear Researchers,

I am looking for a library or a function to calculate SMAPE with same
doneminator to avoid a problem to the presence of 0 values in the series.
I find this variotion of SMAPE called mSMAPE

mSMAPE page 13

http://www.stat.iastate.edu/preprint/articles/2004-10.pdf


yesterday nigth i tried to create a function but without a good result. For
this reason I wish to know if some reserchers develop a solution to avoid
the possibility of an inflation of sMAPE caused by zero values in the series.


Thanks in advance
Gianni


# this is my mSMAPE function but there is some problem

SMAPEper <- function(x,y){mean((200*(abs(x-y)))/(x+y))}
obs <- c(10,20,30,40)
pred <-c(5,6,7,8)


mSMAPE <- function(obs,pred){
    M <- numeric(length(obs))

    for (i in 2:length(obs)) {
         n <- i-1
         M[i] <- mean(obs[1:n])
    }
    sum1 <- (abs(obs[1]-pred[1]))/(0.5*(abs(pred[1])+abs(obs[1])))

    for (i in 2:length(obs)) {
        n <- i-1
         sum2 <- 0
         for (k in 1:n) {sum2 <- sum2+abs(obs[k]-M[k])}
         S <- sum2/n
         sum1 <-
sum1+(abs(obs[i]-pred[i]))/(0.5*(abs(pred[i])+abs(obs[i]))+S)
    }

    my.SMAPE <- sum1/length(obs)
    return(my.SMAPE)
}

mSMAPE(obs,pred)*100
SMAPEper(obs,pred)

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to