
useDynLib(ergm)

importFrom(robustbase, lmrob, covMcd)
importFrom(trust, trust)
importFrom(Matrix, nearPD)
importFrom(lpSolve, lp)
import(statnet.common, network, coda, parallel)
importFrom(stats,simulate, qnorm)
importFrom(MASS,ginv)
importFrom("grDevices", "colors", "dev.cur", "dev.off", "dev.set",
             "pictex", "rainbow")
importFrom("graphics", "boxplot", "lines", "mtext", "pairs", "par",
             "plot", "points", "polygon")
importFrom("stats", "AIC", "BIC", "ar", "as.formula", "coef", "cov",
             "cov.wt", "dlogis", "end", "formula", "influence", "logLik",
             "median", "model.extract", "model.frame", "model.matrix",
             "na.omit", "nobs", "optim", "pchisq", "pf", "plogis",
             "pnorm", "predict", "printCoefmat", "pt", "qf", "quantile",
             "runif", "sd", "start", "terms", "uniroot", "update", "var",
             "vcov", "weighted.mean", "window")
importFrom("utils", "packageDescription","capture.output", "flush.console", "methods",
             "packageVersion", "tail","getAnywhere")
importFrom("methods",'findFunction',"is")

# Export all names that do not begin with a dot.
#exportPattern("^[^\\.]")
export(
  anova.ergm,
  anova.ergmlist,                  
  approx.hotelling.diff.test,      
  #as.edgelist,                  moved to network
  as.edgelist.compressed,          
  #as.edgelist.matrix,           moved to network
  #as.edgelist.network,          moved to network  
  #as.network.numeric,           made internal
  #as.network.uncompressed,      made internal
  central.network, # deprecated
  check.ErgmTerm,                  
  coef.ergm,
  coefficients.ergm,               
  coef.length.model,
  coef.sublength.model,            
  colMeans.mcmc.list,
  control.ergm,                    
  control.ergm.bridge,
  # control.ergm.toplevel,      made internal    
  control.gof.ergm,
  control.gof.formula,             
  control.logLik.ergm,
  control.san,                     
  control.simulate,
  control.simulate.ergm,           
  # control.simulate.ergm.toplevel,  made internal
  control.simulate.formula,        
  control.simulate.formula.ergm,
  # copy.named,    deleted              
  degreedist,
  degreedistfactor, # deprecated           
  delete.isolates,  # deprecated
  # drawcircle,                    made interal      
  drawpie,     # deprecated in favor of ergmm.drawpie in latentnet
  dspartnerdist,            # deprecated       
  enformulate.curved,
  enformulate.curved.ergm,         
  enformulate.curved.formula,
  ergm,                            
  ergm.allstats,
  ergm.bounddeg,                   
  ergm.bridge.0.llk,  
  ergm.bridge.dindstart.llk,       
  ergm.bridge.llr,
  # ergm.bridge.preproc,      made interal
  ergm.checkargs,
  # ergm.checkbipartite,          made interal       
  # ergm.checkconstraints.model,    made interal
  # ergm.checkdegeneracy,               made interal 
  ergm.checkdirected,
  # ergm.checkextreme.model,         made internal
  # ergm.coefficient.degeneracy, proposed to make internal
  # ergm.compute.degeneracy,         proposed to make internal
  ergm.ConstraintImplications,
  ergm.Cprepare,                   
  ergm.Cprepare.el,
  ergm.Cprepare.miss,       
  # ergm.curved.statsmatrix,    proposed to make internal
  ergm.degeneracy,                 
  ergm.design,
  ergm.el.lasttoggle,              
  #ergm.estimate,    made internal
  ergm.eta,                        
  ergm.etagrad,
  ergm.etagradmult,                
  ergm.etamap,
  ergm.exact,                      
  #ergm.geodesicmatrix,  made internal 
  #ergm.geodesicmatrix.edgelist,    made internal
  ergm.geodistdist,
  ergm.geodistn,                   
  ergm.getCluster,
  ergm.getglobalstats,             
  ergm.getMCMCsample,
  ergm.getmodel,                   
  ergm.getnetwork,
  ergm.getterms,                   
  # ergm.initialfit,    made internal
  ergm.init.methods,               
  #ergm.llik.wins,
  ergm.logisticdeviance,           
  ergm.logitreg,
  ergm.mahalanobis,       # deprecated
  # ergm.mapl,
  # ergm.maple,           made internal      
  # ergm.MCMC.packagenames, made internal
  #ergm.MCMCse,            made internal           
  #ergm.MCMCse.lognormal,  made internal
  ergm.mcmcslave,                  
  #ergm.MCMLE,             made internal
  ergm.MHP.table, 
  #ergm.MPIcluster.started,  made internal
  ergm.mple,                       
  ergmMPLE,
  #ergm.nodegeodesics,        made internal      
  #ergm.pairgeodesic,         made internal
  # ergm.pen.glm,             made internal
  # ergm.phase12,            made internal
  ergm.pl,                         
  # ergm.reviseinit, made internal
  # ergm.rhs.formula,      made internal       
  # ergm.robmon, made internal
  # ergm.sample.eta2theta,      made internal     
  # ergm.sample.tomcmc,  made internal
  # ergm.stepping,       made internal         
  # ergm.stocapprox, made internal
  ergm.stopCluster,                
  #ergm.stopCluster.default,  made internal
  #ergm.stopCluster.MPIcluster,      made internal
  # ergm.sufftoprob,  made internal
  # ergm.t.summary,           made internal   
  ergm.update.formula,
  espartnerdist,              # deprecated      
  fix.curved,
  fix.curved.ergm,                 
  fix.curved.formula,
  get.free.dyads,                  
  # get.InitErgm.fname,  made internal
  get.miss.dyads,                  
  get.node.attr,
  gof,                             
  gof.default,
  gof.ergm,                        
  gof.formula,
                     
  invert.network,       # deprecated         
  is.durational,
  is.durational.character,         
  is.durational.ergm.model,
  is.durational.formula,           
  is.durational.NULL,
  is.dyad.independent,             
  is.dyad.independent.conlist,
  is.dyad.independent.ergm,        
  is.dyad.independent.ergm.model,
  is.dyad.independent.formula,     
  is.dyad.independent.NULL,
  is.curved,             
  is.curved.ergm,        
  is.curved.ergm.model,
  is.curved.formula,     
  is.curved.NULL,
  is.ergm,                         
  is.inCH,
  is.invertible,           # deprecated
  largest.components,      # deprecated
  #llik.fun,             made internal           
  #llik.fun2,            made internal
  #llik.fun3,            made internal           
  #llik.fun.EF,          made internal
  #llik.fun.logtaylor,   made internal         
  #llik.fun.median,      made internal
  #llik.fun.obs,         made internal           
  #llik.fun.obs.robust,  made internal
  #llik.grad,            made internal           
  #llik.grad2,           made internal
  #llik.grad3,           made internal           
  #llik.grad.obs,        made internal
  #llik.hessian,         made internal           
  #llik.hessian2,        made internal
  #llik.hessian.naive,   made internal         
  #llik.hessian.obs,     made internal
  #llik.info3,           made internal             
  #llik.mcmcvar3,        made internal
  #logistftest,          made internal                  
  logLik.ergm,
  logLikNull,                      
  logLikNull.ergm,
  mcmc.diagnostics,                
  mcmc.diagnostics.default,
  mcmc.diagnostics.ergm,           
  MHproposal,
  MHproposal.character,            
  MHproposal.ergm,
  MHproposal.formula,              
  MHproposal.MHproposal,
  MHproposal.NULL,                 
  #midarrow,  proposed delete
  #mk.conlist,         made internal                 
  #mk.edge.to.pos.lasttoggle.f,   made internal
  # model.matrix.pen.glm,               made internal 
  # model.transform.formula,   made internal
  mvmodel,              # deprecated      
  mvmodel.default,      # deprecated
  mvmodel.ergm,         # deprecated           
  mvmodel.formula,      # deprecated
  #myLibLoc,              made internal 
  network.update,
  newnw.extract,                   
  #nologLik.message,     made internal 
  nvattr.copy.network,             
  offset.info.formula,
  ostar2deg,             # deprecated          
  plot.ergm,
  plot.gofobject,                  
  plot.mcmc.list.ergm,
  plot.network.ergm,               
  print.ergm,
  print.gofobject,                 
  print.network.list,
  print.summary.ergm,              
  #prune.conlist,     # made internal
  remove.offset.formula,           
  robust.inverse, # deprecated
  rspartnerdist,         # deprecated    
  san,
  san.default,                     
  san.ergm,
  san.formula,                     
  search.ergmTerms,
  # set.offset.formula,       made internal    
  simulate.ergm,
  simulate.formula,                
  sociality,            # deprecated
  sociality.default,    # deprecated  
  sociality.ergm,       # deprecated
  sociality.formula,    # deprecated           
  sociality.network,    # deprecated
  standardize.network,             
  summary.ergm,
  summary.formula,                 
  summary.gofobject,
  summary.network.list,            
  summary.statistics,
  summary.statistics.default,      
  summary.statistics.ergm,
  summary.statistics.formula,      
  summary.statistics.matrix,
  summary.statistics.network,      
  summary.statistics.network.list,
  summary.statsmatrix.ergm,        
  sweep.mcmc.list,
  to.lasttoggle.matrix,
  to.matrix.lasttoggle,            
  # twopathdist,     proposed to make internal 
  # unset.offset.formula,      proposed to make internal      
  # updatemodel.ErgmTerm,    proposed to make internal 
  vcov.ergm,                       
  # which.package.InitFunction, proposed to make internal
  wtd.median
)

