Code Monkey home page Code Monkey logo

miamaxent's Introduction

MIAmaxent

CRAN_Status_Badge CRAN download rate

Read our open-access paper in Ecology and Evolution introducing MIAmaxent: https://doi.org/10.1002/ece3.5654.

Description

Tools for training, selecting, and evaluating maximum entropy (and standard logistic regression) distribution models. This package provides tools for user-controlled transformation of explanatory variables, selection of variables by nested model comparison, and flexible model evaluation and projection. It follows principles based on the maximum-likelihood interpretation of maximum entropy modeling (Halvorsen et al., 2015), and uses infinitely-weighted logistic regression for model fitting (Fithian & Hastie, 2013).

MIAmaxent is intended primarily for maximum entropy distribution modeling (Phillips et al., 2006; Phillips et al., 2017), and provides an alternative to the standard methodology for training, selecting, and using models. The major advantage in this alternative methodology is greater user control – in variable transformations, in variable selection, and in model output. Comparisons also suggest that this methodology results in simpler models with equally good predictive ability, and reduces the risk of overfitting (Halvorsen et al., 2016).

The predecessor to this package is the MIA Toolbox, which is described in detail in Mazzoni et al. (2015).

Installation

Install the release version from CRAN:

install.packages("MIAmaxent")

Or the development version from GitHub:

# install.packages(c("remotes", "R.rsp"))
remotes::install_github("julienvollering/MIAmaxent", build_vignettes = TRUE)

User Workflow

This diagram outlines a common workflow for users of this package. Functions are shown in red.

References

Fithian, W., & Hastie, T. (2013). Finite-sample equivalence in statistical models for presence-only data. The annals of applied statistics, 7(4), 1917.

Halvorsen, R., Mazzoni, S., Bryn, A. & Bakkestuen, V. (2015) Opportunities for improved distribution modelling practice via a strict maximum likelihood interpretation of MaxEnt. Ecography, 38, 172-183.

Halvorsen, R., Mazzoni, S., Dirksen, J.W., Næsset, E., Gobakken, T. & Ohlson, M. (2016) How important are choice of model selection method and spatial autocorrelation of presence data for distribution modelling by MaxEnt? Ecological Modelling, 328, 108-118.

Mazzoni, S., Halvorsen, R. & Bakkestuen, V. (2015) MIAT: Modular R-wrappers for flexible implementation of MaxEnt distribution modelling. Ecological Informatics, 30, 215-221.

Phillips, S.J., Anderson, R.P., Dudík, M., Schapire, R.E., & Blair, M.E. (2017). Opening the black box: an open‐source release of Maxent. Ecography, 40(7), 887-893.

Phillips, S.J., Anderson, R.P. & Schapire, R.E. (2006) Maximum entropy modeling of species geographic distributions. Ecological Modelling, 190, 231-259.

miamaxent's People

Contributors

julienvollering avatar mbedward avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

miamaxent's Issues

"error: can not find or can not load the main class <name>"

Dear problem solver,

I can't make the java command work. It started out as a problem with executing the class file
java program
, where I was told the program had been compiled by a more recent version (jdk 13.0.2, displayed as 57 if I remember correctly) than the java runtime environment (being jre.1.8.0-241). After having desperately tried to solve that problem - changing paths both in windows environment as well as Java's settings - I resorted to simply "downgrading" my jdk to the same version as the jre. Now javac still works fine, but as mentioned, now the "java" command can't even be found. I assume I've made some very simple mistake, but I just can't seem to solve it. Please help!

Error running selectDVforEV function

Dear @julienvollering,

We got this error message and have not been able to figure out what's going on.

code:
DVselect <- selectDVforEV(dvdata, alpha = 0.001, quiet = TRUE)

Error message:

