### Dynlib ###
useDynLib(psychonetrics, .registration = TRUE)

export(ri_clpm)
export(ri_clpm_stationary)

export(logbook)

importFrom("grDevices", "rgb")
    importFrom("stats", "quantile")
    importFrom("utils", "capture.output")

importFrom(rlang, .data)

export(fixstart)

export(aggregate_bootstraps)

export(checkJacobian)
export(checkJacobian)
export(checkFisher)
export(transmod)

export(CIplot)
export(emergencystart)
export(partialprune)

export(factorscores)

importFrom(psych, fa)
importFrom(GA, ga)
importFrom(combinat, permn)

# importFrom(metaSEM, asyCov)
export(meta_ggm)
export(simplestructure)

export(setverbose)

# Multi-level models:
export(ml_tsdlvm1)
export(ml_ts_lvgvar)
export(ml_gvar)
export(ml_var)
export(ml_lvm)
export(ml_lnm)
export(ml_rnm)
export(ml_lrnm)

export(meta_varcov)
export(meta_lvm)
export(meta_var1)
export(meta_gvar)

# Ergodic:
export(esa)
export(esa_manual)
# import(ggplot2)
# import(tidyr)
importFrom(tidyr, gather, pivot_wider)

S3method(plot, esa)
S3method(plot, esa_manual)

S3method(print, esa)
S3method(print, esa_manual)
S3method(print, psychonetrics_compare)

S3method(print, psychonetrics_log)

import(IsingSampler)

# Crayon:
# import(crayon)

### Exports ###
# exportPattern("^[[:alpha:]]+")
#  varcov models:
export(covML)
export(covMLtoUB)
export(covUBtoML)
export(varcov)
export(ggm)
export(precision)
export(cholesky)
export(prec)
export(corr)
# export(meta_varcov)
export(modelsearch)

# Ising models:
export(Ising)

# lvm models:
export(lvm)
export(lnm)
export(rnm)
export(lrnm)
export(bifactor)
export(latentgrowth)

export(getVCOV)

# VAR models:
export(var1)
export(gvar)

# Panel var models:
export(dlvm1)
export(panelvar)
export(panelgvar)
export(panel_lvgvar)
export(panellvgvar)

# Time-series lvvar models:
export(ts_lvgvar)
export(tsdlvm1)

# extra:
# export(joingroups)
# export(frombootnet)

# Model expansions:
export(addMIs)
export(addSEs)
export(addfit)
export(identify)

# Run:
export(runmodel)

# Search:
export(stepup)
export(prune)

# Model modification:
export(fixpar)
export(freepar)
export(groupequal)
export(groupfree)
export(intersectionmodel)
export(unionmodel)
export(parequal)

# Convenience functions:
export(changedata)
export(generate)
export(setestimator)
export(setoptimizer)
export(usecpp)
export(MIs)
export(bootstrap)
# export(bootstrap_SEs)
export(fit)
export(getmatrix)
export(compare)
export(parameters)
export(write_psychonetrics)
# export(replicator)
export(loop_psychonetrics)

# Penalized ML:
export(penalize)
export(unpenalize)
export(refit)
export(penaltyVector)
export(find_penalized_lambda)

# Special matrices:
export(duplicationMatrix, eliminationMatrix, diagonalizationMatrix)

# export Classes
exportClasses("psychonetrics","psychonetrics_log","psychonetrics_bootstrap")
#exportClasses("psychonetrics_samplestats","psychonetrics_log","psychonetrics" )

# export Methods
exportMethods("show", "resid", "residuals")


### Imports ###
# importFrom(lavaan, lavCor, lavInspect)
import(dplyr)
importFrom(abind, abind)
#importFrom(matrixcalc,duplication.matrix,elimination.matrix,commutation.matrix)
import(Matrix)
importFrom(numDeriv, grad, jacobian, hessian)
importFrom(lavaan, lav_matrix_commutation)
importFrom(corpcor, pseudoinverse)
#importFrom(optimx, optimx)
import(glasso)
importFrom(qgraph,qgraph,wi2net)
importFrom("graphics", "abline", "par")
  importFrom("methods", "as", "is", "new", ".hasSlot")
  importFrom("stats", "nlminb", "pchisq", "pnorm", "qchisq", "runif",
             "uniroot","cov")
  importFrom("utils", "sessionInfo", "modifyList")

importFrom("mgcv","uniquecombs")
importFrom("optimx","optimr")
importFrom("nloptr","tnewton")
#importFrom("mvtnorm","rmvnorm")
importFrom("VCA","MPinv")
importFrom("pbapply","pblapply")
import(parallel)
import(magrittr)


  importFrom("stats", "na.omit", "p.adjust", "rnorm", "sd")
     importFrom("utils", "setTxtProgressBar", "txtProgressBar")
     
     importFrom("stats", "qnorm")
     
     importFrom("stats", "cor", "weighted.mean")
     
     importFrom("stats", "median")