fitKNN: Fit using K-nearest neighbour

Description Usage Arguments Details Value Author(s)

View source: R/fitKNN.R

Description

Model adegency matrix using K-nearest neighbour approach

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
fitKNN(
  data,
  distFrom = "jaccard",
  distTo = "jaccard",
  distTraitFrom = NULL,
  distTraitTo = NULL,
  weight = 0.5,
  nNeig,
  phylo = FALSE
)

Arguments

data

An object of the class alienData, see alienData.

distFrom

Character string defining which distance (or dissimilarity) to apply on the "From" species. Check vegdist for the distances to choose from. Default is "jaccard".

distTo

Character string defining which distance (or dissimilarity) to apply on the "To" species. Check vegdist for the distances to choose from. Default is "jaccard".

distTraitFrom

Character string defining which distance (or dissimilarity) to apply on the traits of the "From" species. Check vegdist for the distances to choose from. If the value is left to NULL, traitDistFrom (or phyloDistFrom) in the data (alienData) is used directly. Default is NULL.

distTraitTo

Character string defining which distance (or dissimilarity) to apply on the "To" species. Check vegdist for the distances to choose from. If the value is left to NULL, traitDistTo (or phyloDistTo) in the data (alienData) is used directly. Default is NULL.

weight

Numeric. Defines the contribution of the traits (or phylogeny) in the analysis. Must be between 0 and 1. Default is 0.5.

nNeig

Integer defining how many neighbours to consider.

phylo

Logical. Whether phylogenetic information should be used instead of traits to measure neighbourhood. Default is FALSE.

Details

This function should only be used for bipartite adjacency matrices.

The function is designed in such a way that if the argument distTraitFrom is defined it will build a distance matrix using traitFrom in the alienData object even if distTraitFrom is available in alienData object. The same is true for the argument distTraitTo.

The argument weight defines the important of traits (or phylogeny) in the analysis. If a weight of 0 is given, the traits (or phylogeny) are assumed to have no importance. Conversely, if weight is 1 the traits (or phylogeny) are given their full importance in the analysis.

If phylo is TRUE, the cophenetic distance is used to calculate the distance between pairs of species.

When ranking the species to find the nNeig nearest neighbour, in case of ties the argument tie.method in the rank function is set to "first". Also, when ranking the species, it is assumed that the species is not a neighbour of itself.

NAs were removed in the calculation of the distances whenever they were present, but also in the calculation of the interaction probability. For species where all distance values are NAs, the returned interactions probability will be 0.

Value

An object with a class alienFit and a class fitKNN.

Author(s)

F. Guillaume Blanchet and Dominique Gravel


TheoreticalEcosystemEcology/alienR documentation built on Dec. 25, 2021, 5:59 p.m.