est.shcoa.prime {ShapDoE} | R Documentation |
Estimating the Shapley value based on component orthogonal array (COA) with a prime d
Description
Estimating the Shapley value based on component orthogonal array (COA) with a prime d
Usage
est.shcoa.prime(d, n, val, ...)
Arguments
d |
a prime, the number of players. |
n |
an integer, the sample size. |
val |
the predefined value function. |
... |
other parameters used in val(sets,...). |
Value
a vector including estimated Shapley values of all players based on COA.
Examples
temp_adjacent<-matrix(0,nrow=5,ncol=5)
temp_adjacent[1,c(2,3,5)]<-1;temp_adjacent[2,4]<-1;temp_adjacent[3,5]<-1;
temp_adjacent<-temp_adjacent+t(temp_adjacent)
temp_val<-function(sets,adjacent){
if(length(sets)==1) val<-0
else{
subadjacent<-adjacent[sets,sets]
nsets<-length(sets)
A<-diag(1,nsets); B<-matrix(0,nsets,nsets)
for(l in 1:(nsets-1)){
A<-A%*%subadjacent
B<-B+A
}
val<-ifelse(sum(B==0)>nsets,0,1)
}
return(val)
}
est.shcoa.prime(5,20,temp_val,temp_adjacent)
[Package ShapDoE version 1.0.0 Index]