Skip to content

Commit 1068576

Browse files
version 1.1.0, send to travis-ci
1 parent 346fae1 commit 1068576

File tree

11 files changed

+90
-41
lines changed

11 files changed

+90
-41
lines changed

DESCRIPTION

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: MIAmaxent
22
Type: Package
33
Title: A Modular, Integrated Approach to Maximum Entropy Distribution Modeling
4-
Version: 1.0.0.9000
4+
Version: 1.1.0
55
Authors@R: c(
66
person("Julien", "Vollering", email = "[email protected]", role = c("aut", "cre")),
77
person("Sabrina", "Mazzoni", email = "[email protected]", role = "aut"),
@@ -21,6 +21,7 @@ LazyData: TRUE
2121
URL: https://github.com/julienvollering/MIAmaxent
2222
BugReports: https://github.com/julienvollering/MIAmaxent/issues
2323
RoxygenNote: 6.1.1
24+
Encoding: UTF-8
2425
Imports:
2526
dplyr (>= 0.4.3),
2627
e1071 (>= 1.6-7),

NEWS.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1-
# MIAmaxent 1.0.0.9000
1+
# MIAmaxent 1.1.0
2+
23
* Added ellipsis to plotFOP() for easier customization of graphic
4+
* Feature request: added 'densitythreshold' argument to plotFOP()
5+
* Predictions NA when a transformation returns NaN.
36
* Minor documentation edits to readData and testAUC
47
* Simplification of F-statistic calculation; may cause rounding differences with respect to previous versions.
58

69
# MIAmaxent 1.0.0
710

811
## Major changes
12+
913
* Model fitting implemented as infinitely-weighted logistic regression, so that all computation can be done natively in R (maxent.jar no longer required).
1014
* Implements choice of algorithm: "maxent" for maximum entropy or "LR" for standard logistic regression (binomial GLM).
1115
* No files written to system unless write = TRUE

R/MIAmaxent.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#' @references Halvorsen, R., Mazzoni, S., Bryn, A. & Bakkestuen, V. (2015)
3636
#' Opportunities for improved distribution modelling practice via a strict
3737
#' maximum likelihood interpretation of MaxEnt. Ecography, 38, 172-183.
38-
#' @references Halvorsen, R., Mazzoni, S., Dirksen, J.W., Naesset, E., Gobakken,
38+
#' @references Halvorsen, R., Mazzoni, S., Dirksen, J.W., Næsset, E., Gobakken,
3939
#' T. & Ohlson, M. (2016) How important are choice of model selection method
4040
#' and spatial autocorrelation of presence data for distribution modelling by
4141
#' MaxEnt? Ecological Modelling, 328, 108-118.

R/deriveVars.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
#'
1010
#' The linear transformation "L" is a simple rescaling to the range [0, 1].
1111
#'
12-
#' The monotonous transformation "M" performed is a zero-skew transformation
13-
#' (Oekland et al. 2001).
12+
#' The monotone transformation "M" performed is a zero-skew transformation
13+
#' (Økland et al. 2001).
1414
#'
1515
#' The deviation transformation "D" is performed around an optimum EV value that
1616
#' is found by looking at frequency of presence (see \code{\link{plotFOP}}).
@@ -49,7 +49,7 @@
4949
#' complete (no NAs). See \code{\link{readData}}.
5050
#' @param transformtype Specifies the types of transformations types to be
5151
#' performed. Default is the full set of the following transformation types: L
52-
#' (linear), M (monotonous), D (deviation), HF (forward hinge), HR (reverse
52+
#' (linear), M (monotone), D (deviation), HF (forward hinge), HR (reverse
5353
#' hinge), T (threshold), and B (binary).
5454
#' @param allsplines Logical. Keep all spline transformations created, rather
5555
#' than pre-selecting particular splines based on fraction of total variation
@@ -74,7 +74,7 @@
7474
#' @references Halvorsen, R., Mazzoni, S., Bryn, A., & Bakkestuen, V. (2015).
7575
#' Opportunities for improved distribution modelling practice via a strict
7676
#' maximum likelihood interpretation of MaxEnt. Ecography, 38(2), 172-183.
77-
#' @references Oekland, R.H., Oekland, T. & Rydgren, K. (2001).
77+
#' @references Økland, R.H., Økland, T. & Rydgren, K. (2001).
7878
#' Vegetation-environment relationships of boreal spruce swamp forests in
7979
#' Oestmarka Nature Reserve, SE Norway. Sommerfeltia, 29, 1-190.
8080
#'

R/plotFOP.R

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@
3838
#' @param ranging Logical. If \code{TRUE}, will range the EV scale to [0,1].
3939
#' This is equivalent to plotting FOP over the linear transformation produced
4040
#' by deriveVars. Irrelevant for categorical EVs.
41+
#' @param densitythreshold Numeric. Intervals containing fewer than this number
42+
#' of observations will be represented with an open symbol in the plot.
43+
#' Irrelevant for categorical EVs.
4144
#' @param ... Arguments to be passed to \code{plot} or \code{barplot} to control
4245
#' the appearance of the plot. For example: \itemize{ \item \code{lwd} for
4346
#' line width \item \code{cex.main} for size of plot title \item \code{space}
@@ -54,10 +57,12 @@
5457
#' observations in the level ("n"), and the mean RV value of the level
5558
#' ("levelRV") are used.}
5659
#'
57-
#' @references Stoea, B., Halvorsen, R., Mazzoni, S. & Gusarov, V. (2016)
60+
#' @references Støa, B., R. Halvorsen, S. Mazzoni, and V. I. Gusarov. (2018).
5861
#' Sampling bias in presence-only data used for species distribution
59-
#' modelling: assessment and effects on models. Sommerfeltia, submitted
60-
#' manuscript.
62+
#' modelling: theory and methods for detecting sample bias and its effects on
63+
#' models. Sommerfeltia 38:1–53.
64+
65+
6166
#'
6267
#' @examples
6368
#' FOPev11 <- plotFOP(toydata_sp1po, 2)
@@ -78,7 +83,8 @@
7883
#' @export
7984

8085

81-
plotFOP <- function(data, EV, span = 0.5, intervals = NULL, ranging = FALSE, ...) {
86+
plotFOP <- function(data, EV, span = 0.5, intervals = NULL, ranging = FALSE,
87+
densitythreshold = NULL, ...) {
8288

8389
if (EV==1) {
8490
stop("'EV' cannot be the first column of 'data', which must be the response variable")
@@ -109,8 +115,6 @@ plotFOP <- function(data, EV, span = 0.5, intervals = NULL, ranging = FALSE, ...
109115
FOP <- list(EVoptimum = evoptimum,
110116
FOPdata = FOPdf)
111117

112-
113-
114118
op <- graphics::par(mar=(c(5, 4, 4, 4) + 0.3))
115119
on.exit(graphics::par(op))
116120
dens <- stats::density(df[, 2])
@@ -120,8 +124,11 @@ plotFOP <- function(data, EV, span = 0.5, intervals = NULL, ranging = FALSE, ...
120124
graphics::axis(side=4, col="grey60", col.axis="grey60", las=1)
121125
graphics::mtext("Kernel estimated data density", side=4, line=3, col="grey60")
122126
graphics::par(new=TRUE)
127+
if (is.null(densitythreshold)) {densitythreshold <- 0}
128+
closedsymbols <- as.numeric(FOPdf$n >= densitythreshold)+1
123129
args1 <- list(bty="n", main = paste0("FOP plot: ", evname), xlab = evname,
124-
ylab = "Frequency of Observed Presence (FOP)", pch=20, las=1)
130+
ylab = "Frequency of Observed Presence (FOP)", las=1,
131+
pch=c(1,20)[closedsymbols])
125132
inargs <- list(...)
126133
args1[names(inargs)] <- inargs
127134
do.call(graphics::plot, c(list(x=FOPdf$intEV, y=FOPdf$intRV), args1))

R/projectModel.R

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,19 @@ projectModel <- function(model, transformations, data, clamping = FALSE,
126126
})
127127
newdata <- as.data.frame(do.call(cbind, dvdatani))
128128
names(newdata) <- dvnamesni
129-
130129
type <- if (class(model)[1] == "iwlr") {
131130
ifelse(raw == TRUE, "raw", "PRO")
132131
} else { "response" }
133-
preds <- stats::predict(model, newdata, type)
132+
133+
if (any(is.nan(unlist(newdata)))) {
134+
nans <- which(apply(newdata, 1, function(x) {any(is.nan(x))}))
135+
warning("Transformed 'data' has ", length(nans), " rows with NaN. Predictions for these will be NA.",
136+
call. = FALSE)
137+
preds <- rep(NA, nrow(newdata))
138+
preds[-nans] <- stats::predict(model, newdata[-nans,], type)
139+
} else {
140+
preds <- stats::predict(model, newdata, type)
141+
}
134142

135143
if (class(model)[1] == "iwlr" && rescale == TRUE) {
136144
if (raw == TRUE) { preds <- preds/sum(preds, na.rm = TRUE)

cran-comments.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
## Major release submission
1+
## Minor release submission
22

33
## Test environments
4-
* local Windows install, R 3.5.1
4+
* local OS X install, R 3.6.0
55
* ubuntu 14.04 (on travis-ci), R 3.5.1
6-
* os x 10.13, (on travis-ci), R 3.5.0
76
* win-builder, R devel
87

98
## R CMD check results

man/MIAmaxent.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/deriveVars.Rd

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/plotFOP.Rd

Lines changed: 9 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)