Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

asmodee() is not (always) deterministic #35

Open
stephaneghozzi opened this issue Aug 15, 2020 · 0 comments
Open

asmodee() is not (always) deterministic #35

stephaneghozzi opened this issue Aug 15, 2020 · 0 comments

Comments

@stephaneghozzi
Copy link

stephaneghozzi commented Aug 15, 2020

While looking at a special case, I found outlier detection is not deterministic. In the code below, asmodee is applied 100 times to the same time series, but only a fraction of the trials finds outliers. (Actually none should, see #36.) This fraction itself varied substantially between runs.

This likely due to the way model selection is performed.

Code:

library(trendbreaker)

models <- list(
  poisson_constant = glm_model(count ~ 1, family='poisson'),
  regression = lm_model(count ~ date),
  negbin_time = glm_nb_model(count ~ date)
)

ts <- data.frame(
  date=1:42,
  count=c(2, 2, 2, 2, 1, 1, 2, 2, 2, 0, 1, 0, 0, 0, 1, 0, 1, 1, 2, 1, 1, 0, 1, 2, 1, 2, 2, 2, 0, 0,
    2, 3, 2, 1, 0, 1, 1, 0, 2, 3, 0, 7)
)

i_outlier <- c()
n_trials <- 100
for (j in 1:n_trials) {
  asmodee_res <- asmodee(
    ts,
    models = models,
    alpha = 0,
    max_k = 12,
    method = evaluate_aic
  )
  if (any(asmodee_res$results$outlier)) {
    i_outlier <- c(i_outlier, j)
  }
}
print('Proportion of trials with outliers:')
print(paste0(round(100*length(i_outlier)/n_trials),'%'))

Output:

[1] "Proportion of trials with outliers:"
[1] "32%"

(The percentage will vary from run to run)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant