R/zzz.R

Defines functions .onLoad

## Do not edit this file manually.
## It has been automatically generated from *.org sources.

.onLoad <- function(libname, pkgname){
    ## TODO: when Polynom 2.0.0 or later has been around for some time,
    ##       rename the calls in the package with the new names
    ##       and reverse the check here to
    ##                 utils::packageVersion("PolynomF") < "2.0.0"
    if (utils::packageVersion("PolynomF") >= "2.0.0") {
                                               # or: envir = asNamespace("sarima")
        assign("as.polylist", PolynomF::as_polylist, envir = topenv())
        ## add other renamed functions from PolynomF
    }

    NULL
}

InformationMatrixARMA <- local({
    avail <- NA
    fu <- function(phi, theta){phi + theta}
    function(phi = numeric(0), theta = numeric(0)){
        if(!isTRUE(avail)){
            if(requireNamespace("FitARMA")){
                avail <<- TRUE
                ## invertibleQ is not visible in FitARMA::InformationMatrixARMA(), v1.6.1 and
                ## earlier, unless FitAR is attached. v1.6.1 is the current one at the time
                ## of writing this (2021-03-07) but it would be unsafe to make this changed
                ## for later versions.  Also, if a new version appears on CRAN this should be
                ## resolved since there is a NOTE about it by R CMD check.
                fu <<- FitARMA::InformationMatrixARMA
                if(utils::packageVersion("FitARMA") <= "1.6.1")
                    body(fu)[[c(2,2)]] <<- 
                            # 2022-02-14 was:
                            #   quote(!(FitAR::InvertibleQ(phi) & FitAR::InvertibleQ(theta)))
                        quote(!((length(phi) == 0 || all(abs(sarima::ar2Pacf(phi)) < 1)) &
                                (length(theta) == 0 || all(abs(sarima::ar2Pacf(theta)) < 1))))
            }else{
                avail <<- FALSE
                stop("This feature needs package 'FitARMA'. ",
                     "Please install it from Github using\n\n",
                     '    remotes::install_github("cran/FitARMA")\n\n',
                     '(if package "remotes" is not installed, install it from CRAN)'
                     )
            }
        }
        fu(phi, theta)
    }
})

Try the sarima package in your browser

Any scripts or data that you put into this service are public.

sarima documentation built on Aug. 11, 2022, 5:11 p.m.