import("BayesXsrc")
import("colorspace")
import("mgcv")
importFrom("stats", "AIC", "BIC")

importFrom("grDevices", "chull", "n2mfrow", "trans3d")
importFrom("graphics", "abline", "axis", "box", "hist", "layout",
  "lcm", "lines", "mtext", "par", "points", "rect", "text")
importFrom("methods", "is", "slot")
importFrom("stats", "C", "as.formula", "coef", "complete.cases",
  "contr.sum", "density", "fitted", "model.frame",
  "model.matrix", "model.offset", "model.weights", "na.fail",
  "na.omit", "na.pass", "predict", "printCoefmat", "pt", "qt",
  "quantile", "rnorm", "runif", "sd", "terms",
  "terms.formula", "update")
importFrom("utils", "getS3method", "head", "read.table", "tail",
  "write.table")

export(
  ## main user interface
  "bayesx",               
  "sx",

  ## model specification
  "bayesx.construct",     
  "bayesx.control",      
  "bayesx.term.options", 

  ## workhorse functions
  "parse.bayesx.input",  
  "read.bayesx.output",
  "write.bayesx.input",

  ## extractor functions
  "cprob",
  "getscript",       
  "GCV",
  "DIC",
  "samples",
  "GRstats",
  "term.freqs",

  ## BayesX extractor functions
  "bayesx_logfile",       
  "bayesx_prgfile",  
  "bayesx_runtime",            
  "bxopts",

  ## visualization
  "colorlegend",
  "plot2d",               
  "plot3d",              
  "plotblock",
  "plotmap",              
  "plotsamples",
  "sliceplot",

  ## old package BayesX functions
  "write.bnd",
  "bnd2gra",
  "add.neighbor",
  "delete.neighbor",
  "get.neighbor",
  "write.gra",
  "read.gra",
  "read.bnd",
  "shp2bnd",
  "bnd2sp",
  "sp2bnd",
  "nb2gra",
  "gra2nb",
  "plotnonp",
  "plotsurf",
  "drawmap"
)

## methods for objects of class bayesx etc.
S3method("c", "bayesx")
S3method("fitted", "bayesx")
S3method("plot", "bayesx")
S3method("plot", "geo.bayesx")
S3method("plot", "sm.bayesx")
S3method("plot", "mrf.bayesx")
S3method("plot", "random.bayesx")
S3method("plot", "linear.bayesx")
S3method("plot", "fit.bayesx")
S3method("plot", "bnd")
S3method("predict", "bayesx")
S3method("print", "bayesx")
S3method("print", "bayesx.script")
S3method("summary", "bayesx")
S3method("model.frame", "bayesx")
S3method("print", "summary.bayesx")
S3method("residuals", "bayesx")
S3method("[", "fit.bayesx")

S3method("AIC", "bayesx")
S3method("BIC", "bayesx")
S3method("DIC", "bayesx")
S3method("GCV", "bayesx")
S3method("logLik", "bayesx")
S3method("coef", "bayesx")
S3method("confint", "bayesx")
S3method("terms", "bayesx")

## methods for bayesx.construct()
S3method("bayesx.construct", "default")

S3method("bayesx.construct", "gk.smooth.spec")
S3method("bayesx.construct", "gs.smooth.spec")
S3method("bayesx.construct", "mrf.smooth.spec")
S3method("bayesx.construct", "ps.smooth.spec")
S3method("bayesx.construct", "ra.smooth.spec")
S3method("bayesx.construct", "re.smooth.spec")
S3method("bayesx.construct", "rw1.smooth.spec")
S3method("bayesx.construct", "rw2.smooth.spec")
S3method("bayesx.construct", "tensor.smooth.spec")
S3method("bayesx.construct", "t2.smooth.spec")
S3method("bayesx.construct", "kr.smooth.spec")
S3method("bayesx.construct", "bl.smooth.spec")
S3method("bayesx.construct", "lasso.smooth.spec")
S3method("bayesx.construct", "nigmix.smooth.spec")
S3method("bayesx.construct", "ridge.smooth.spec")
S3method("bayesx.construct", "te.smooth.spec")
S3method("bayesx.construct", "season.smooth.spec")
S3method("bayesx.construct", "generic.smooth.spec")
S3method("bayesx.construct", "factor.smooth.spec")
S3method("bayesx.construct", "cs.smooth.spec")
S3method("bayesx.construct", "offset.smooth.spec")

S3method("bayesx.construct", "geokriging.smooth.spec")
S3method("bayesx.construct", "geospline.smooth.spec")
S3method("bayesx.construct", "spatial.smooth.spec")
S3method("bayesx.construct", "psplinerw1.smooth.spec")
S3method("bayesx.construct", "psplinerw2.smooth.spec")
S3method("bayesx.construct", "pspline.smooth.spec")
S3method("bayesx.construct", "random.smooth.spec")
S3method("bayesx.construct", "rsps.smooth.spec")
S3method("bayesx.construct", "pspline2dimrw2.smooth.spec")
S3method("bayesx.construct", "pspline2dimrw1.smooth.spec")
S3method("bayesx.construct", "kriging.smooth.spec")
S3method("bayesx.construct", "baseline.smooth.spec")
S3method("bayesx.construct", "catspecific.smooth.spec")

useDynLib(R2BayesX, .registration = TRUE)
