allProb: Outlier probabilities for all observations

Description Usage Arguments Value See Also Examples

View source: R/allProb.R

Description

Outlier probabilities for all of the data, obtained by assigning to each observation the probabilty of the its associated leader partition.

Usage

1
allProb( leaderInstance, partprob)

Arguments

leaderInstance

A single component from a call to leader, giving leader algorithm results for one value of the partitioning radius.

partprob

A vector of probabilities for each partition in leaderInstance.

Value

A vector of probabilities for each observation in the data underlying leaderInstance. Each observation inherits the probability of its associated partition.

See Also

leader, partProb

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 set.seed(0)

 lead <- leader(faithful)
 nlead <- length(lead[[1]]$partitions)

# repeat multiple times to account for randomness
 ntimes <- 100
 probs <- matrix( NA, nlead, ntimes)
 for (i in 1:ntimes) {
    probs[,i] <- partProb( simData(lead[[1]]), method = "distance")
 }

# median probability for each partition
 partprobs <- apply( probs, 1, median)

 quantile(partprobs)

# plot leaders with outlier probability > .95
 plot( faithful[,1], faithful[,2], pch = 16, cex = .5,
       main = "red : instances with outlier probability > .95")
 allprobs <- allProb( lead[[1]], partprobs)
 out <- allprobs > .95
 points( faithful[out,1], faithful[out,2], pch = 8, cex = 1, col = "red")

probout documentation built on Feb. 11, 2022, 5:10 p.m.