useDynLib(spdep)

import(spData)
import(sf)
import(sp)
import(methods)

importFrom(stats, influence.measures, lag, punif, lm, var, integrate,
             summary.lm, pchisq, pnorm, sd, ppois, qnorm, rnorm,
             mahalanobis, dist, p.adjust, density, quantile, cor,
             aggregate, "coefficients", "fitted", "gaussian",
             "model.frame", "model.matrix", "model.response", "na.fail",
             "na.omit", "naresid", "optimise", "printCoefmat", "resid",
             "terms", "uniroot", "weighted.residuals", "weights", "median")

importFrom(stats, model.matrix, model.response, model.extract, coefficients, residuals, deviance, optimize, optim, nlminb, na.fail, as.formula, terms, coef, gaussian, model.weights, model.offset, glm.fit, logLik, predict, formula, lm.fit, model.frame, AIC, anova, napredict, nlm, optimHess, resid, fitted, weighted.residuals, weights, naresid, optimise, fitted.values, delete.response, printCoefmat, uniroot, na.omit, predict.lm, "dbeta", "rchisq", "runif", "spline") # deprecated

importFrom(deldir, deldir)
importFrom(boot, boot)

importFrom(graphics, par, locator, lines, text, plot.new, plot.window, segments, points, identify, symbols, abline, hist, arrows, axis, stem)
importFrom(utils, write.table, object.size, read.table, read.csv, packageDescription)
importFrom(grDevices, rainbow)
if (.Platform$OS.type == "windows") importFrom(grDevices, bringToTop)
importFrom(utils, packageVersion)
importFrom(units, set_units)
importFrom(s2, s2_distance, s2_closest_edges, s2_buffer_cells, s2_intersects_matrix, s2_dwithin_matrix)
importFrom(e1071, skewness, kurtosis)

importFrom(MASS, mvrnorm) # deprecated
importFrom(coda, as.mcmc, HPDinterval) # deprecated
importFrom(splines, interpSpline) # deprecated
importFrom(nlme, fdHess) # deprecated
if (R.version$major >= 3) { # deprecated
  if (R.version$major == 3 && R.version$minor < 3) {
    import(Matrix)
  } else if (R.version$major == 3 && R.version$minor >= 3) {
    import(Matrix, except=c("expm"))
  } else if(R.version$major > 3)
    import(Matrix, except=c("expm"))
} else {
  import(Matrix)
}
importFrom(LearnBayes, rwmetrop) # deprecated
importFrom(gmodels, estimable) # deprecated
importFrom(expm, expAtv, expm) # deprecated

#importMethodsFrom("Matrix", "%*%", "crossprod", "t", "diag", "rowSums", "colSums") # defunct
#importFrom("Matrix", "Diagonal", "drop") # defunct

exportMethods(coerce)

export(EBImoran.mc, probmap, choynowski, EBest, EBlocal)

export(airdist, card, cell2nb, vi2mrc, n.comp.nb, diffnb, dnearneigh, droplinks)

export(gabrielneigh, geary.test, geary, geary.mc, globalG.test, graph2nb, 
	joincount.test, joincount.mc, joincount.multi, print.jcmulti,
	knearneigh, knn2nb)

export(listw2sn, sn2listw, read.gwt2nb,	write.sn2gwt, lm.LMtests, 
	lm.morantest, localG, localG_perm, localmoran, localmoran_perm, moran,
	moran.test, moran.mc, moran.plot, localmoran.sad, lm.morantest.sad,
	nb2listw, nb2listwdist, nb2mat, listw2mat, mat2listw, invIrM, invIrW, nbdists, nblag,
	nblag_cumul, poly2nb, read.gal, write.nb.gal, read.geoda, relativeneigh,
	soi.graph, sp.correlogram, sp.mantel.mc, set.spChkOption, chkIDs,
	get.spChkOption, spNamedVec, tri2nb,
	spweights.constants, lag.listw, listw2U, listw2star, is.symmetric.nb,
	sym.attr.nb, include.self, make.sym.nb, union.nb, intersect.nb,
	setdiff.nb, complement.nb, Szero, spdep, print.nb, summary.nb, 
	plot.nb, edit.nb, subset.nb, summary.listw, print.listw, subset.listw,
	plot.Gabriel, plot.relative, print.jclist, print.LMtestlist, 
	plot.mc.sim, as.data.frame.localmoransad, print.localmoransad, 
	summary.localmoransad, print.summary.localmoransad, print.moransad, 
	summary.moransad, print.summary.moransad, print.spcor, plot.spcor)