# export all the ergm terms
# exportPattern("^InitErgmTerm.*")
# export all the weighted ergm terms
# exportPattern("^InitWtErgmTerm.*")
# export all the constaints
#exportPattern("^InitConstraint.*")
# export all the MH proposals
#exportPattern("^InitMHP.*")
# export all the weighted MH proposals
#exportPattern("^InitWtMHP.*")

# export all reference distributions
#exportPattern("^InitReference.*")

  


# register S3 methods so they will be visable when
# namespace is attached but package not loaded

S3method(MHproposal,MHproposal) 
S3method(MHproposal,NULL) 
S3method(MHproposal,character)
S3method(MHproposal,ergm)
S3method(MHproposal,formula)

S3method(anova,ergm)
S3method(anova,ergmlist)

S3method(as.network,numeric)
#S3method(as.network,uncompressed)
S3method(as.edgelist,compressed)
#S3method(as.edgelist,matrix)
#S3method(as.edgelist,network)

S3method(coef,ergm)
S3method(coef,length.model)
S3method(coef,sublength.model)
S3method(enformulate.curved,ergm)
S3method(enformulate.curved,formula)

S3method(ergm.stopCluster,MPIcluster)
S3method(ergm.stopCluster,default) 

S3method(fix.curved,ergm)
S3method(fix.curved,formula)

