-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:Ludwigm6/CAST
- Loading branch information
Showing
25 changed files
with
1,035 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
Package: CAST | ||
Type: Package | ||
Title: 'caret' Applications for Spatial-Temporal Models | ||
Version: 0.9.1 | ||
Version: 0.9.2 | ||
Authors@R: c(person("Hanna", "Meyer", email = "[email protected]", role = c("cre", "aut")), | ||
person("Carles", "Milà", role = c("aut")), | ||
person("Marvin", "Ludwig", role = c("aut")), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#' Normalize DI values | ||
#' @description | ||
#' The DI is normalized by the DI threshold to allow for a more straightforwrd interpretation. | ||
#' A value in the resulting DI larger 1 means that the data are more dissimilar than what has been observed during cross-validation. | ||
#' The returned threshold is adjusted accordingly and is, as a consequence, 1. | ||
#' @param AOA An AOA object | ||
#' @return An object of class \code{aoa} | ||
#' @seealso \code{\link{aoa}} | ||
#' @examples | ||
#' \dontrun{ | ||
#' library(sf) | ||
#' library(terra) | ||
#' library(caret) | ||
#' | ||
#' # prepare sample data: | ||
#' dat <- readRDS(system.file("extdata","Cookfarm.RDS",package="CAST")) | ||
#' dat <- aggregate(dat[,c("VW","Easting","Northing")],by=list(as.character(dat$SOURCEID)),mean) | ||
#' pts <- st_as_sf(dat,coords=c("Easting","Northing")) | ||
#' pts$ID <- 1:nrow(pts) | ||
#' set.seed(100) | ||
#' pts <- pts[1:30,] | ||
#' studyArea <- rast(system.file("extdata","predictors_2012-03-25.tif",package="CAST"))[[1:8]] | ||
#' trainDat <- extract(studyArea,pts,na.rm=FALSE) | ||
#' trainDat <- merge(trainDat,pts,by.x="ID",by.y="ID") | ||
#' | ||
#' # train a model: | ||
#' set.seed(100) | ||
#' variables <- c("DEM","NDRE.Sd","TWI") | ||
#' model <- train(trainDat[,which(names(trainDat)%in%variables)], | ||
#' trainDat$VW, method="rf", importance=TRUE, tuneLength=1, | ||
#' trControl=trainControl(method="cv",number=5,savePredictions=T)) | ||
#' | ||
#' #...then calculate the AOA of the trained model for the study area: | ||
#' AOA <- aoa(studyArea, model) | ||
#' plot(AOA) | ||
#' plot(AOA$DI) | ||
#' | ||
#' #... then normalize the DI | ||
#' DI_norm <- normalize_DI(AOA) | ||
#' plot(DI_norm) | ||
#' plot(DI_norm$DI) | ||
#' | ||
#' } | ||
#' @export normalize_DI | ||
#' @aliases normalize_DI | ||
|
||
|
||
normalize_DI <- function(AOA) { | ||
AOA$DI <- AOA$DI/AOA$parameters$threshold | ||
AOA$parameters$trainDI <- AOA$parameters$trainDI/AOA$parameters$threshold | ||
AOA$parameters$threshold <- AOA$parameters$threshold/AOA$parameters$threshold | ||
return(AOA) | ||
} | ||
|
Oops, something went wrong.