# Imports from base packages
importFrom(grDevices, rainbow, dev.off)
importFrom(stats,
           mad, model.matrix, terms, setNames, qbeta, optim, pf, xtabs,
           as.formula, summary.lm, pbeta, approx, poly, na.omit,
           complete.cases, predict, predict.lm, t.test, formula, ave,
           aggregate, median, sd, qnorm, rnorm, dnorm, pnorm, lm, .lm.fit,
           runif, optimize, cor, quantile, coef)
importFrom(utils, menu, head, tail)

importFrom(parallel, clusterCall)
importFrom(parallel, clusterExport)
importFrom(parallel, detectCores)
importFrom(parallel, makeCluster)
importFrom(parallel, parLapply)
importFrom(parallel, stopCluster)
importFrom(utils, flush.console)

# Imports from suggested packages (with checks in code)
importFrom(leaps, regsubsets)

# Imports from ggplot2
importFrom(ggplot2,
           .data, aes, annotate, element_blank, element_line, element_rect,
           element_text, facet_wrap, geom_abline, geom_contour,
           geom_contour_filled, geom_hline, geom_line, geom_point, geom_label,
           geom_smooth, geom_text, geom_tile, geom_vline, ggplot, ggsave,
           guide_legend, guides, labs, margin, scale_color_brewer,
           scale_color_manual, scale_color_viridis_d, scale_fill_gradientn,
           scale_shape_manual, scale_x_continuous, scale_y_continuous,
           scale_y_log10, theme, theme_minimal, unit, ylim, coord_cartesian,
           geom_step)

# Exported functions
export(
    autoselect.betabinomial,
    autoselect.shash,
    bestModel,
    betaCoefficients,
    buildCnormObject,
    checkConsistency,
    cNORM.GUI,
    cNORM.GUI2,
    cnorm,
    cnorm.betabinomial,
    cnorm.cv,
    cnorm.shash,
    compare,
    computePowers,
    computeWeights,
    derivationTable,
    derive,
    diagnostics.betabinomial,
    diagnostics.shash,
    dshash,
    getGroups,
    getNormCurve,
    getNormScoreSE,
    modelSummary,
    normTable,
    normTable.betabinomial,
    normTable.shash,
    plotCnorm,
    plotDensity,
    plotDerivative,
    plotNorm,
    plotNormCurves,
    plotPercentiles,
    plotPercentileSeries,
    plotRaw,
    plotSubset,
    predictMoments,
    predictNorm,
    predictRaw,
    prepareData,
    printSubset,
    pshash,
    qshash,
    rangeCheck,
    rankByGroup,
    rankBySlidingWindow,
    rawTable,
    regressionFunction,
    rshash,
    simulateRasch,
    standardize,
    taylorSwift,
    weightedAverageModel,
    weighted.quantile,
    weighted.quantile.harrell.davis,
    weighted.quantile.inflation,
    weighted.quantile.type7,
    weighted.rank
)

# S3 methods for cnorm class
S3method(plot, cnorm)
S3method(print, cnorm)
S3method(summary, cnorm)

# S3 methods for cnormBetaBinomial class
S3method(plot, cnormBetaBinomial)
S3method(predict, cnormBetaBinomial)
S3method(summary, cnormBetaBinomial)

# S3 methods for cnormBetaBinomial2 class
S3method(plot, cnormBetaBinomial2)
S3method(predict, cnormBetaBinomial2)
S3method(summary, cnormBetaBinomial2)

# S3 methods for cnormShash class
S3method(plot, cnormShash)
S3method(predict, cnormShash)
S3method(summary, cnormShash)

# S3 methods to predict moments
S3method(predictMoments, cnorm)
S3method(predictMoments, cnormBetaBinomial)
S3method(predictMoments, cnormBetaBinomial2)
S3method(predictMoments, cnormShash)
S3method(predictMoments, default)