S3method(gof,default) 
S3method(gof,ergm)
S3method(gof,formula)

S3method(is.durational,NULL)
S3method(is.durational,character)
S3method(is.durational,ergm.model)
S3method(is.durational,formula)

S3method(is.dyad.independent,NULL)
S3method(is.dyad.independent,conlist) 
S3method(is.dyad.independent,ergm)
S3method(is.dyad.independent,ergm.model)
S3method(is.dyad.independent,formula)

S3method(is.curved,NULL)
S3method(is.curved,ergm)
S3method(is.curved,ergm.model)
S3method(is.curved,formula)

S3method(logLik,ergm)
S3method(logLikNull,ergm)

S3method(mcmc.diagnostics,default)
S3method(mcmc.diagnostics,ergm)

S3method(model.matrix,pen.glm)

S3method(mvmodel,default)
S3method(mvmodel,ergm)
S3method(mvmodel,formula)

S3method(plot,ergm)
S3method(plot,gofobject)
S3method(plot,mcmc.list.ergm)
S3method(plot,network.ergm)

S3method(print,ergm)
S3method(print,gofobject)
S3method(print,network.list)
S3method(print,summary.ergm)

S3method(san,default)
S3method(san,ergm)
S3method(san,formula)

S3method(simulate,ergm)
S3method(simulate,formula)

# why does sociality have S3 forms but other terms don't?
S3method(sociality,default)
S3method(sociality,ergm)
S3method(sociality,formula)
S3method(sociality,network)

S3method(summary,ergm)
S3method(summary,formula)
S3method(summary,gofobject)
S3method(summary,network.list)
S3method(summary,statistics)
S3method(summary.statistics,default)
S3method(summary.statistics,ergm)
S3method(summary.statistics,formula)
S3method(summary.statistics,matrix)
S3method(summary.statistics,network)
S3method(summary.statistics,network.list)
S3method(summary,statsmatrix.ergm)
         
S3method(vcov,ergm)
