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

export(ri_clpm)
export(ri_clpm_stationary)
export(ri_clpm_search)
# RI-CLPN: the GGM-parameterized RI-CLPM (network parameterization):
export(ri_clpn)
export(ri_clpn_stationary)
export(ri_clpn_search)

# lavaan interoperability:
export(fromlavaan)
export(tolavaan)

export(logbook)

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

importFrom(rlang, .data)

export(fixstart)

export(aggregate_bootstraps)

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

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

export(factorscores)

importFrom(psych, fa)

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

export(setverbose)
export(update_baseline)
export(update_saturated)

# Multi-level models:
export(ml_tsdlvm1)
export(ml_ts_lvgvar)
export(ml_gvar)
export(ml_var)
export(ml_var1)
export(ml_gvar1)
export(ml_varcov)
export(ml_ggm)
export(ml_corr)
export(ml_lvm)
export(ml_lnm)
export(ml_rnm)
export(ml_lrnm)

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

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

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

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

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 / Spin models:
export(Ising)
export(BlumeCapel)

# 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(dlvm)
export(panelvar)
export(panelgvar)
export(panel_lvgvar)
export(panellvgvar)

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

# 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(allequal)
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", "summary")


### Imports ###
# importFrom(lavaan, lavCor, lavInspect)
import(dplyr)
#importFrom(matrixcalc,duplication.matrix,elimination.matrix,commutation.matrix)
import(Matrix)
importFrom(numDeriv, grad, jacobian, hessian)
importFrom(lavaan, lav_matrix_commutation, lavInspect, parTable, lavNames, sem, lavaan)
importFrom(corpcor, pseudoinverse)
#importFrom(optimx, optimx)
import(glasso)
importFrom(qgraph,qgraph,wi2net)
importFrom("graphics", "abline", "par")
  importFrom("methods", "as", "is", "new", ".hasSlot", "slot")
  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("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")