find_dfa_trends {bayesdfa}R Documentation

Find the best number of trends according to LOOIC

Description

Fit a DFA with different number of trends and return the leave one out (LOO) value as calculated by the loo package.

Usage

find_dfa_trends(
  y = y,
  kmin = 1,
  kmax = 5,
  iter = 2000,
  thin = 1,
  compare_normal = FALSE,
  convergence_threshold = 1.05,
  variance = c("equal", "unequal"),
  ...
)

Arguments

y

A matrix of data to fit. Columns represent time element.

kmin

Minimum number of trends, defaults to 1.

kmax

Maximum number of trends, defaults to 5.

iter

Iterations when sampling from each Stan model, defaults to 2000.

thin

Thinning rate when sampling from each Stan model, defaults to 1.

compare_normal

If TRUE, does model selection comparison of Normal vs. Student-t errors

convergence_threshold

The maximum allowed value of Rhat to determine convergence of parameters

variance

Vector of variance arguments for searching over large groups of models. Can be either or both of ("equal","unequal")

...

Other arguments to pass to fit_dfa()

Examples


set.seed(42)
s <- sim_dfa(num_trends = 2, num_years = 20, num_ts = 3)
# only 1 chain and 180 iterations used so example runs quickly:
m <- find_dfa_trends(
  y = s$y_sim, iter = 50,
  kmin = 1, kmax = 2, chains = 1, compare_normal = FALSE,
  variance = "equal", convergence_threshold = 1.1,
  control = list(adapt_delta = 0.95, max_treedepth = 20)
)
m$summary
m$best_model


[Package bayesdfa version 1.3.3 Index]