CorIndex.xPerm: Permutates and calculates for each permutation both the non...

Description Usage Arguments Value Author(s) See Also Examples

View source: R/CorrelationIndex.R

Description

This function purmutaes and calculates the non and group-equalised versions of the Phi coefficient of correlation Tichy and Chytry (2006), De Cáceres and Legendre (2009). It is useful as it gives the distribution of phi values if the species are distributed randomly across the locations, the phi value for the actual data is compared to this distribution to calculate the p-value. The distribution is a useful output to visualise the distribution.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
CorIndex.xPerm(
  InDataframe,
  FieldToPerm,
  weighted,
  groupsField,
  targetGroup,
  x = 1000,
  SquareID = NULL,
  toroidal = FALSE
)

Arguments

InDataframe

dataframe - containing the data on species presence absence, habitat and weighting. It also optionally could contain location ID's.

FieldToPerm

string - the name of the binary field within InDataframe that contains binary presence absence for a species at the location.

weighted

string - name of habitat weighting field. For example, proportion of habitat, but any weighting with all habitats at a location adding to 1.

groupsField

string - ID of habitats or groups of interest.

x

Integer - optional - the number of permutation, set as 1000 by default.

SquareID

string - optional if non-weighted, but MUST be used if a weighting is used. ID of each location. Useful later for permutating the locations to calculate p-values.

toroidal

Boolean - If you suspect that your data is spatially auto-correlated you should use a toroidal permutation.

targetgroup

Integer - ID of the habitat of interest.

Value

Two data frames, one for the group-equalised $'GroupEqualPermList' and one for the non group-equalised $NonGroupEqualPermList. It also returns the number of permutations $Permutations.

Author(s)

Jordan Chetcuti

See Also

PhiCor

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
    #Builing on the examples from \link[PhiCor]{CorIndex.nonEqual}
    #Using the included dataframe Species1
    Inputs_species1 = CorIndex(InDataframe = Species1, speciesbinary = 'Species1', weighted = 'Proportion', group = 'HabId', 'LocationID')
    Inputs_species1$nkoverNk
    #Using CorIndex.TargetVar, the input is the output of CorIndex. In this case we are interested in
    #habitat 1 (using the ID for the habitat)
    Inputs_species1_hab1 = CorIndex.TargetVar(Inputs_species1, 1)

    species1_hab1_Phi = CorIndex.nonEqual(Inputs_species1_hab1)

    #histogram showing the output of CorIndex.xPerm for habitat 1 in comparison to the phi value from actual data.
    hist(Hab1_PermutatedPhi$NonGroupEqualPermList, main = "Non group-equalised distribution", xlab = "Phi values", breaks = 100)
    abline(v=species1_hab1_Phi, col="red")
    text((species1_hab1_Phi + 0.006), 15, "Calulated phi value", col = "red", srt=90)

Zabados/PhiCor documentation built on Oct. 9, 2021, 1:24 a.m.