Parse Maxent lambdas information
parse_lambdas.Rd
NOTICE: This function was borrowed from the rmaxent package written by John Baumgartner (https://github.com/johnbaums/rmaxent/). (dependencies on Github-only packages are not allowed for CRAN).
Parse Maxent .lambdas files to extract the types, weights, minima and maxima of features, as well as the fitted model's entropy and other values required for predicting to new data.
Value
A list (of class `lambdas`) with five elements: * `lambdas`: a `data.frame` describing the features used in a Maxent model, including their weights (lambdas), maxima, minima, and type; * `linearPredictorNormalizer`: a constant that ensures the linear predictor (the sum of clamped features multiplied by their respective feature weights) is always negative (for numerical stability); * `densityNormalizer`: a scaling constant that ensures Maxent's raw output sums to 1 over background points; * `numBackgroundPoints`: the number of background points used in model training; and * `entropy`: the entropy of the fitted model.
References
* Wilson, P. W. (2009) [_Guidelines for computing MaxEnt model output values from a lambdas file_](http://gis.humboldt.edu/OLM/Courses/GSP_570/Learning%20Modules/10%20BlueSpray_Maxent_Uncertinaty/MaxEnt%20lambda%20files.pdf). * _Maxent software for species habitat modeling, version 3.3.3k_ help file (software freely available [here](https://www.cs.princeton.edu/~schapire/maxent/)).
Examples
# Below we use the predicts::MaxEnt example to fit a model:
library(predicts)
#> Loading required package: terra
#> terra 1.8.5
occs <- read.csv(file.path(system.file(package="predicts"),
"/ex/bradypus.csv"))[,2:3]
predictors <- rast(file.path(system.file(package='predicts'), '/ex/bio.tif'))
me <- MaxEnt(predictors, occs)
#> Loading required namespace: rJava
# ... and then parse the lambdas information:
lam <- parse_lambdas(me)
lam
#> $lambdas
#> feature var lambda min max type
#> 1 bio1 bio1 1.910476e+00 -23.0 289.0 linear
#> 2 bio12 bio12 7.093663e-01 0.0 7682.0 linear
#> 3 bio16 bio16 0.000000e+00 0.0 2458.0 linear
#> 4 bio17 bio17 -3.851500e+00 0.0 1496.0 linear
#> 5 bio5 bio5 0.000000e+00 61.0 422.0 linear
#> 6 bio6 bio6 0.000000e+00 -212.0 242.0 linear
#> 7 bio7 bio7 -1.725647e+01 60.0 461.0 linear
#> 8 bio8 bio8 3.870400e-01 -66.0 323.0 linear
#> 9 bio9 bio9 8.186268e-01 -23.0 289.0 linear
#> 10 bio12^2 bio12 5.919734e-02 0.0 59013124.0 quadratic
#> 11 bio16^2 bio16 3.039654e-01 0.0 6041764.0 quadratic
#> 12 bio6^2 bio6 -2.442335e+00 0.0 58564.0 quadratic
#> 13 bio1*bio12 bio1,bio12 2.840565e-01 -14571.0 2028048.0 product
#> 14 bio12*bio16 bio12,bio16 3.220484e-01 0.0 18636532.0 product
#> 15 bio12*bio5 bio12,bio5 6.430193e-04 0.0 2396784.0 product
#> 16 bio12*bio6 bio12,bio6 1.644931e-01 -156047.0 1674676.0 product
#> 17 bio12*bio7 bio12,bio7 8.865686e-01 0.0 737464.0 product
#> 18 bio12*bio8 bio12,bio8 3.011205e+00 -27324.0 2020366.0 product
#> 19 bio12*bio9 bio12,bio9 3.059475e-01 -14571.0 2028048.0 product
#> 20 bio16*bio8 bio16,bio8 6.038987e-01 -13332.0 638038.0 product
#> 21 bio5*bio7 bio5,bio7 -4.103028e-01 8235.0 162812.0 product
#> 22 `bio17 bio17 -1.970418e-01 0.0 89.5 reverse_hinge
#> 23 `bio17 bio17 -5.218809e-02 0.0 62.5 reverse_hinge
#> 24 'bio5 bio5 -1.635089e+00 287.5 422.0 forward_hinge
#> 25 `bio17 bio17 -1.260720e+00 0.0 52.5 reverse_hinge
#> 26 'bio5 bio5 -8.593232e-01 283.5 422.0 forward_hinge
#> 27 `bio1 bio1 -1.528864e+00 -23.0 180.5 reverse_hinge
#> 28 'bio6 bio6 -1.075395e+00 203.5 242.0 forward_hinge
#> 29 `bio16 bio16 -9.611040e-01 0.0 531.5 reverse_hinge
#> 30 'bio1 bio1 1.826304e+00 265.5 289.0 forward_hinge
#> 31 'bio6 bio6 -2.437269e-01 204.5 242.0 forward_hinge
#> 32 'bio16 bio16 3.590613e-01 2394.0 2458.0 forward_hinge
#> 33 'bio17 bio17 1.020436e-01 1229.5 1496.0 forward_hinge
#> 34 'bio17 bio17 1.335425e+00 1202.5 1496.0 forward_hinge
#> 35 'bio8 bio8 1.082490e+00 256.5 323.0 forward_hinge
#> 36 'bio6 bio6 -2.318697e-01 197.5 242.0 forward_hinge
#> 37 'bio1 bio1 4.046470e-01 258.5 289.0 forward_hinge
#> 38 'bio5 bio5 -4.581517e-01 255.5 422.0 forward_hinge
#> 39 'bio5 bio5 -2.546101e-01 258.5 422.0 forward_hinge
#> 40 `bio7 bio7 -9.515878e-01 60.0 111.5 reverse_hinge
#> 41 'bio9 bio9 5.708096e-01 265.5 289.0 forward_hinge
#> 42 'bio9 bio9 7.703929e-02 258.5 289.0 forward_hinge
#> 43 `bio17 bio17 -3.679882e-02 0.0 53.5 reverse_hinge
#>
#> $linearPredictorNormalizer
#> [1] 2.283563
#>
#> $densityNormalizer
#> [1] 117.8422
#>
#> $numBackgroundPoints
#> [1] 9775
#>
#> $entropy
#> [1] 7.9527
#>
#> attr(,"class")
#> [1] "lambdas"
str(lam, 1)
#> List of 5
#> $ lambdas :'data.frame': 43 obs. of 6 variables:
#> $ linearPredictorNormalizer: num 2.28
#> $ densityNormalizer : num 118
#> $ numBackgroundPoints : num 9775
#> $ entropy : num 7.95
#> - attr(*, "class")= chr "lambdas"