# only when we have src code
# useDynLib("restriktor")
importFrom("lavaan",
           lavParseModelString,
           #lav_constraints_parse,
           lav_partable_constraints_def,
           lav_func_jacobian_complex,
           lav_func_jacobian_simple,
           lav_partable_constraints_ciq,
           lav_partable_constraints_ceq,
           lav_matrix_vech_idx,
           lav_matrix_vechru_idx,
           lav_matrix_symmetric_sqrt,
           lav_matrix_bdiag,
           lav_matrix_duplication_post,
           lav_matrix_duplication_pre_post,
           lav_samplestats_from_data,
           lav_data_update,
           lav_partable_add,
           lav_model_implied,
           standardizedSolution,
           parTable,
           lavInspect,
           sem,   # conTestD
           lavaan # conTestD
           )

importFrom("glue",
           glue)


importFrom("mvtnorm",
           #rmvnorm, 
           dmvnorm)

# truncated multivariate normal
importFrom("tmvtnorm",
           rtmvnorm)

importFrom("quadprog",
           solve.QP)

importFrom("boot",
           boot,
           boot.ci)

importFrom("MASS",
           psi.bisquare,
           psi.huber,
           ginv)

importFrom("pbapply", 
           pblapply,
           pboptions)


importFrom("ic.infer",
           #nchoosek, NOT EXPORTED!
           ic.weights)

importFrom("utils", combn, packageDescription, menu, capture.output)

importFrom("stats", coef, df.residual, dnorm, fitted,
           formula, frequency, median, model.matrix,
           naresid, pchisq, pf, pnorm, printCoefmat, pt,
           quantile, rchisq, residuals, rnorm, rt, runif,
           sd, start, terms, update, var, vcov,
           weighted.residuals, weights, gaussian, lm.fit,
           lm.wfit, mad, coefficients, family, logLik,
           model.frame, anova, optimize, sigma, cov, dist, lm, uniroot) 

importFrom("graphics", abline, axis, box, hist, par)

importFrom("norm", em.norm, prelim.norm, imp.norm, rngseed)

importFrom("ggplot2", ggplot, aes, .data, geom_point, geom_line, theme, unit, margin,
           element_blank, element_text, element_line, scale_y_continuous, 
           scale_x_discrete, labs, guides, guide_legend, scale_color_brewer)

#importFrom("lpSolve", lp)


# export ordinary functions defined in this package
export("restriktor", 
       "conLM.lm", "conRLM.rlm", "conGLM.glm", "conMLM.mlm", 
       "conTest", "iht", 
       "conTest_summary", "conTest_ceq", "conTestC",
       "conTestF.conLM", "conTestF.conRLM", "conTestF.conGLM", 
       "conTestLRT.conLM", "conTestLRT.conGLM", "conTestLRT.conMLM", 
       "conTestScore.conLM", "conTestScore.conRLM", "conTestScore.conGLM", 
       "conTestWald.conRLM", 
       "conTestC.restriktor", 
       "conTest_ceq.conLM", "conTest_ceq.conRLM", "conTest_ceq.conGLM", 
       "conTestD", "bootstrapD", 
       "goric", "calculate_IC_weights",
       #"print.con_goric", "print.conTestLavaan",
       #"print.restriktor", "print.summary.restriktor",
       "summary.restriktor", "conTest_summary.restriktor",
       #"print.conTest", 
       "logLik.restriktor",
       "coef.restriktor", "model.matrix.restriktor",
       "con_weights_boot", "coef.con_goric", 
       #"summary.con_goric", 
       "evSyn", "plot.evSyn",
       "calculate_IC_weights", "calc_ICweights",
       "print.goric_ICw"#,
       #"benchmarks_ANOVA"
       #"benchmarks_goric"
       #"print.evSyn", 
       #"summary.evSyn",
       #"print.summary.evSyn"
       )

S3method(coef, restriktor)
S3method(model.matrix, restriktor)
S3method(logLik, restriktor)
S3method(print, restriktor)
S3method(print, conTest)
S3method(print, conTestLavaan)
S3method(print, summary.restriktor)
S3method(summary, restriktor)
S3method(print, con_goric)
S3method(summary, con_goric)
S3method(coef, con_goric)
#S3method(plot, conTestLavaan)

#S3method(conTestD, conLavaan)
S3method(conTestC, restriktor)
S3method(conTestLRT, conLM)
S3method(conTestLRT, conGLM)
S3method(conTestLRT, conMLM)
S3method(conTestScore, conLM)
S3method(conTestScore, conRLM)
S3method(conTestScore, conGLM)
S3method(conTestWald, conRLM)
S3method(conTestF, conLM)
S3method(conTestF, conRLM)
S3method(conTestF, conGLM)
S3method(conTest_ceq, conLM)
S3method(conTest_ceq, conRLM)
S3method(conTest_ceq, conGLM)
S3method(conTest_summary, restriktor)

S3method(conLM, lm)
S3method(conRLM, rlm)
S3method(conGLM, glm)
S3method(conMLM, mlm)

S3method(goric, default)
#S3method(goric, restriktor)
S3method(goric, lm)
S3method(goric, lavaan)
S3method(goric, numeric)
S3method(goric, CTmeta)
S3method(goric, rma)

S3method(evSyn_est, list)
S3method(evSyn_LL, list)
S3method(evSyn_ICvalues, list)
S3method(evSyn_ICweights, list)
S3method(plot, evSyn)
S3method(print, evSyn)
S3method(summary, evSyn)
S3method(print, summary.evSyn)

S3method(print, goric_ICw)