useDynLib(sarima, .registration=TRUE)
importFrom(Rcpp, evalCpp)

import(methods, Formula, PolynomF, lagged)

importFrom(stats4, vcov, coef, confint, plot)
importFrom(stats, var, sd, filter, pnorm, rnorm, qnorm, pchisq,
           ts, ar, acf, pacf, acf2AR, ARMAacf, arima.sim, tsdiag,
           frequency, spectrum, formula, as.formula, poly, toeplitz,
           terms, is.empty.model, model.frame, model.matrix, update,
           lm, predict, printCoefmat, na.omit, na.pass,
           KalmanLike, KalmanRun, KalmanForecast, makeARIMA,
           logLik, optim)
importFrom(utils, capture.output, menu, as.relistable, relist, head)
importFrom(graphics, abline, lines, par, plot.function, curve)

importFrom(ltsa, DLAcfToAR, tacvfARMA) # PredictionVariance, 
## importFrom(FitAR, PacfToAR) # TacvfAR, TacvfMA, VarianceRacfAR, PacfDL, ARToPacf, ARToMA
## importFrom(FitARMA, InformationMatrixARMA) # TacvfARMA, ImpulseCoefficientsARMA, also tccfAR?
# importFrom(portes, LjungBox)

importFrom(numDeriv, hessian)

importFrom(Rdpack, rebib)


## 2022-01-19 moved to Suggests
##   importFrom(KFAS, SSMarima, SSModel, artransform)

## 2018-07-08 commenting out for the CRAN release
## 2020-02-29 reinstating
## 2022-01-19 moved to Suggests
##   importFrom(FKF, fkf)

## 2018-10-10 for periodogram function
## 2022-01-19 dropping dplyr
##   importFrom(dplyr, mutate, select)

##S3method(print, sarima)
S3method(print, simSarimaFun)
S3method(print, Sarima)
S3method(print, genspec)
S3method(print, Spectrum)

S3method(format, genspec)
S3method(format, Spectrum)
S3method(format, ArmaSpectrum)

S3method(summary, SarimaFilter)
S3method(summary, SarimaSpec)
S3method(summary, SarimaModel)
S3method(summary, Sarima)

S3method(plot, Spectrum)

S3method(as.list, SarimaModel)
S3method(as.list, ArmaModel)
S3method(as.list, ArmaSpec)

S3method(predict, Sarima)
S3method(tsdiag, Sarima)

#S3method(coef, SampleAutocorrelations)
#S3method(confint, SampleAutocorrelations)

S3method(FisherInformation, Arima)
S3method(FisherInformation, ArmaModel)
S3method(FisherInformation, SarimaModel)

S3method(spectrum, default)
S3method(spectrum, "function")
S3method(spectrum, Arima)
S3method(spectrum, ArmaModel)
S3method(spectrum, SarimaModel)

S3method(as.SarimaModel, Arima)                       


exportMethods(plot)
exportMethods(show)


exportClassPattern("^[^\\.]")

export(
    ## pacf2Ar,
    ## pacf2ArWithJacobian,
    sarima,
    tsdiag.Sarima,
    
    ## odl
    sim_sarima, # was: sarima.sim
    fun.forecast,
    ##print.sarima,
    sarima.f,
    ##sarima.mod,


    prepareSimSarima,   #was: simenvSarima,
    print.simSarimaFun,  #  print.simenvSarima,
    ## from_sarima.mod,
    ## from_modellist,

    xarmaFilter,

    armaacf, # from package pcts
    armaccf_xe,

    filterCoef,
    filterOrder,
    filterPoly,
    filterPolyCoef,


    autocovariances,
    autocorrelations,
    partialAutocovariances,
    partialAutocorrelations,
    partialVariances,
    backwardPartialVariances,
    partialCoefficients,
    backwardPartialCoefficients,

    sigmaSq,
    modelCenter,
    modelIntercept,
    nUnitRoots,
    isStationaryModel,

    modelOrder,
    modelPoly,
    modelPolyCoef,

    modelCoef,

    ## acfLjungBoxTest,
    acfIidTest,
    whiteNoiseTest,
    acfMaTest,
    acfGarchTest,
    acfWnTest,

    ## Bartlet
    acfOfSquaredArmaModel,
    nvcovOfAcf,
    nvcovOfAcfBD,
    nvarOfAcfKP,

    nSeasons,

    ## arOrder,
    ## maOrder,
    ## arCoef,
    ## maCoef,
    ## arPolyCoef,
    ## maPolyCoef,

    ArmaModel,
    ArModel,
    MaModel,

    ## internal
    rgarch1p1,
    
    ## periodogram
    periodogram,

    ## standard error, generic
    se,
    FisherInformation,
    spectrum,
    as.SarimaModel,
    print.Spectrum,
    plot.Spectrum,

    ## work in progress
    arma_Q0gnb,

    ## internal, may change
    ar2Pacf
)
