R/sort_models.r

Defines functions sort_models

# sorts models by highest model_score first

sort_models <- function(model_list) {
  # each model has a parameters and a varest property
  if (length(model_list) <= 1) {
    model_list
  } else {
    score_list <- sapply(model_list,function(x) model_score(x$varest))
    sortres <- sort(score_list,index.return=TRUE)
    res <- model_list[sortres$ix]
    class(res) <- class(model_list)
    res
  }
}
roqua/autovar documentation built on Jan. 21, 2023, 7:37 p.m.