Giter Site home page Giter Site logo

Comments (1)

rvosa avatar rvosa commented on June 1, 2024

De gehanteerde method is nu hier geimplementeerd:

removeCollinearity_adjusted <- function(raster.stack, multicollinearity.cutoff = .7,
select.variables = FALSE, sample.points = FALSE,
nb.points = 10000, plot = FALSE)
{
env.df <- getValues(raster.stack)
env.df <- env.df[-unique(which(is.na(env.df), arr.ind = T)[, 1]), ] # Removing NAs
# Correlation matrix creation
cor.matrix <- matrix(data = 0,
nrow = nlayers(raster.stack),
ncol = nlayers(raster.stack),
dimnames = list(names(raster.stack), names(raster.stack)))
# Correlation based on Pearson
cor.matrix<-1 - abs(stats::cor(env.df, method = "pearson" ))
cor.matrix[is.na(cor.matrix)]<- 0
# Transforming the correlation matrix into an ascendent hierarchical classification
dist.matrix <- stats::as.dist(cor.matrix)
ahc <- stats::hclust(dist.matrix, method = "complete")
groups <- stats::cutree(ahc, h = 1 - multicollinearity.cutoff)
if(length(groups) == max(groups))
{
message(paste(" - No multicollinearity detected in your data at threshold ", multicollinearity.cutoff, "\n", sep = ""))
mc <- FALSE
} else
{ mc <- TRUE }
# Random selection of variables
if(select.variables)
{
sel.vars <- NULL
for (i in 1:max(groups))
{
sel.vars <- c(sel.vars, sample(names(groups[groups == i]), 1))
}
} else
{
if(mc)
{
sel.vars <- list()
for (i in groups)
{
sel.vars[[i]] <- names(groups)[groups == i]
}
} else
{
sel.vars <- names(raster.stack)
}
}
return(sel.vars)
}

from trait-geo-diverse-ungulates.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.