#' Get residuals of generalized ARMA-Model
#'
#' Estimates order of ARMA process with auto.arima
#' Takes estimated Distribution of x as link function in model
#'
#' @param x vector containing time-series values. are assumed to be from day to day / week to week / month to month
#' @return vector with residuals of garmaFit
#' @export
get_garima_score <- function(x){
library(forecast)
library(gamlss)
library(gamlss.util)
assertthat::assert_that(is.numeric(x), msg = "x must be numeric")
order.proxy <- arimaorder(auto.arima(x, max.d = 0))[c(1,3)]
distribution_class <- get_distribution_class(x)
if(distribution_class == "real0to1") x <- (x+0.01)/1.011
distributions <- get_distribution(x, dist_class = distribution_class)
fit <- fit_garma(y = x, order = order.proxy, dists = distributions)
if(!exists("fit")) return(rep(NA, nrow(df)))
res <- fit$residuals
if(max(order.proxy) > 0) res[1:(1 + max(order.proxy))] <- NA
res[res == Inf] = NA
res[res == -Inf] = NA
res[is.nan(res)] = NA
return(res)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.