# last modified 29 Oct 2014 by M. Friendly
# - removed aperm, now that aperm.table is in base
# - removed meanResiduals, which is now in gnm
# + added HLtest & methods
# + added CMHtest
# + added functions in loglin-utilities
# + added logseries functions
# + added seq_mosaic
# + added logLik.loglm, blogits
# - removed as.array generic, now in base
# + added cutfac
# + now required to import: grid
# - removed loddsratio (now in vcd)
# - removed print.Kappa (now in vcd)
# + import from ca; export mpcaplot

# we are a vcd extension; do we need to import gnm here?
import(vcd)
import(gnm)
import(grid)
#import(rgl)
importFrom(MASS, loglm)
# add inports for all base packages

importFrom("grDevices", "hsv")
importFrom("stats",     "as.formula", "deviance", "family", "fitted", "formula", "glm", "logLik", "loglin", "model.frame", "na.pass", "nobs", "pchisq", "poisson", "qnorm", "quantile", "reformulate", "residuals", "rstandard", "runif", "terms", "update", "xtabs")
importFrom("utils",     "data", "menu", "type.convert")
importFrom("ca",        "cacoord", "multilines")
importFrom("grDevices", "rgb")
importFrom("graphics",  "abline", "plot", "points", "text")
importFrom("stats",      "update.formula")

# for datasets vignette
importFrom("here",    "here")
importFrom("readxl",  "read_excel")
importFrom("glue",    "glue", "glue_collapse")
importFrom("purrr",   "map")
importFrom("stringr", "str_split_1")
importFrom("tidyr",   "separate_longer_delim")
importFrom("dplyr",   "select", "rename", "mutate", "group_by", "summarise", "left_join", "relocate")



# joy to the world
export(
	expand.dft,expand.table,collapse.table,
	mosaic.glm, sieve.glm, assoc.glm,
	modFit, modFit.glm, modFit.loglm,
	GKgamma,print.GKgamma,
	glmlist, loglmlist, 
	summarise, 
	logLik.loglm,
#	print.Kappa,
	mosaic3d, split3d, range3d, center3d,
	Kway, Crossings, 
	datasets,
#	loddsratio, 
#	as.array,
#	aperm, meanResiduals,
	HLtest, HosmerLemeshow,
	CMHtest,
	conditional, joint, markov, mutual, saturated,
	loglin2formula, loglin2string, seq_loglm,
	dlogseries, plogseries, qlogseries, rlogseries,
	seq_mosaic,
	blogits,
	Summarise,
	LRstats,
	cutfac,
  mcaplot,
  update.xtabs,
  zero.test
	)

# basic methods for glm & loglm objects
S3method(mosaic, glm)
S3method(sieve, glm)
S3method(assoc, glm)
S3method(modFit, glm)
S3method(modFit, loglm)
S3method(mosaic, glmlist)
S3method(mosaic, loglmlist)
S3method(update, xtabs)

#S3method(summarise, glm)
#S3method(summarise, glmlist)
#S3method(summarise, loglm)
#S3method(summarise, loglmlist)

S3method(Summarise, glmlist)
S3method(Summarise, loglmlist)
S3method(Summarise, default)

S3method(LRstats, glmlist)
S3method(LRstats, loglmlist)
S3method(LRstats, default)

S3method(coef, glmlist)

S3method(logLik, loglm)
S3method(print, GKgamma)
#S3method(print, Kappa)  # moved to vcd

# mosaic3d related
S3method(split3d, shape3d)
S3method(split3d, list)

S3method(mosaic3d, default)
S3method(mosaic3d, loglm)

# logoddsratio related methods -- moved to vcd
#S3method(loddsratio, default)
#S3method(coef, loddsratio)
#S3method(confint, loddsratio)
#S3method(dim, loddsratio)
#S3method(dimnames, loddsratio)
#S3method(print, loddsratio)
#S3method(vcov, loddsratio)
#S3method(as.matrix, loddsratio)
#S3method(as.array, loddsratio)
#S3method(as.data.frame, loddsratio)

# aperm method removed, as this is now in stats
#S3method(aperm, default)
#S3method(aperm, table)

S3method(print, HLtest)
S3method(summary, HLtest)
S3method(plot, HLtest)
S3method(rootogram, HLtest)

S3method(print, CMHtest)
S3method(CMHtest,formula)
S3method(CMHtest,default)

