Skip to content

Bug fix to hinge() and check of data added#29

Open
oharar wants to merge 5 commits intomrmaxent:masterfrom
oharar:master
Open

Bug fix to hinge() and check of data added#29
oharar wants to merge 5 commits intomrmaxent:masterfrom
oharar:master

Conversation

@oharar
Copy link

@oharar oharar commented Feb 3, 2026

I've made the following changes:

  1. hinge() now doesn't return columns with the same features.
  2. maxent() checks to see if any column in data only has a single unique value, and stops if it does (requested here: maxnet() sometimes fails with hinge features #26).
  3. Minor update to documentation to stop R CMD check complaining

This code shows the changes:

library(disdat)
library(maxnet)
sp <- "nsw38"

bgEnv <- disBg("NSW")
EnvNames <- names(bgEnv)[!(names(bgEnv)%in%c("siteid", "spid", "x", "y", "occ", "group"))]
Pres <- disPo("NSW")[disPo("NSW")$spid==sp,c("occ", EnvNames)]

dat <- rbind(Pres, bgEnv[,c("occ", EnvNames)])
dat$vegsys <- factor(dat$vegsys)

This now works. Before it was causing a problem in predict.maxnet()

MaxNet.mod <- maxnet(p=dat$occ, data=dat[,EnvNames],
f=maxnet.formula(p=dat$occ, data=dat[,EnvNames],
classes="h"))

dat$One <- rep(1, nrow(dat))
EnvNames1 <- c(EnvNames, "One")

This now gives an informative error

MaxNet.mod <- maxnet(p=dat$occ, data=dat[,EnvNames1],
f=maxnet.formula(p=dat$occ, data=dat[,EnvNames1],
classes="h"))

@oharar
Copy link
Author

oharar commented Feb 10, 2026

Added option to change weights on absences: these can be a scalar or the same length as p. This means we can use MaxNet on presence/absence data, and also test how close 100 is to infinity (or even use area based weights)

…cumentation for ...

Put .Rhistory in .gitignore
@oharar
Copy link
Author

oharar commented Feb 17, 2026

Now if any element of the entropy has p=0, so p log p = -Inf, removes that element (=sets to 0) with a warning. Resolves #28

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant