#exportPattern("^[[:alpha:]]+")
useDynLib(bayesTFR, .registration = TRUE)

import(mvtnorm)
import(coda)
import(wpp2019)
import(data.table)
importFrom(MASS, mvrnorm)
#importFrom(rworldmap, getMap, mapDevice, addMapLegend, mapCountryData)

importFrom("graphics", "grid", "hist", "legend", "lines", "par", "plot", "plot.default", "points")
importFrom("grDevices", "col2rgb", "dev.off", "rainbow", "rgb", "pdf")
importFrom("stats", "cov", "dnorm", "dunif", "lm", "mahalanobis", "median", "pgamma", "pnorm", "qgamma", 
           "quantile", "rexp", "rgamma", "rnorm", "runif", "sd", "var", "approx")
importFrom("utils", "read.delim", "read.table", "write.table", "packageVersion")
importFrom("stats", "aggregate", "as.formula", "predict", "residuals")
importFrom("utils", "data", "read.csv", "head")
importFrom("lifecycle", "deprecated")

# export functions
export(
	run.tfr.mcmc,
	run.tfr3.mcmc,
	continue.tfr.mcmc,
	continue.tfr3.mcmc,
	run.tfr.mcmc.extra,
	tfr.predict,
	tfr.predict.extra,
	tfr.median.shift,
	tfr.median.set.all,
	tfr.median.set,
	tfr.median.reset,
	get.tfr.shift,
	get.tfr.shift.estimation,
	tfr.median.reset.estimation,
	tfr.median.adjust,
	tfr.shift.estimation.to.wpp,
	tfr.shift.prediction.to.wpp,
	get.ar1.parameters,
	convert.tfr.trajectories,
	write.projection.summary,
	get.tfr.mcmc,
	get.tfr3.mcmc,
	has.tfr.mcmc,
	has.tfr3.mcmc,
	tfr.mcmc,
	tfr.mcmc.list,
	get.mcmc.list,
	get.thinned.tfr.mcmc,
	get.tfr.prediction,
	has.tfr.prediction,
	available.tfr.predictions,
	get.tfr.convergence.all,
	get.tfr.convergence,
	get.tfr3.convergence.all,
	get.tfr3.convergence,
	has.mcmc.converged,
	tfr.parameter.names.extended,
	tfr.parameter.names.cs.extended,
	tfr.parameter.names,
	tfr.parameter.names.cs,
	tfr3.parameter.names,
	tfr3.parameter.names.cs,
	get.total.iterations,
	get.stored.mcmc.length,
	get.tfr.parameter.traces,
	get.tfr.parameter.traces.cs,
	get.tfr3.parameter.traces,
	get.tfr3.parameter.traces.cs,
	get.tfr.trajectories,
	coda.mcmc,
	coda.list.mcmc,
	coda.list.mcmc3,
	get.cov.gammas,
	get.country.object,
	country.names,
	DLcurve.plot.all,
	DLcurve.plot,
	tfr.trajectories.table,
	tfr.trajectories.plot.all,
	tfr.trajectories.plot,
	tfr.partraces.plot,
	tfr.partraces.cs.plot,
	tfr3.partraces.plot,
	tfr3.partraces.cs.plot,
	tfr.pardensity.plot,
	tfr.pardensity.cs.plot,
	tfr3.pardensity.plot,
	tfr3.pardensity.cs.plot,
	get.tfr.map.parameters,
	tfr.map.all,
	tfr.map,
	tfr.map.gvis,
	tfr.ggmap,
	read.tfr.file,
	#tfr.gelman.diag,
	#tfr.plot.gelman,
	tfr.raftery.diag,
	tfr.diagnose,
	tfr3.diagnose,
	tfr.get.dlcurves,
	tfr.world.dlcurves,
	tfr.country.dlcurves,
	tfr.dl.coverage,
	get.median.from.prediction,
	get.mean.from.prediction,
	bdem.parameter.traces,
	get.traj.ascii.header,
	get.nr.countries,
	get.nrest.countries,
	get.data.matrix,
	get.countries.index,
	get.data.imputed,
	get.data.for.country.imputed,
	get.projection.summary.header,
	get.UN.variant.names,
	get.friendly.variant.names,
	.get.gamma.pars,
	.map.main.default,
	bdem.map.gvis,
	get.mcmc.meta,
	par.names.for.worldmap,
	get.data.for.worldmap,
	get.countries.table,
	get.countries.phase,
	tfr.predict.subnat,
	get.regtfr.prediction,
	get.tfr.estimation,
	tfr.estimation.plot,
	get.bias.model,
	get.std.model,
	tfr.bias.sd
)

# register S3 methods
S3method(bdem.parameter.traces, bayesTFR.mcmc)

S3method(get.mcmc.list, bayesTFR.mcmc.set)
S3method(get.mcmc.list, bayesTFR.mcmc)
S3method(get.mcmc.list, bayesTFR.prediction)
S3method(get.mcmc.list, list)

S3method(get.mcmc.meta, bayesTFR.mcmc.meta)
S3method(get.mcmc.meta, bayesTFR.mcmc.set)
S3method(get.mcmc.meta, bayesTFR.mcmc)
S3method(get.mcmc.meta, bayesTFR.prediction)

S3method(coda.mcmc, bayesTFR.mcmc)

S3method(summary, bayesTFR.mcmc.set)
S3method(summary, bayesTFR.mcmc)
S3method(summary, bayesTFR.mcmc.meta)
S3method(summary, bayesTFR.prediction)
S3method(summary, bayesTFR.convergence)

S3method(print, bayesTFR.mcmc)
S3method(print, bayesTFR.mcmc.set)
S3method(print, bayesTFR.mcmc.meta)
S3method(print, bayesTFR.prediction)
S3method(print, bayesTFR.convergence)
S3method(print, summary.bayesTFR.mcmc)
S3method(print, summary.bayesTFR.mcmc.set)
S3method(print, summary.bayesTFR.prediction)
S3method(print, summary.bayesTFR.mcmc.meta)
S3method(print, summary.bayesTFR.convergence)
S3method(print, bayesTFR.estimation)

S3method(get.traj.ascii.header, bayesTFR.mcmc.meta)
S3method(get.nr.countries, bayesTFR.mcmc.meta)
S3method(get.nrest.countries, bayesTFR.mcmc.meta)
S3method(get.data.matrix, bayesTFR.mcmc.meta)
S3method(get.countries.index, bayesTFR.mcmc.meta)
S3method(get.data.imputed, bayesTFR.prediction)
S3method(get.data.for.country.imputed, bayesTFR.prediction)
S3method(get.projection.summary.header, bayesTFR.prediction)
S3method(get.UN.variant.names, bayesTFR.prediction)
S3method(get.friendly.variant.names, bayesTFR.prediction)
S3method(.get.gamma.pars, bayesTFR.prediction)
S3method(.map.main.default, bayesTFR.prediction)
S3method(bdem.map.gvis, bayesTFR.prediction)
S3method(par.names.for.worldmap, bayesTFR.prediction)
S3method(get.data.for.worldmap, bayesTFR.prediction)
S3method(get.countries.table, bayesTFR.prediction)
S3method(get.countries.table, bayesTFR.mcmc.set)
S3method(get.countries.phase, bayesTFR.mcmc.set)
S3method(get.countries.phase, bayesTFR.prediction)