export(write.sn2dat, read.dat2listw, nb2blocknb, p.adjustSP,
	is.symmetric.glist, nb2lines, listw2lines, df2sn, 
	plot.listw, aggregate.nb, old.make.sym.nb)

export(nb2WB, listw2WB, nb2INLA)

export(lm.morantest.exact, print.moranex, localmoran.exact, localmoran.exact.alt, print.localmoranex, as.data.frame.localmoranex)

export(mstree, nbcosts, nbcost, plot.mst, plot.skater, prunecost, ssw, prunemst, skater)

export(aple, aple.mc, aple.plot, localAple)

export(tolerance.nb, Rotation)

export(lee.mc, lee, lee.test)

export(LOSH, LOSH.cs, LOSH.mc)

export(grid2nb)

export(autocov_dist)

export(set.VerboseOption, get.VerboseOption, set.ZeroPolicyOption, 
        get.ZeroPolicyOption)
export(set.mcOption, get.mcOption, set.coresOption, get.coresOption,
        set.ClusterOption, get.ClusterOption)



export(errorsarlm) # deprecated (prabclus, spfrontier, ssfa)

export(lagsarlm) # deprecated (lagsarlmtree)

export(sacsarlm) # deprecated

export(print.sarlm, summary.sarlm, residuals.sarlm, deviance.sarlm, 
	coef.sarlm, fitted.sarlm, logLik.sarlm, anova.sarlm, vcov.sarlm,
	predict.sarlm, print.summary.sarlm, print.sarlm.pred, bptest.sarlm) # deprecated

export(lmSLX, create_WX, predict.SLX) # deprecated

export(spBreg_lag, spBreg_err, spBreg_sac) # deprecated

export(spautolm, residuals.spautolm, deviance.spautolm, coef.spautolm, 
	fitted.spautolm, print.spautolm, summary.spautolm, LR1.spautolm, 
	logLik.spautolm, print.summary.spautolm) # deprecated

export(MCMCsamp) # deprecated

export(do_ldet, eigen_setup, mcdet_setup, cheb_setup, spam_setup,
        Matrix_setup, LU_setup, Matrix_J_setup, spam_update_setup,
        moments_setup, SE_classic_setup, SE_whichMin_setup, SE_interp_setup,
        LU_prepermutate_setup, eigen_pre_setup) # deprecated (spatialprobit, splm, HSAR)

export(eigenw, jacobianSetup, can.be.simmed, similar.listw) # deprecated

export(trW, impacts, intImpacts) # deprecated (splm, sphet)

export(as_dgRMatrix_listw, as_dsTMatrix_listw, as_dsCMatrix_I,
	as_dsCMatrix_IrW, Jacobian_W, powerWeights) # deprecated

export(as.spam.listw) # deprecated (latticeDensity, splm)

export(LR.sarlm, LR1.sarlm, Wald1.sarlm) # deprecated

export(Hausman.test) # deprecated

export(SpatialFiltering, print.SFResult, fitted.SFResult,
	ME, print.ME_res, fitted.ME_res) # deprecated

export(lagmess) # deprecated

export(GMerrorsar, gstsls, GMargminImage,
	residuals.gmsar, deviance.gmsar, coef.gmsar, fitted.gmsar, 
	print.gmsar, summary.gmsar, print.summary.gmsar) # deprecated

export(stsls, print.stsls, summary.stsls, print.summary.stsls, 
	residuals.stsls, coef.stsls, deviance.stsls) # deprecated

export(mom_calc, mom_calc_int2) # deprecated

export(griffith_sone, subgraph_eigenw) # deprecated

export(lextrB, lextrW, lextrS, l_max) # deprecated

#import(maptools)

S3method(print, nb)
S3method(summary, nb)
S3method(plot, nb)
S3method(edit, nb)
S3method(subset, nb)
S3method(aggregate, nb)

