importFrom("methods", "new")
importFrom("stats", "as.formula", "coef", "coefficients",
           "fitted.values", "lm", "model.extract", "model.frame",
           "na.fail", "optimize", "pchisq", "pnorm", "printCoefmat",
           "residuals", "terms", "var", "vcov")
importFrom("stats", "cor", "lm.fit", "reshape", "resid")
importFrom("plm", "pdata.frame")
importFrom(stats, model.matrix, model.response, aggregate, effects)
importFrom(stats, optim, nlminb)
importFrom(plm, plm)
importFrom(plm, pmodel.response)
importFrom(plm, pdim)
importFrom(nlme, fdHess, lme)


#if (packageVersion("spdep") < 1.2) {
#  import(spdep, except=c(do_ldet, eigen_setup, trW, impacts.gmsar, impacts))
#  importFrom(spatialreg, do_ldet, eigen_setup, trW, impacts)
#} else {
#  import(spdep, except=c(set.ClusterOption, set.VerboseOption, set.mcOption, 
#    get.VerboseOption, get.coresOption, set.coresOption, set.ZeroPolicyOption, 
#    get.mcOption, get.ClusterOption, get.ZeroPolicyOption))
#  import(spatialreg)
#}

## check if we can rationalize imports from spdep and spatialreg (also to avoid
## problematic dependencies like, e.g., gdata)
if (packageVersion("spdep") < 1.2) {
  import(spdep, except=c(do_ldet, eigen_setup, trW, impacts.gmsar, impacts))
  importFrom(spatialreg, do_ldet, eigen_setup, trW, impacts)
} else {
  #import(spdep, except=c(set.ClusterOption, set.VerboseOption, set.mcOption, 
   # get.VerboseOption, get.coresOption, set.coresOption, set.ZeroPolicyOption, 
    #get.mcOption, get.ClusterOption, get.ZeroPolicyOption))
    importFrom(spdep, mat2listw, listw2mat, lag.listw, nblag,
               is.symmetric.nb, is.symmetric.glist, card)
    importFrom(spatialreg, impacts,
             do_ldet, eigen_setup, trW,
             eigen_pre_setup, Matrix_setup, Matrix_J_setup, spam_setup,
             spam_update_setup, cheb_setup, mcdet_setup, LU_setup,
             LU_prepermutate_setup, moments_setup,
             SE_classic_setup, SE_whichMin_setup, SE_interp_setup,
             as.spam.listw, get.ZeroPolicyOption)
}


importFrom(ibdreg, pchibar)
import(Matrix)
importFrom(spam, as.spam, diag.spam, solve.spam, t.spam, determinant.spam)
importFrom(maxLik, maxLik)
importFrom(bdsmatrix, bdsmatrix)
importFrom(MASS, ginv)
importFrom(parallel, mclapply)


export(bsktest, sphtest, bsjktest, vcov.splm,
effects.splm, print.effects.splm, slag, 
print.splm, spml, spgm, summary.splm, sphtest,
listw2dgCMatrix, spreml, rwtest, slmtest)



S3method(print, splm)
S3method(print, summary.splm)
S3method(effects, splm)
S3method(vcov, splm)
S3method(print, effects.splm)
S3method(bsktest, formula)
S3method(bsjktest, formula)
S3method(summary, splm)
S3method(sphtest, formula)
S3method(sphtest, splm)
S3method(impacts, splm)
S3method(slag, pseries)
S3method(rwtest, formula)
S3method(rwtest, panelmodel)
S3method(rwtest, pseries)
S3method(slmtest, formula)
S3method(slmtest, plm)
