earlywarnings vignette

earlywarnings R package

Installation

Installing and loading the release version

install.packages("earlywarnings")

Installing and loading the experimental development version

library(devtools)
install_github("earlywarningtoolbox/earlywarnings-R/earlywarnings")

Clone the repository & install locally:

Run on command line:
git clone [email protected]:earlywarningtoolbox/earlywarnings-R.git
./build.sh

Loading the package

library(earlywarnings)  
## Loading required package: ggplot2
## Loading required package: moments
## Loading required package: tgp
## Loading required package: tseries
## Registered S3 method overwritten by 'quantmod':
##   method            from
##   as.zoo.data.frame zoo
## 
## earlywarnings Copyright (C) 2011-2022 Vasilis Dakos and Leo Lahti
## http://www.early-warning-signals.org

Potential analysis

Potential analysis, used for instance in [Hirota et al. Science, 2011, 334, 232-235.]

# Create simulated example data
X <- c(rnorm(1000, mean = 0), rnorm(1000, mean = -2), 
               rnorm(1000, mean = 2))
param <- seq(0,5,length=3000) 

# Run potential analysis
res <- movpotential_ews(X, param)

# Visualize
p <- PlotPotential(res$res, title = '', 
               xlab.text = '', ylab.text = '', 
           cutoff = 0.5, plot.contours = TRUE, binwidth = 0.2)
print(p)

Licensing and Citations

This work can be freely used, modified and distributed under the Two-clause (Free)BSD license.

Kindly cite the work as ‘Vasilis Dakos and Leo Lahti (2014). earlywarnings R package. URL: https://github.com/earlywarningtoolbox/earlywarnings-R’.

citation("earlywarnings")
## Warning in person1(given = given[[i]], family = family[[i]], middle =
## middle[[i]], : It is recommended to use 'family' instead of 'last'.
## Warning in person1(given = given[[i]], family = family[[i]], middle =
## middle[[i]], : It is recommended to use 'family' instead of 'last'.
## To cite earlywarnings in publications use:
## 
## To see these entries in BibTeX format, use 'print(<citation>,
## bibtex=TRUE)', 'toBibtex(.)', or set
## 'options(citation.bibtex.max=999)'.

Session info

This vignette was created with

sessionInfo()
## R version 4.4.2 (2024-10-31)
## Platform: x86_64-pc-linux-gnu
## Running under: Ubuntu 24.04.2 LTS
## 
## Matrix products: default
## BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 
## LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.26.so;  LAPACK version 3.12.0
## 
## locale:
##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
##  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=C              
##  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
##  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
##  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
## 
## time zone: Etc/UTC
## tzcode source: system (glibc)
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
## [1] earlywarnings_1.1.29 tseries_0.10-58      tgp_2.4-23          
## [4] moments_0.14.1       ggplot2_3.5.1       
## 
## loaded via a namespace (and not attached):
##  [1] sass_0.4.9         nortest_1.0-4      KernSmooth_2.23-26 lattice_0.22-6    
##  [5] digest_0.6.37      magrittr_2.0.3     evaluate_1.0.3     grid_4.4.2        
##  [9] maptree_1.4-8      maps_3.4.2.1       fastmap_1.2.0      jsonlite_1.9.0    
## [13] som_0.3-5.2        spam_2.11-1        viridisLite_0.4.2  scales_1.3.0      
## [17] isoband_0.2.7      jquerylib_0.1.4    cli_3.6.4          rlang_1.1.5       
## [21] Kendall_2.2.1      munsell_0.5.1      withr_3.0.2        cachem_1.1.0      
## [25] yaml_2.3.10        tools_4.4.2        colorspace_2.1-1   boot_1.3-31       
## [29] curl_6.2.1         buildtools_1.0.0   vctrs_0.6.5        R6_2.6.1          
## [33] rpart_4.1.24       zoo_1.8-13         lifecycle_1.0.4    cluster_2.1.8     
## [37] pkgconfig_2.0.3    pillar_1.10.1      bslib_0.9.0        gtable_0.3.6      
## [41] Rcpp_1.0.14        glue_1.8.0         quantmod_0.4.26    fields_16.3       
## [45] xfun_0.51          tibble_3.2.1       lmtest_0.9-40      sys_3.4.3         
## [49] knitr_1.49         farver_2.1.2       htmltools_0.5.8.1  labeling_0.4.3    
## [53] rmarkdown_2.29     xts_0.14.1         maketools_1.3.2    dotCall64_1.2     
## [57] compiler_4.4.2     quadprog_1.5-8     TTR_0.24.4