S3method(summary, listw)
S3method(print, listw)
S3method(plot, listw)
S3method(subset, listw)
S3method(lag, listw)

S3method(plot, Gabriel)
S3method(plot, relative)

S3method(print, jclist)
S3method(print, jcmulti)
S3method(print, LMtestlist)
S3method(summary, LMtestlist)
S3method(print, LMtestlist.summary)
S3method(plot, mc.sim)

S3method(as.data.frame, localmoransad)
S3method(print, localmoransad)
S3method(summary, localmoransad)
S3method(print, summary.localmoransad)

S3method(print, moransad)
S3method(summary, moransad)
S3method(print, summary.moransad)

S3method(print, moranex)
S3method(print, localmoranex)
S3method(as.data.frame, localmoranex)

S3method(print, spcor)
S3method(plot, spcor)

S3method(plot, mst)
S3method(plot, skater)

# deprecate candidates

S3method(print, sarlm) # deprecated
S3method(summary, sarlm) # deprecated
S3method(residuals, sarlm) # deprecated
S3method(deviance, sarlm) # deprecated
S3method(coef, sarlm) # deprecated
S3method(vcov, sarlm) # deprecated
S3method(fitted, sarlm) # deprecated
S3method(logLik, sarlm) # deprecated
S3method(anova, sarlm) # deprecated
S3method(predict, sarlm) # deprecated
S3method(impacts, sarlm) # deprecated
S3method(print, summary.sarlm) # deprecated
S3method(print, sarlm.pred) # deprecated
S3method(as.data.frame, sarlm.pred)

S3method(Hausman.test, sarlm) # deprecated
S3method(MCMCsamp, sarlm) # deprecated

S3method(impacts, MCMC_sar_g) # deprecated
S3method(impacts, MCMC_sem_g) # deprecated
S3method(impacts, MCMC_sac_g) # deprecated

S3method(impacts, SLX) # deprecated
S3method(predict, SLX) # deprecated

S3method(residuals, spautolm) # deprecated
S3method(deviance, spautolm) # deprecated
S3method(coef, spautolm) # deprecated
S3method(fitted, spautolm) # deprecated
S3method(print, spautolm) # deprecated
S3method(summary, spautolm) # deprecated
S3method(logLik, spautolm) # deprecated
S3method(MCMCsamp, spautolm) # deprecated

S3method(print, summary.spautolm) # deprecated

S3method(residuals, gmsar) # deprecated
S3method(deviance, gmsar) # deprecated
S3method(coef, gmsar) # deprecated
S3method(fitted, gmsar) # deprecated
S3method(print, gmsar) # deprecated
S3method(summary, gmsar) # deprecated
S3method(Hausman.test, gmsar) # deprecated
S3method(impacts, gmsar) # deprecated

S3method(print, summary.gmsar) # deprecated

S3method(fitted, SFResult) # deprecated
S3method(print, SFResult) # deprecated
S3method(fitted, ME_res) # deprecated
S3method(print, ME_res) # deprecated

S3method(residuals, stsls) # deprecated
S3method(deviance, stsls) # deprecated
S3method(coef, stsls) # deprecated
S3method(print, stsls) # deprecated
S3method(summary, stsls) # deprecated
S3method(impacts, stsls) # deprecated

S3method(print, summary.stsls) # deprecated

S3method(print, lagImpact) # deprecated
S3method(plot, lagImpact) # deprecated
S3method(summary, lagImpact) # deprecated
S3method(HPDinterval, lagImpact) # deprecated
export(HPDinterval.lagImpact) # deprecated
S3method(print, summary.lagImpact) # deprecated

S3method(print, WXImpact) # deprecated
S3method(summary, WXImpact) # deprecated
S3method(print, summary.WXImpact) # deprecated

S3method(print, lagmess) # deprecated
S3method(summary, lagmess) # deprecated
S3method(print, summary.lagmess) # deprecated
S3method(residuals, lagmess) # deprecated
S3method(deviance, lagmess) # deprecated
S3method(coef, lagmess) # deprecated
S3method(fitted, lagmess) # deprecated
S3method(logLik, lagmess) # deprecated
S3method(impacts, lagmess) # deprecated

