useDynLib(fixest, .registration = TRUE)

#
# EXPORT
#

# main funs
export(feNmlm, femlm, feols, feglm, fepois, fenegbin)
export(feglm.fit, feols.fit)
export(est_env)
# etable
export(etable, style.tex, style.df)
export(log_etable)
export(extralines_register)
# misc funs
export(collinearity)
export(r2, fitstat, fitstat_register, wald)
export(fixest_startup_msg)
export(check_conv_feols)
# did
export(did_means)
# graph
export(coefplot, iplot)
# dof
export(dof, ssc, degrees_freedom)
# Lag related
export(panel, unpanel, f, l, d, lag_fml)
# factor/interactions/binning
export(i, bin, ref)
# macro
export(xpd)
# multiple estimations
export(models)
# utilities
export(to_integer, demean, obs)
export(as.dict)
# setters & getters
exportPattern("^(s|g)etFixest")

# coeftable and co
export(coeftable, se, pvalue, tstat)
S3method(coeftable, default)
S3method(coeftable, fixest)
S3method(coeftable, fixest_multi)
S3method(se, default)
S3method(se, matrix)
S3method(se, fixest)
S3method(se, fixest_multi)
S3method(pvalue, default)
S3method(pvalue, fixest)
S3method(pvalue, fixest_multi)
S3method(tstat, default)
S3method(tstat, fixest)
S3method(tstat, fixest_multi)

# VCOV funs
export(vcov_cluster, vcov_DK, vcov_NW, vcov_conley)

# Data manipulation
export(n_unik, osize, sample_df, fdim)

# dsb
export(dsb, .dsb, .dsb0)
S3method(print, dsb)

# deprecated
export(esttex, esttable)

# Base methods
S3method(print, fixest)
S3method(print, fixest_fitstat)
S3method(print, vec_n_unik)
S3method(print, list_n_unik)
S3method(print, osize)
S3method(summary, fixest.fixef)
S3method(summary, fixest)
S3method(summary, fixest_list)
S3method(summary, fixest_check_conv)
S3method(aggregate, fixest)
S3method(plot, fixest.fixef)
S3method("[", fixest_panel) # Lag related
# fixest_multi
S3method("[", fixest_multi)
S3method("[[", fixest_multi)
S3method(print, fixest_multi)
S3method(summary, fixest_multi)
S3method(as.list, fixest_multi)
# etable
S3method(print, etable_tex)
S3method(print, etable_df)

# rep
S3method(rep, fixest) # rep fixest objects
S3method(rep, fixest_list) # idem: rep a list of fixest objects
export(.l)

# Stats methods
S3method(nobs, fixest)
S3method(logLik, fixest)
S3method(AIC, fixest)
S3method(BIC, fixest)
S3method(vcov, fixest)
S3method(resid, fixest)
S3method(residuals, fixest)
S3method(coef, fixest)
S3method(coefficients, fixest)
S3method(fitted, fixest)
S3method(fitted.values, fixest)
S3method(update, fixest)
S3method(predict, fixest)
S3method(confint, fixest)
S3method(confint, fixest_multi)
S3method(formula, fixest)
S3method(model.matrix, fixest)
S3method(terms, fixest)
S3method(lag, formula)
S3method(deviance, fixest)
S3method(sigma, fixest)
S3method(weights, fixest)
S3method(hatvalues, fixest)

# Stats methods => fixest_multi
S3method(coef, fixest_multi)
S3method(coefficients, fixest_multi)
S3method(resid, fixest_multi)
S3method(residuals, fixest_multi)

# nlme method
S3method(fixef, fixest)

# sandwich method
S3method(estfun, fixest)
S3method(bread, fixest)

#
# IMPORT
#

import(dreamerr)

importFrom(numDeriv, hessian, jacobian, genD)

# needs re-export :-(, not the best solution but...
importFrom(nlme, fixef)
export(fixef)
importFrom(sandwich, estfun, bread, bwNeweyWest)
export(estfun, bread)

importFrom(stats, cor, dnorm, lm, nlminb, optim,
			  pnorm, qnorm, as.formula, var, sd, formula,
			  na.omit, model.frame, "na.pass", poisson, pt, hatvalues,
			  quasibinomial)

# stats methods
importFrom(stats, model.matrix, sigma, deviance, weights, terms,
             nobs, AIC, BIC, update, predict, fitted, fitted.values,
			  resid, residuals, logLik, coef, coefficients, lag,
			  confint, vcov, binomial, setNames, complete.cases, pchisq, pf,
			  aggregate, cancor, rnorm, median, qt, .getXlevels, quantile)

importFrom(utils, combn, head, tail, packageVersion, object.size, read.csv,
           write.csv, write.table, capture.output, as.roman)

importFrom(Rcpp, evalCpp)

importFrom(graphics, par, plot, box, axis, abline, points, text, title,
           lines, polygon, segments, plot.default, strwidth, strheight,
           rect)

importFrom(grDevices, rgb, col2rgb)

importFrom(methods, formalArgs)


# Auto-exports::vcov_aliases
export(NW, newey_west, DK, driscoll_kraay, conley)



