Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

regularization multipler behavior for hinges unexpected #11

Open
jamiemkass opened this issue Jul 1, 2019 · 0 comments
Open

regularization multipler behavior for hinges unexpected #11

jamiemkass opened this issue Jul 1, 2019 · 0 comments

Comments

@jamiemkass
Copy link

jamiemkass commented Jul 1, 2019

I found that when hinge features only are used, I do not get the expected results when I increase the regularization multiplier -- sometimes the number of non-zero betas goes down, but sometimes it goes up. Please run this example to see this behavior. Why would this be? Shouldn't the number of non-zero betas for a model with rm = n always be equal to or lower than a model with rm = n - 1?

set.seed(48)
bv <- spocc::occ('Bradypus variegatus', 'gbif', limit=300, has_coords=TRUE)
occs <- as.data.frame(bv$gbif$data$Bradypus_variegatus[,2:3])
occs <- occs[!duplicated(occs),]
envs <- raster::stack(list.files(path=paste(system.file(package='dismo'), '/ex', sep=''), pattern='grd', full.names=TRUE))
bg <- dismo::randomPoints(envs, 1000)
occs.vals <- raster::extract(envs, occs)
bg.vals <- raster::extract(envs, bg)
bg.vals.naRows <- which(rowSums(is.na(bg.vals)) > 0)
bg.vals <- bg.vals[-bg.vals.naRows,]
d <- as.data.frame(rbind(occs.vals, bg.vals))
d$biome <- as.factor(d$biome)
p <- c(rep(1, nrow(occs.vals)), rep(0, nrow(bg.vals)))
f <- maxnet::maxnet.formula(p, d, classes = "h")

m1 <- maxnet::maxnet(p, d, f, regmult = 1)
m2 <- maxnet::maxnet(p, d, f, regmult = 2)
m3 <- maxnet::maxnet(p, d, f, regmult = 3)
m4 <- maxnet::maxnet(p, d, f, regmult = 4)

length(m1$betas)
length(m2$betas)
length(m3$betas)
length(m4$betas)
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

No branches or pull requests

1 participant