\name{ELAplus-package}
\alias{ELAplus-package}
\alias{ELAplus}
\docType{package}
\title{
\packageTitle{ELAplus}
}
\description{
\packageDescription{ELAplus}
}
\details{
This package provides tools for energy landscape analysis (ELA),
a framework for analyzing dynamical systems represented as weighted
networks. The main functions support construction of energy landscapes,
by fitting the community composition data to a pairwise maximum entropy model
(or its extension) and subsequent identification of stable states, and
analysis of transitions between community compositions.
}
\author{
\packageAuthor{ELAplus}

Maintainer: \packageMaintainer{ELAplus}
}
\references{
Suzuki, K., Nakaoka, S., Fukuda, S., & Masuya, H. (2021). 
"Energy landscape analysis elucidates the multistability of ecological communities across environmental gradients." 
Ecological Monographs.
\doi{10.1002/ecm.1469}
\url{https://esajournals.onlinelibrary.wiley.com/doi/abs/10.1002/ecm.1469}
}
\keyword{models}
\keyword{multivariate}
\seealso{
GitHub: \url{https://github.com/kecosz/rELA},
Portal: \url{https://elaportal.org}
}
\examples{
# load sample dataset
data("baseabtable")
data("basemetadata")
# Formatting dataset
formatted <- Formatting(baseabtable, basemetadata, 0, c(0.05, 0.05, 0.95))
ocvecs <- formatted[[1]]
envecs <- formatted[[3]]
# Example (without environmental parameters)
# Fitting the data to the extended maximum pairwise entropy model
# without explicit environmental parameters
sa <- runSA(
  ocvecs,
  enmat   = NULL,
  rep     = 1,
  getall  = FALSE,
  lambda  = 0.01,
  we      = 0.001,
  maxlr = 0.005,
  totalit = 1000
)

# Using the fitted model, normal ELA is run.
ela <- ELA(sa, env=NULL,
           threads=1,SS.itr=2000,
           FindingTip.itr=1000,
           reporting=TRUE)
# Pruning stable states
elap <- ELPruning(ela, th=0.1)
# show disconnectivity graph
showDG(elap[[1]], ocvecs, "test")
# show species interaction graph
showIntrGraph(elap[[1]], sa, th=0.01,
              annot_adj=c(0.75, 2.00))
              
# Example (with environmental parameters)   
# Find best parameter sets for the machine learning (with envecs)
\donttest{
bpresult <- Findbp(ocvecs,enmat=envecs,rep=1,threads=1,nrepeat=1,cvmode="5fold")
bp <- bpresult[[1]]
bpm <- as.numeric(unlist(strsplit(names(bp)[1], split = "_")))
# Fitting the data to the extended maximum pairwise entropy model
# with explicit environmental parameters
sa <- runSA(
  ocvecs,
  enmat   = envecs,
  rep     = 16,
  getall  = FALSE,
  lambda  = bpm[[1]],
  we      = bpm[[2]],
  maxlr = bpm[[3]],
  totalit = bpm[[4]]
)
# Using the fitted model, gradient ELA is run.
gela <- GradELA(
  sa      = sa,
  eid     = "factor.1",
  enmat   = envecs,
  env     = NULL,
  range   = c(0, 1),
  steps   = 32,
  th      = 0.05,
  threads = 2
)
showSSD(gela)
}
}