Error in if (nrow(ctable) == 1 || ctable$P[1] > alpha) { : 
  missing value where TRUE/FALSE needed

We are willing to share the dvdata object if you provide your email.
Thanks,

"running command 'java -mx512m -jar...had status 1"

From a user:

I'm not sure why I get the following error when I run the line:

grasslandDVs <- deriveVars(grasslandPO, transformtype = c("L", "M", "D", "HF", "HR", "T", "B"))

Alpha: returning -Infinity for pi[f]=0.000000+-0.000000, q[f]=0.000091
Error: goodAlpha: returning -Infinity for pi[f]=0.000000+-0.000000, q[f]=0.000091
Error in read.table(file = file, header = header, sep = sep, quote = quote, :
no lines available in input
In addition: Warning message:
running command 'java -mx512m -jar "C:/Users/mcilwea/Documents/R/R-3.4.3/library/MIAmaxent/java/maxent.jar" removeduplicates=FALSE addsamplestobackground=FALSE autofeature=FALSE betamultiplier=0 quadratic=FALSE product=FALSE hinge=FALSE threshold=FALSE outputformat=raw writebackgroundpredictions=TRUE outputgrids=FALSE pictures=FALSE extrapolate=FALSE writemess=FALSE plots=FALSE doclamp=FALSE writeclampgrid=FALSE autorun=TRUE threads=2 visible=FALSE warnings=FALSE maximumbackground=17480 samplesfile="R:/Koala/R/MAXENT/Test/deriveVars/pca1/HR/pca1_HR1/samples.csv" environmentallayers="R:/Koala/R/MAXENT/Test/deriveVars/pca1/HR/pca1_HR1/environlayers.csv" outputdirectory="R:/Koala/R/MAXENT/Test/deriveVars/pca1/HR/pca1_HR1/"' had status 1

Copy paste not working using Robot Class: Ctrl+C; content is not saving into clipboard, but it used to work perfectly fine few days back

Issue: Using Robot class i have copied content during run time BCDE and trying to retrieve it from clipboard to print again in console or any other file. But it's fetching old value from the clip board?
Expected Output is: BCDE

import java.awt.AWTException;
import java.awt.HeadlessException;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.StringSelection;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.io.IOException;

import org.sikuli.basics.Settings;
import org.sikuli.script.FindFailed;
import org.sikuli.script.Key;
import org.sikuli.script.Pattern;
import org.sikuli.script.Screen;

public class Sikuli_Demo {

public static void main(String[] args) throws InterruptedException, FindFailed, AWTException, HeadlessException, UnsupportedFlavorException, IOException {

	Screen screen=new Screen();
	Thread.sleep(2000);
	Pattern clickOutlook=new Pattern("images\\1_ClickOutlook.png");

	Pattern clickNewMail=new Pattern("images\\3_NewMail.png");

	screen.click(clickOutlook);
	Thread.sleep(2000);
	screen.click(clickNewMail);
	Thread.sleep(2000);
	screen.type("ABCDE");
	screen.type(Key.LEFT+Key.LEFT+Key.LEFT+Key.LEFT);
	Thread.sleep(2000);

	Robot robot=new Robot();
	Thread.sleep(4000);
	
	robot.keyPress(KeyEvent.VK_SHIFT);
	robot.keyPress(KeyEvent.VK_RIGHT);
	robot.keyPress(KeyEvent.VK_SHIFT);
	robot.keyPress(KeyEvent.VK_RIGHT);
	robot.keyPress(KeyEvent.VK_SHIFT);
	robot.keyPress(KeyEvent.VK_RIGHT);
	robot.keyPress(KeyEvent.VK_SHIFT);
	robot.keyPress(KeyEvent.VK_RIGHT);

	Thread.sleep(2000);
	robot.keyRelease(KeyEvent.VK_RIGHT);
	robot.keyRelease(KeyEvent.VK_SHIFT);
	Thread.sleep(2000);
	System.out.println("Check1");
	robot.keyPress(KeyEvent.VK_CONTROL);
	robot.keyPress(KeyEvent.VK_C);
	Thread.sleep(2000);
	robot.keyRelease(KeyEvent.VK_CONTROL);
	robot.keyRelease(KeyEvent.VK_C);
	Thread.sleep(2000);
	robot.keyPress(KeyEvent.VK_RIGHT);
	robot.keyRelease(KeyEvent.VK_RIGHT);

	System.out.println("Check2");

	String str=(String)Toolkit.getDefaultToolkit().getSystemClipboard().getData(DataFlavor.stringFlavor);
	Thread.sleep(2000);

	System.out.println("Copied content is :"+str);
	screen.type(str);
}

}

Console:
Jan 11, 2018 5:41:31 PM java.util.prefs.WindowsPreferences
WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
[log] CLICK on L(540,1401)@s(0)[0,0 2560x1440]
[log] CLICK on L(58,214)@s(0)[0,0 2560x1440]
[log] TYPE "ABCDE"
[log] TYPE "#LEFT.#LEFT.#LEFT.#LEFT."
Check1
Check2
Copied content is :[email protected]
[log] TYPE "[email protected] "

Model predictions Inf, under particular data structures

Problem: with certain real world data (in a typical model selection workflow) model predictions end up Inf.
This seems to be the result of high collinearity, unstable parameter estimates.

Demonstration:

library(MIAmaxent)
packageVersion("MIAmaxent")
#> [1] '1.2.0.9000'

reprexdata <- structure(list(RV = c(1, 1, 1, NA, NA, NA, NA, NA, NA, NA), 
                             EV_L = c(0.98, 0.83, 0.94, 0.72, 0.89, 0.7, 0.67, 0.64, 0.39, 0.83), 
                             EV_D2 = c(0, 0.03, 0, 0.07, 0.01, 0.09, 0.1, 0.13, 0.37, 0.03), 
                             EV_M = c(0.96, 0.74, 0.9, 0.6, 0.83, 0.58, 0.54, 0.5, 0.26, 0.74)), 
                        class = "data.frame", row.names = c("1", "2", "3", "4", "5", "6", "7", "8", "9", "10"))

plot(reprexdata[,-1])

cor(reprexdata[,-1], reprexdata[,-1])
#>             EV_L      EV_D2       EV_M
#> EV_L   1.0000000 -0.9451377  0.9946556
#> EV_D2 -0.9451377  1.0000000 -0.9069347
#> EV_M   0.9946556 -0.9069347  1.0000000

iwlr <- MIAmaxent:::.runIWLR(formula("RV ~ EV_L + EV_D2 + EV_M"), reprexdata)
coef(iwlr)
#> (Intercept)        EV_L       EV_D2        EV_M 
#>  -2531.4654   7431.9418    802.6664  -4954.6279
iwlr$entropy
#> [1] 0
iwlr$alpha
#> [1] -Inf

The instability is contingent on the data in unexpected ways. Leave only the highly correlated variables and the problem disappears:

iwlr <- MIAmaxent:::.runIWLR(formula("RV ~ EV_L + EV_M"), reprexdata)
coef(iwlr)
#> (Intercept)        EV_L        EV_M 
#>   -262.0798    782.4296   -530.8548
iwlr$entropy
#> [1] 1.41998
iwlr$alpha
#> [1] -258.5736

This problem can appear in a real world MIAmaxent workflow, as highly correlated derived variables are selected together given a sufficient number of background points:

set.seed(42)
longerdata <- dplyr::slice_sample(reprexdata, n = 1e4, replace = TRUE)
selection <- selectDVforEV(list(RV = longerdata$RV, EV = longerdata[,-1]))
#> Forward selection of DVs for 1 EVs
#>   |                                                                              |                                                                      |   0%  |                                                                              |======================================================================| 100%
selection$selection
#> $EV
#>   round           variables m   Dsq    Chisq df        P
#> 1     1               EV_D2 1 0.099 4033.427  1 0.00e+00
#> 2     1                EV_L 1 0.097 3945.131  1 0.00e+00
#> 3     1                EV_M 1 0.094 3834.647  1 0.00e+00
#> 4     2        EV_D2 + EV_L 2 0.100   26.073  1 3.29e-07
#> 5     2        EV_D2 + EV_M 2 0.099    9.107  1 2.55e-03
#> 6     3 EV_D2 + EV_L + EV_M 3 0.140 1660.015  1 0.00e+00

I have only encountered the issue when both 'L' and 'M'-type transformations are used. The derived variables that result from these may often be highly correlated. So I expect that picking only one of these transformation types in deriveVars() will resolve the problem in most real world cases.

Created on 2022-11-22 by the reprex package (v2.0.1)

Error: "'java' is not recognized as an internal or external command, operable program or batch file."

From Maxent readme:

The problem is either that you don't have Java installed (you need to
install from java.sun.com as above), or Java is not mentioned in your
"path" variable. To fix the latter problem:

  1. From the desktop, right click My Computer and click properties.

  2. In the System Properties window, click on the Advanced tab.

  3. In the Advanced section, click the Environment Variables button.

  4. Finally, in the Environment Variables window, highlight the path
    variable in the Systems Variable section and click edit. Add the
    directory where the java executable is.

For example, if you downloaded Java 1.6.0_13, it was probably
installed in C:\Program Files\Java\jdk1.6.0_13, in
which case you will add ";C:\Program Files\Java\jdk1.6.0_13\bin" to
the end of the path variable, like in the following example:

  C:\Program Files;C:\Winnt;C:\Winnt\System32;C:\Program Files\Java\jdk1.6.0_13\bin

visualization for interaction terms

Feature request: a convenient way to visualize the effect of pairwise interaction terms, similar to the plotResp() functions. Either with 3D plot or with facetting.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.