predicor: Predictor correllation throught scales

View source: R/predicor.R

predicorR Documentation

Predictor correllation throught scales

Description

This function analyze the correlation of a predictor across different scales.

Usage

predicor(x, ...)

Arguments

x

a dataframe generated with the functions calc_lsm and tranformed with lsm2multifit() function

...

other parameters to be passed for the stats::cor function

Value

A data frame containing the correlation values between scales

Examples

## Not run: 
#Comparing correlation behaviour in nested and decouple multiscales:

b <- c(500, 1000, 1500, 2000, 2500, 3000)

nest.ls <- nestedscales(r, p, b)
dec.ls  <- decouple(r, p, b)

#extracting percentage for each class and scale
nest.lsm <- calc_lsm(nest.ls, metric = "pland")
dec.lsm  <- calc_lsm(dec.ls,  metric = "pland")

#Comparing correlation for the class = 3
nestcor <- predicor(lsm2multifit(nest.lsm, level="class", class=3,
 metrics="pland"))
deccor  <- predicor(lsm2multifit(dec.lsm, level="class", class=3,
 metrics="pland"))

corcomp    <- data.frame(
  strategy    = factor(c(rep("nested", nrow(nestcor)),
                  rep("decoupled", nrow(deccor))),
                  levels = c("nested","decoupled")),
  scales      = factor(c(nestcor$scales, deccor$scales),
                  levels=nestcor$scales),
  correlation = c(nestcor$correlation, deccor$correlation)
)
library(ggplot2)
ggplot(corcomp, aes(x=scales, y=correlation, fill=strategy))+
  geom_bar(stat="identity", position="dodge")+
  theme(axis.text = element_text(angle=90))


## End(Not run)

wilsonfrantine/landscapeDecoupler documentation built on Oct. 31, 2024, 3:45 a.m.