Skip to content

Softplus as a better alternative to Exponential function for Positivity Constraint #3

Answered by robjhyndman
AhmedThahir asked this question in Q&A
Discussion options

You must be logged in to vote

Yes, softplus is an alternative transformation that can be used to ensure positive forecasts. The advantage of exponential is that it allows for multiplicative interpretations. But sometimes the exponential is too strong, and then softplus can be useful.

Here is an example:

library(fable)

softplus <- function(x) {
    log(1 + exp(x))
}
invsoftplus <- function(x) {
    log(exp(x) - 1)
}

inv_softplus <- new_transformation(softplus, invsoftplus)

USAccDeaths |>
    as_tsibble() |>
    model(arima = ARIMA(inv_softplus(value/1e3))) |>
    forecast()
#> # A fable: 24 x 4 [1M]
#> # Key:     .model [1]
#>    .model    index           value  .mean
#>    <chr>     <mth>          <dist>  <dbl>
#> …

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by robjhyndman
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
fpp3 Forecasting: Principles and Practice 3rd edition
2 participants