OWA Calculator

In preparation for developing the Bonferroni calculation and fitting software, I thought I’d just write a quick OWA calculator.  Although the concept of the OWA calculation is quite simple, it is one of the most powerful and widely used aggregation functions.  It was formally defined by Yager in 1988.

The key implementation is the sorting of the x values, other than this, it can be calculated in the same manner as the WAM.  For high dimensional data, the sort algorithm can be quite an impediment to efficient application.  My colleague, Gleb Beliakov has tackled this problem here and, of course, also has already developed tools for OWA calculation and fitting in other languages.

Standard Function Specification

required input: x-vector, weights (optional), n

OWA <- function(x,w=array(1/n,n) {
sum(sort(x,decreasing= TRUE)*(w))
}

Calculation of an input data set

required input: x-values, w (optional)

# Define the function
OWA <- function(x,w=array(1/n,n) {
sum(sort(x,decreasing= TRUE)*(w))
}
# read weights and data
w <- array(0,n)
x.data <-read.table("documents/R/inputs6.txt",header=TRUE)
y.values <- array(0,nrow(x))
# sort data
for(i in 1:nrow(x)) {
x.data[i,]<-sort(x.data[i,],decreasing = TRUE)
}
# calc values
for(i in 1:nrow(x.data)) {
y[i] <- OWA(x.data[i,],w)
}
# merge into single file if you like and export to file
write.table(cbind(x.data,y),"documents/R/OWAout1.txt")
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s