BiRankFr: BiRank algorithm

View source: R/BiRankFr.R

BiRankFrR Documentation

BiRank algorithm

Description

BiRank algorithm to compute fraud scores.

Usage

BiRankFr(
  sNetwork,
  fraudMat,
  Today = Sys.Date(),
  decayR = 0,
  decayF = 0,
  alpha = 0.85,
  maxiter = 1000,
  Epsilon = 1e-14,
  PrintProgress = F,
  pInit = NULL,
  cInit = NULL,
  ConvCriterion = c("Sep", "Whole", "Order")
)

Arguments

sNetwork

Data frame containing the variables startNode, endNode and possibly Date.

fraudMat

Data frame containing the variables FraudInd (binary variable indicatinf fraudulent claimes) and possibly Date.

Today

Date of analysis (e.g. 1/1/2020), default is Sys.Date(). Supply either as object with class Date or as character string in the format %d/%m/%Y.

decayR

Parameter for exponential decay of recency of relation (in weeks).

decayF

Parameter for exponential decay of recency of fraud (in weeks).

alpha

Damping factor for propagation algorithm (return to start).

maxiter

Maximum number of iterations for propagation algorithm.

Epsilon

Positive convergence tolerance \epsilon.

PrintProgress

Logical, indicates whether progress of the algorithm has to be printed.

pInit

Initial values for the party score vector p.

cInit

Initial values for the fraud score vector c.

ConvCriterion

Which convergence criterion to use. "Sep" uses ||p - p_{old}||_{2} / ||p_{old}||_{2} < \epsilon and ||c - c_{old}||_{2} / ||c_{old}||_{2} < \epsilon. "Whole" uses ||x - x_{old}||_{2} / ||x_{old}||_{2} < \epsilon with x = c(c, p). "Order" uses the same convergence criterion as "Sep" and checks if the order of the elements of \bold{p} and \bold{c} has not changed since the previous iteration.

Value

A list with the following components:

ResultsClaims

A data frame containing the claim IDs, fraud scores, scaled and normalized fraud scores.

ResultsParties

A data frame containing the party IDs, party scores, scaled and normalized party scores.

AdjacencyMatrix

Adjancency/weight matrix indicating which nodes are connected.

iter

Number of iterations that the algorithm needed to converge.

Converged

Logical, indicating whether the algorithm converged.

Examples

library(BiRankFraud)
NetwLabel = data.frame(
startNode = c('P2', 'P3', 'P3', 'C1', 'C1', 'C5', 'P1', 'P4', 'C2', 'C2'),
endNode = c('C3', 'C3', 'C4', 'P2', 'P3', 'P3', 'C1', 'C5', 'P1', 'P4'),
stringsAsFactors = FALSE
)
NetwLabel[grepl("C", NetwLabel$startNode), 1:2] = NetwLabel[grepl("C", NetwLabel$startNode), 2:1]
NetwLabel = NetwLabel[order(NetwLabel$startNode), ]
NetwLabel$startNode = as.numeric(gsub("P", "", NetwLabel$startNode))
NetwLabel$endNode   = as.numeric(gsub("C", "", NetwLabel$endNode))
NetwLabel

c0      = c(rep(0, 3), 1, 0)
Results = BiRankFr(NetwLabel, data.frame(FraudInd = c0))
Results

BavoDC/BiRankFraud documentation built on Aug. 30, 2023, 5:13 a.m.