Skip to content

Commit

Permalink
version 0.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmaxent authored and cran-robot committed Feb 3, 2017
1 parent 4c96b05 commit a04c442
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
9 changes: 5 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
Package: maxnet
Type: Package
Title: Fitting 'Maxent' Species Distribution Models with 'glmnet'
Version: 0.1.0
Date: 2016-11-12
Version: 0.1.1
Date: 2017-02-03
Author: Steven Phillips
Maintainer: Steven Phillips <mrmaxent@gmail.com>
Imports: glmnet
Description: Procedures to fit species distributions models from occurrence records and environmental variables, using 'glmnet' for model fitting. Model structure is the same as for the 'Maxent' Java package, version 3.4.0, with the same feature types and regularization options. See the 'Maxent' website <http://biodiversityinformatics.amnh.org/open_source/maxent> for more details.
License: MIT + file LICENSE
URL: https://github.com/mrmaxent/maxnet
RoxygenNote: 5.0.1
NeedsCompilation: no
Packaged: 2016-11-16 02:23:35 UTC; phillips
Packaged: 2017-02-03 15:51:37 UTC; phillips
Repository: CRAN
Date/Publication: 2016-11-16 08:16:39
Date/Publication: 2017-02-03 19:18:39
4 changes: 2 additions & 2 deletions MD5
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
0d2ea99c3ce6c0cfeaee90524801d6c2 *DESCRIPTION
2b837427b32ae30ad903f6423588e7f2 *DESCRIPTION
647c3da237fb33ee8bfa84337d7250e9 *LICENSE
3e3a91a387434cae65abcff42cba04ac *NAMESPACE
dc4580faf21895654550fce43c932296 *NEWS.md
Expand All @@ -7,7 +7,7 @@ e68f571f67610cd3314e700a32d8afac *R/categoricalval.R
bef5dc4e35646907f004387a26f4a737 *R/data.R
910564f66b072a8e09dbb0597c398055 *R/hinge.R
2902c6ec58f78af1fd12ec83e6db080c *R/hingeval.R
7fbf6fabe232baa1923bead33167694f *R/maxnet.R
dc5666869a5fac5eca3bbc4cbb67e6fc *R/maxnet.R
6eb6cbbb5689130f5e94010fa026cdd1 *R/maxnet.default.regularization.R
05aa6f3586d566ccc842247e2d67513d *R/maxnet.formula.R
3dca2d0753cf1b9e0486f7e8c17f1659 *R/plot.maxnet.R
Expand Down
15 changes: 8 additions & 7 deletions R/maxnet.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,25 @@ function(p, data, f=maxnet.formula(p, data), regmult=1.0,
reg <- regfun(p,mm) * regmult
weights <- p+(1-p)*100
glmnet::glmnet.control(pmin=1.0e-8, fdev=0)
model <- glmnet::glmnet(x=mm, y=as.factor(p), family="binomial", standardize=F, penalty.factor=reg, lambda=10^(seq(4,0,length.out=100))*sum(reg)/length(reg)*sum(p)/sum(weights), weights=weights, ...)
model <- glmnet::glmnet(x=mm, y=as.factor(p), family="binomial", standardize=F, penalty.factor=reg, lambda=10^(seq(4,0,length.out=200))*sum(reg)/length(reg)*sum(p)/sum(weights), weights=weights, ...)
class(model) <- c("maxnet", class(model))
bb <- model$beta[,100]
if (length(model$beta) < 200) stop("Error: glmnet failed to complete regularization path")
bb <- model$beta[,200]
model$betas <- bb[bb!=0]
model$alpha <- 0
rr <- predict.maxnet(model, data[p==0,], type="exponent", clamp=F)
rr <- predict.maxnet(model, data[p==0, , drop = FALSE], type="exponent", clamp=F)
raw <- rr / sum(rr)
model$entropy <- -sum(raw * log(raw))
model$alpha <- -log(sum(rr))
model$penalty.factor <- reg
model$featuremins <- apply(mm, 2, min)
model$featuremaxs <- apply(mm, 2, max)
vv <- (sapply(data, class)!="factor")
model$varmin <- apply(data[,vv], 2, min)
model$varmax <- apply(data[,vv], 2, max)
means <- apply(data[p==1,vv], 2, mean)
model$varmin <- apply(data[,vv, drop = FALSE], 2, min)
model$varmax <- apply(data[,vv, drop = FALSE], 2, max)
means <- apply(data[p==1,vv, drop = FALSE], 2, mean)
majorities <- sapply(names(data)[!vv],
function(n) which.max(table(data[p==1,n])))
function(n) which.max(table(data[p==1,n, drop = FALSE])))
names(majorities) <- names(data)[!vv]
model$samplemeans <- c(means, majorities)
model$levels <- lapply(data, levels)
Expand Down

0 comments on commit a04c442

Please sign in to comment.