R/easyAHP.R

Defines functions easyAHP

Documented in easyAHP

easyAHP=function(data){

N=ncol(data)
n=nrow(data)

if(N>20){
  stop("Error: more than 20 makers is not allowed!")
}

lnx=function(p){
ln=matrix(rep(0,n*n),nrow=n)
for(i in 1:n){
  for(j in 1:n){
    if(i==j){
      ln[i,j]=1
    }else{
      delta=data[,p][i]-data[,p][j]
      if(delta<0){
        ln[j,i]=abs(delta)
        ln[i,j]=1/ln[j,i]
      }else{
        ln[i,j]=delta
        ln[j,i]=1/ln[i,j]
      }
    }
  }
}
MarginLn=margin.table(ln,2)
LnLn=log(ln)
ExpMarginLnLn=exp(margin.table(LnLn,1)/n)
RGGM=prop.table(ExpMarginLnLn)
SumRGGM=MarginLn%*%RGGM
CI=(SumRGGM-n)/(n-1)
CR=(SumRGGM-n)/((2.7699*n-4.3513)-n)
dimnames(ln)=list(row.names(data),row.names(data))
names(RGGM)=row.names(data)
return(list(Matrix=ln,Weights=RGGM,CI=as.numeric(CI),CR=as.numeric(CR)))
}

ConLambda=function(ConLn){
  Matrix10=matrix(rep(0,10*10),ncol=10)
  diag(Matrix10)=1
  Matrix10[1:n,1:n]=ConLn
  MarginMatrix10.1=margin.table(Matrix10,1)
  Iterations0=MarginMatrix10.1/10
  Scaling0=Iterations0/max(Iterations0)
  Iterations1=Matrix10%*%Iterations0
  Scaling1=Iterations1/max(Iterations1)
  Iterations2=Matrix10%*%Scaling1
  Scaling2=Iterations2/max(Iterations2)
  Iterations3=Matrix10%*%Scaling2
  Scaling3=Iterations3/max(Iterations3)
  Iterations4=Matrix10%*%Scaling3
  Scaling4=Iterations4/max(Iterations4)
  Iterations5=Matrix10%*%Scaling4
  Scaling5=Iterations5/max(Iterations5)
  Iterations6=Matrix10%*%Scaling5
  Scaling6=Iterations6/max(Iterations6)
  Iterations7=Matrix10%*%Scaling6
  Scaling7=Iterations7/max(Iterations7)
  Iterations8=Matrix10%*%Scaling7
  Scaling8=Iterations8/max(Iterations8)
  Iterations9=Matrix10%*%Scaling8
  Scaling9=Iterations9/max(Iterations9)
  Iterations10=Matrix10%*%Scaling9
  Scaling10=Iterations10/max(Iterations10)
  Iterations11=Matrix10%*%Scaling10
  Scaling11=Iterations11/max(Iterations11)
  Iterations12=Matrix10%*%Scaling11
  Scaling12=Iterations12/max(Iterations12)
  MatrixScaling=matrix(c(Scaling0,Scaling1,Scaling2,Scaling3,Scaling4,
                           Scaling5,Scaling6,Scaling7,Scaling8,Scaling9,
                           Scaling10,Scaling11,Scaling12),nrow=10)
  MarginMatrixScaling2=margin.table(MatrixScaling,2)
  Normal=MatrixScaling
  for(Normal.i in 1:13){
    Normal[,Normal.i]=MatrixScaling[,Normal.i]/MarginMatrixScaling2[Normal.i]
  }
  MarginMatrix10.2=margin.table(Matrix10,2)
  Eigenvalue=MarginMatrix10.2%*%Normal[,2:13]
  return(Eigenvalue[12])
}

if(N==1){
  ln1=lnx(p=1)
  LogLn1=log(ln1$Matrix)
  ConLogLn=(LogLn1)/N
  ConLn=exp(ConLogLn)
  lambda=ConLambda(ConLn)
  CI=(lambda-n)/(n-1)
  CR=(lambda-n)/((2.7699*n-4.3513)-n)
  ExpMarginConLogLn=exp(margin.table(ConLogLn,1)/n)
  RGGM=prop.table(ExpMarginConLogLn)
  dimnames(ConLn)=list(row.names(data),row.names(data))
  lnCon=list(Matrix=ConLn,Weights=RGGM,CI=CI,CR=CR)
  rst=list(Maker1=ln1,Makers=lnCon)
}

if(N==2){
  ln1=lnx(p=1)
  ln2=lnx(p=2)
  LogLn1=log(ln1$Matrix)
  LogLn2=log(ln2$Matrix)
  ConLogLn=(LogLn1+LogLn2)/N
  ConLn=exp(ConLogLn)
  lambda=ConLambda(ConLn)
  CI=(lambda-n)/(n-1)
  CR=(lambda-n)/((2.7699*n-4.3513)-n)
  ExpMarginConLogLn=exp(margin.table(ConLogLn,1)/n)
  RGGM=prop.table(ExpMarginConLogLn)
  dimnames(ConLn)=list(row.names(data),row.names(data))
  lnCon=list(Matrix=ConLn,Weights=RGGM,CI=CI,CR=CR)
  rst=list(Maker1=ln1,Maker2=ln2,Makers=lnCon)
}

if(N==3){
  ln1=lnx(p=1)
  ln2=lnx(p=2)
  ln3=lnx(p=3)
  LogLn1=log(ln1$Matrix)
  LogLn2=log(ln2$Matrix)
  LogLn3=log(ln3$Matrix)
  ConLogLn=(LogLn1+LogLn2+LogLn3)/N
  ConLn=exp(ConLogLn)
  lambda=ConLambda(ConLn)
  CI=(lambda-n)/(n-1)
  CR=(lambda-n)/((2.7699*n-4.3513)-n)
  ExpMarginConLogLn=exp(margin.table(ConLogLn,1)/n)
  RGGM=prop.table(ExpMarginConLogLn)
  dimnames(ConLn)=list(row.names(data),row.names(data))
  lnCon=list(Matrix=ConLn,Weights=RGGM,CI=CI,CR=CR)
  rst=list(Maker1=ln1,Maker2=ln2,Maker3=ln3,Makers=lnCon)
}

if(N==4){
  ln1=lnx(p=1)
  ln2=lnx(p=2)
  ln3=lnx(p=3)
  ln4=lnx(p=4)
  LogLn1=log(ln1$Matrix)
  LogLn2=log(ln2$Matrix)
  LogLn3=log(ln3$Matrix)
  LogLn4=log(ln4$Matrix)
  ConLogLn=(LogLn1+LogLn2+LogLn3+LogLn4)/N
  ConLn=exp(ConLogLn)
  lambda=ConLambda(ConLn)
  CI=(lambda-n)/(n-1)
  CR=(lambda-n)/((2.7699*n-4.3513)-n)
  ExpMarginConLogLn=exp(margin.table(ConLogLn,1)/n)
  RGGM=prop.table(ExpMarginConLogLn)
  dimnames(ConLn)=list(row.names(data),row.names(data))
  lnCon=list(Matrix=ConLn,Weights=RGGM,CI=CI,CR=CR)
  rst=list(Maker1=ln1,Maker2=ln2,Maker3=ln3,Maker4=ln4,Makers=lnCon)
}

if(N==5){
  ln1=lnx(p=1);LogLn1=log(ln1$Matrix)
  ln2=lnx(p=2);LogLn2=log(ln2$Matrix)
  ln3=lnx(p=3);LogLn3=log(ln3$Matrix)
  ln4=lnx(p=4);LogLn4=log(ln4$Matrix)
  ln5=lnx(p=5);LogLn5=log(ln5$Matrix)
  ConLogLn=(LogLn1+LogLn2+LogLn3+LogLn4+LogLn5)/N
  ConLn=exp(ConLogLn)
  lambda=ConLambda(ConLn)
  CI=(lambda-n)/(n-1)
  CR=(lambda-n)/((2.7699*n-4.3513)-n)
  ExpMarginConLogLn=exp(margin.table(ConLogLn,1)/n)
  RGGM=prop.table(ExpMarginConLogLn)
  dimnames(ConLn)=list(row.names(data),row.names(data))
  lnCon=list(Matrix=ConLn,Weights=RGGM,CI=CI,CR=CR)
  rst=list(Maker1=ln1,Maker2=ln2,Maker3=ln3,Maker4=ln4,Maker5=ln5,
           Makers=lnCon)
}

if(N==6){
  ln1=lnx(p=1);LogLn1=log(ln1$Matrix)
  ln2=lnx(p=2);LogLn2=log(ln2$Matrix)
  ln3=lnx(p=3);LogLn3=log(ln3$Matrix)
  ln4=lnx(p=4);LogLn4=log(ln4$Matrix)
  ln5=lnx(p=5);LogLn5=log(ln5$Matrix)
  ln6=lnx(p=6);LogLn6=log(ln6$Matrix)
  ConLogLn=(LogLn1+LogLn2+LogLn3+LogLn4+LogLn5+LogLn6)/N
  ConLn=exp(ConLogLn)
  lambda=ConLambda(ConLn)
  CI=(lambda-n)/(n-1)
  CR=(lambda-n)/((2.7699*n-4.3513)-n)
  ExpMarginConLogLn=exp(margin.table(ConLogLn,1)/n)
  RGGM=prop.table(ExpMarginConLogLn)
  dimnames(ConLn)=list(row.names(data),row.names(data))
  lnCon=list(Matrix=ConLn,Weights=RGGM,CI=CI,CR=CR)
  rst=list(Maker1=ln1,Maker2=ln2,Maker3=ln3,Maker4=ln4,Maker5=ln5,
           Maker6=ln6,Makers=lnCon)
}

if(N==7){
  ln1=lnx(p=1);LogLn1=log(ln1$Matrix)
  ln2=lnx(p=2);LogLn2=log(ln2$Matrix)
  ln3=lnx(p=3);LogLn3=log(ln3$Matrix)
  ln4=lnx(p=4);LogLn4=log(ln4$Matrix)
  ln5=lnx(p=5);LogLn5=log(ln5$Matrix)
  ln6=lnx(p=6);LogLn6=log(ln6$Matrix)
  ln7=lnx(p=7);LogLn7=log(ln7$Matrix)
  ConLogLn=(LogLn1+LogLn2+LogLn3+LogLn4+LogLn5+LogLn6+LogLn7)/N
  ConLn=exp(ConLogLn)
  lambda=ConLambda(ConLn)
  CI=(lambda-n)/(n-1)
  CR=(lambda-n)/((2.7699*n-4.3513)-n)
  ExpMarginConLogLn=exp(margin.table(ConLogLn,1)/n)
  RGGM=prop.table(ExpMarginConLogLn)
  dimnames(ConLn)=list(row.names(data),row.names(data))
  lnCon=list(Matrix=ConLn,Weights=RGGM,CI=CI,CR=CR)
  rst=list(Maker1=ln1,Maker2=ln2,Maker3=ln3,Maker4=ln4,Maker5=ln5,
           Maker6=ln6,Maker7=ln7,Makers=lnCon)
}

if(N==8){
  ln1=lnx(p=1);LogLn1=log(ln1$Matrix)
  ln2=lnx(p=2);LogLn2=log(ln2$Matrix)
  ln3=lnx(p=3);LogLn3=log(ln3$Matrix)
  ln4=lnx(p=4);LogLn4=log(ln4$Matrix)
  ln5=lnx(p=5);LogLn5=log(ln5$Matrix)
  ln6=lnx(p=6);LogLn6=log(ln6$Matrix)
  ln7=lnx(p=7);LogLn7=log(ln7$Matrix)
  ln8=lnx(p=8);LogLn8=log(ln8$Matrix)
  ConLogLn=(LogLn1+LogLn2+LogLn3+LogLn4+LogLn5+LogLn6+LogLn7+LogLn8)/N
  ConLn=exp(ConLogLn)
  lambda=ConLambda(ConLn)
  CI=(lambda-n)/(n-1)
  CR=(lambda-n)/((2.7699*n-4.3513)-n)
  ExpMarginConLogLn=exp(margin.table(ConLogLn,1)/n)
  RGGM=prop.table(ExpMarginConLogLn)
  dimnames(ConLn)=list(row.names(data),row.names(data))
  lnCon=list(Matrix=ConLn,Weights=RGGM,CI=CI,CR=CR)
  rst=list(Maker1=ln1,Maker2=ln2,Maker3=ln3,Maker4=ln4,Maker5=ln5,
           Maker6=ln6,Maker7=ln7,Maker8=ln8,Makers=lnCon)
}

if(N==9){
  ln1=lnx(p=1);LogLn1=log(ln1$Matrix)
  ln2=lnx(p=2);LogLn2=log(ln2$Matrix)
  ln3=lnx(p=3);LogLn3=log(ln3$Matrix)
  ln4=lnx(p=4);LogLn4=log(ln4$Matrix)
  ln5=lnx(p=5);LogLn5=log(ln5$Matrix)
  ln6=lnx(p=6);LogLn6=log(ln6$Matrix)
  ln7=lnx(p=7);LogLn7=log(ln7$Matrix)
  ln8=lnx(p=8);LogLn8=log(ln8$Matrix)
  ln9=lnx(p=9);LogLn9=log(ln9$Matrix)
  ConLogLn=(LogLn1+LogLn2+LogLn3+LogLn4+LogLn5+LogLn6+LogLn7+LogLn8+LogLn9)/N
  ConLn=exp(ConLogLn)
  lambda=ConLambda(ConLn)
  CI=(lambda-n)/(n-1)
  CR=(lambda-n)/((2.7699*n-4.3513)-n)
  ExpMarginConLogLn=exp(margin.table(ConLogLn,1)/n)
  RGGM=prop.table(ExpMarginConLogLn)
  dimnames(ConLn)=list(row.names(data),row.names(data))
  lnCon=list(Matrix=ConLn,Weights=RGGM,CI=CI,CR=CR)
  rst=list(Maker1=ln1,Maker2=ln2,Maker3=ln3,Maker4=ln4,Maker5=ln5,
           Maker6=ln6,Maker7=ln7,Maker8=ln8,Maker9=ln9,Makers=lnCon)
}

if(N==10){
  ln1=lnx(p=1);LogLn1=log(ln1$Matrix)
  ln2=lnx(p=2);LogLn2=log(ln2$Matrix)
  ln3=lnx(p=3);LogLn3=log(ln3$Matrix)
  ln4=lnx(p=4);LogLn4=log(ln4$Matrix)
  ln5=lnx(p=5);LogLn5=log(ln5$Matrix)
  ln6=lnx(p=6);LogLn6=log(ln6$Matrix)
  ln7=lnx(p=7);LogLn7=log(ln7$Matrix)
  ln8=lnx(p=8);LogLn8=log(ln8$Matrix)
  ln9=lnx(p=9);LogLn9=log(ln9$Matrix)
  ln10=lnx(p=10);LogLn10=log(ln10$Matrix)
  ConLogLn=(LogLn1+LogLn2+LogLn3+LogLn4+LogLn5+LogLn6+LogLn7+LogLn8+LogLn9+
            LogLn10)/N
  ConLn=exp(ConLogLn)
  lambda=ConLambda(ConLn)
  CI=(lambda-n)/(n-1)
  CR=(lambda-n)/((2.7699*n-4.3513)-n)
  ExpMarginConLogLn=exp(margin.table(ConLogLn,1)/n)
  RGGM=prop.table(ExpMarginConLogLn)
  dimnames(ConLn)=list(row.names(data),row.names(data))
  lnCon=list(Matrix=ConLn,Weights=RGGM,CI=CI,CR=CR)
  rst=list(Maker1=ln1,Maker2=ln2,Maker3=ln3,Maker4=ln4,Maker5=ln5,
           Maker6=ln6,Maker7=ln7,Maker8=ln8,Maker9=ln9,Maker10=ln10,
           Makers=lnCon)
}

if(N==11){
  ln1=lnx(p=1);LogLn1=log(ln1$Matrix)
  ln2=lnx(p=2);LogLn2=log(ln2$Matrix)
  ln3=lnx(p=3);LogLn3=log(ln3$Matrix)
  ln4=lnx(p=4);LogLn4=log(ln4$Matrix)
  ln5=lnx(p=5);LogLn5=log(ln5$Matrix)
  ln6=lnx(p=6);LogLn6=log(ln6$Matrix)
  ln7=lnx(p=7);LogLn7=log(ln7$Matrix)
  ln8=lnx(p=8);LogLn8=log(ln8$Matrix)
  ln9=lnx(p=9);LogLn9=log(ln9$Matrix)
  ln10=lnx(p=10);LogLn10=log(ln10$Matrix)
  ln11=lnx(p=11);LogLn11=log(ln11$Matrix)
  ConLogLn=(LogLn1+LogLn2+LogLn3+LogLn4+LogLn5+LogLn6+LogLn7+LogLn8+LogLn9+
              LogLn10+LogLn11)/N
  ConLn=exp(ConLogLn)
  lambda=ConLambda(ConLn)
  CI=(lambda-n)/(n-1)
  CR=(lambda-n)/((2.7699*n-4.3513)-n)
  ExpMarginConLogLn=exp(margin.table(ConLogLn,1)/n)
  RGGM=prop.table(ExpMarginConLogLn)
  dimnames(ConLn)=list(row.names(data),row.names(data))
  lnCon=list(Matrix=ConLn,Weights=RGGM,CI=CI,CR=CR)
  rst=list(Maker1=ln1,Maker2=ln2,Maker3=ln3,Maker4=ln4,Maker5=ln5,
           Maker6=ln6,Maker7=ln7,Maker8=ln8,Maker9=ln9,Maker10=ln10,
           Maker11=ln11,Makers=lnCon)
}

if(N==12){
  ln1=lnx(p=1);LogLn1=log(ln1$Matrix)
  ln2=lnx(p=2);LogLn2=log(ln2$Matrix)
  ln3=lnx(p=3);LogLn3=log(ln3$Matrix)
  ln4=lnx(p=4);LogLn4=log(ln4$Matrix)
  ln5=lnx(p=5);LogLn5=log(ln5$Matrix)
  ln6=lnx(p=6);LogLn6=log(ln6$Matrix)
  ln7=lnx(p=7);LogLn7=log(ln7$Matrix)
  ln8=lnx(p=8);LogLn8=log(ln8$Matrix)
  ln9=lnx(p=9);LogLn9=log(ln9$Matrix)
  ln10=lnx(p=10);LogLn10=log(ln10$Matrix)
  ln11=lnx(p=11);LogLn11=log(ln11$Matrix)
  ln12=lnx(p=12);LogLn12=log(ln12$Matrix)
  ConLogLn=(LogLn1+LogLn2+LogLn3+LogLn4+LogLn5+LogLn6+LogLn7+LogLn8+LogLn9+
              LogLn10+LogLn11+LogLn12)/N
  ConLn=exp(ConLogLn)
  lambda=ConLambda(ConLn)
  CI=(lambda-n)/(n-1)
  CR=(lambda-n)/((2.7699*n-4.3513)-n)
  ExpMarginConLogLn=exp(margin.table(ConLogLn,1)/n)
  RGGM=prop.table(ExpMarginConLogLn)
  dimnames(ConLn)=list(row.names(data),row.names(data))
  lnCon=list(Matrix=ConLn,Weights=RGGM,CI=CI,CR=CR)
  rst=list(Maker1=ln1,Maker2=ln2,Maker3=ln3,Maker4=ln4,Maker5=ln5,
           Maker6=ln6,Maker7=ln7,Maker8=ln8,Maker9=ln9,Maker10=ln10,
           Maker11=ln11,Maker12=ln12,Makers=lnCon)
}

if(N==13){
  ln1=lnx(p=1);LogLn1=log(ln1$Matrix)
  ln2=lnx(p=2);LogLn2=log(ln2$Matrix)
  ln3=lnx(p=3);LogLn3=log(ln3$Matrix)
  ln4=lnx(p=4);LogLn4=log(ln4$Matrix)
  ln5=lnx(p=5);LogLn5=log(ln5$Matrix)
  ln6=lnx(p=6);LogLn6=log(ln6$Matrix)
  ln7=lnx(p=7);LogLn7=log(ln7$Matrix)
  ln8=lnx(p=8);LogLn8=log(ln8$Matrix)
  ln9=lnx(p=9);LogLn9=log(ln9$Matrix)
  ln10=lnx(p=10);LogLn10=log(ln10$Matrix)
  ln11=lnx(p=11);LogLn11=log(ln11$Matrix)
  ln12=lnx(p=12);LogLn12=log(ln12$Matrix)
  ln13=lnx(p=13);LogLn13=log(ln13$Matrix)
  ConLogLn=(LogLn1+LogLn2+LogLn3+LogLn4+LogLn5+LogLn6+LogLn7+LogLn8+LogLn9+
              LogLn10+LogLn11+LogLn12+LogLn13)/N
  ConLn=exp(ConLogLn)
  lambda=ConLambda(ConLn)
  CI=(lambda-n)/(n-1)
  CR=(lambda-n)/((2.7699*n-4.3513)-n)
  ExpMarginConLogLn=exp(margin.table(ConLogLn,1)/n)
  RGGM=prop.table(ExpMarginConLogLn)
  dimnames(ConLn)=list(row.names(data),row.names(data))
  lnCon=list(Matrix=ConLn,Weights=RGGM,CI=CI,CR=CR)
  rst=list(Maker1=ln1,Maker2=ln2,Maker3=ln3,Maker4=ln4,Maker5=ln5,
           Maker6=ln6,Maker7=ln7,Maker8=ln8,Maker9=ln9,Maker10=ln10,
           Maker11=ln11,Maker12=ln12,Maker13=ln13,Makers=lnCon)
}

if(N==14){
  ln1=lnx(p=1);LogLn1=log(ln1$Matrix)
  ln2=lnx(p=2);LogLn2=log(ln2$Matrix)
  ln3=lnx(p=3);LogLn3=log(ln3$Matrix)
  ln4=lnx(p=4);LogLn4=log(ln4$Matrix)
  ln5=lnx(p=5);LogLn5=log(ln5$Matrix)
  ln6=lnx(p=6);LogLn6=log(ln6$Matrix)
  ln7=lnx(p=7);LogLn7=log(ln7$Matrix)
  ln8=lnx(p=8);LogLn8=log(ln8$Matrix)
  ln9=lnx(p=9);LogLn9=log(ln9$Matrix)
  ln10=lnx(p=10);LogLn10=log(ln10$Matrix)
  ln11=lnx(p=11);LogLn11=log(ln11$Matrix)
  ln12=lnx(p=12);LogLn12=log(ln12$Matrix)
  ln13=lnx(p=13);LogLn13=log(ln13$Matrix)
  ln14=lnx(p=14);LogLn14=log(ln14$Matrix)
  ConLogLn=(LogLn1+LogLn2+LogLn3+LogLn4+LogLn5+LogLn6+LogLn7+LogLn8+LogLn9+
              LogLn10+LogLn11+LogLn12+LogLn13+LogLn14)/N
  ConLn=exp(ConLogLn)
  lambda=ConLambda(ConLn)
  CI=(lambda-n)/(n-1)
  CR=(lambda-n)/((2.7699*n-4.3513)-n)
  ExpMarginConLogLn=exp(margin.table(ConLogLn,1)/n)
  RGGM=prop.table(ExpMarginConLogLn)
  dimnames(ConLn)=list(row.names(data),row.names(data))
  lnCon=list(Matrix=ConLn,Weights=RGGM,CI=CI,CR=CR)
  rst=list(Maker1=ln1,Maker2=ln2,Maker3=ln3,Maker4=ln4,Maker5=ln5,
           Maker6=ln6,Maker7=ln7,Maker8=ln8,Maker9=ln9,Maker10=ln10,
           Maker11=ln11,Maker12=ln12,Maker13=ln13,Maker14=ln14,Makers=lnCon)
}

if(N==15){
  ln1=lnx(p=1);LogLn1=log(ln1$Matrix)
  ln2=lnx(p=2);LogLn2=log(ln2$Matrix)
  ln3=lnx(p=3);LogLn3=log(ln3$Matrix)
  ln4=lnx(p=4);LogLn4=log(ln4$Matrix)
  ln5=lnx(p=5);LogLn5=log(ln5$Matrix)
  ln6=lnx(p=6);LogLn6=log(ln6$Matrix)
  ln7=lnx(p=7);LogLn7=log(ln7$Matrix)
  ln8=lnx(p=8);LogLn8=log(ln8$Matrix)
  ln9=lnx(p=9);LogLn9=log(ln9$Matrix)
  ln10=lnx(p=10);LogLn10=log(ln10$Matrix)
  ln11=lnx(p=11);LogLn11=log(ln11$Matrix)
  ln12=lnx(p=12);LogLn12=log(ln12$Matrix)
  ln13=lnx(p=13);LogLn13=log(ln13$Matrix)
  ln14=lnx(p=14);LogLn14=log(ln14$Matrix)
  ln15=lnx(p=15);LogLn15=log(ln15$Matrix)
  ConLogLn=(LogLn1+LogLn2+LogLn3+LogLn4+LogLn5+LogLn6+LogLn7+LogLn8+LogLn9+
              LogLn10+LogLn11+LogLn12+LogLn13+LogLn14+LogLn15)/N
  ConLn=exp(ConLogLn)
  lambda=ConLambda(ConLn)
  CI=(lambda-n)/(n-1)
  CR=(lambda-n)/((2.7699*n-4.3513)-n)
  ExpMarginConLogLn=exp(margin.table(ConLogLn,1)/n)
  RGGM=prop.table(ExpMarginConLogLn)
  dimnames(ConLn)=list(row.names(data),row.names(data))
  lnCon=list(Matrix=ConLn,Weights=RGGM,CI=CI,CR=CR)
  rst=list(Maker1=ln1,Maker2=ln2,Maker3=ln3,Maker4=ln4,Maker5=ln5,
           Maker6=ln6,Maker7=ln7,Maker8=ln8,Maker9=ln9,Maker10=ln10,
           Maker11=ln11,Maker12=ln12,Maker13=ln13,Maker14=ln14,
           Maker15=ln15,Makers=lnCon)
}

if(N==16){
  ln1=lnx(p=1);LogLn1=log(ln1$Matrix)
  ln2=lnx(p=2);LogLn2=log(ln2$Matrix)
  ln3=lnx(p=3);LogLn3=log(ln3$Matrix)
  ln4=lnx(p=4);LogLn4=log(ln4$Matrix)
  ln5=lnx(p=5);LogLn5=log(ln5$Matrix)
  ln6=lnx(p=6);LogLn6=log(ln6$Matrix)
  ln7=lnx(p=7);LogLn7=log(ln7$Matrix)
  ln8=lnx(p=8);LogLn8=log(ln8$Matrix)
  ln9=lnx(p=9);LogLn9=log(ln9$Matrix)
  ln10=lnx(p=10);LogLn10=log(ln10$Matrix)
  ln11=lnx(p=11);LogLn11=log(ln11$Matrix)
  ln12=lnx(p=12);LogLn12=log(ln12$Matrix)
  ln13=lnx(p=13);LogLn13=log(ln13$Matrix)
  ln14=lnx(p=14);LogLn14=log(ln14$Matrix)
  ln15=lnx(p=15);LogLn15=log(ln15$Matrix)
  ln16=lnx(p=16);LogLn16=log(ln16$Matrix)
  ConLogLn=(LogLn1+LogLn2+LogLn3+LogLn4+LogLn5+LogLn6+LogLn7+LogLn8+LogLn9+
              LogLn10+LogLn11+LogLn12+LogLn13+LogLn14+LogLn15+LogLn16)/N
  ConLn=exp(ConLogLn)
  lambda=ConLambda(ConLn)
  CI=(lambda-n)/(n-1)
  CR=(lambda-n)/((2.7699*n-4.3513)-n)
  ExpMarginConLogLn=exp(margin.table(ConLogLn,1)/n)
  RGGM=prop.table(ExpMarginConLogLn)
  dimnames(ConLn)=list(row.names(data),row.names(data))
  lnCon=list(Matrix=ConLn,Weights=RGGM,CI=CI,CR=CR)
  rst=list(Maker1=ln1,Maker2=ln2,Maker3=ln3,Maker4=ln4,Maker5=ln5,
           Maker6=ln6,Maker7=ln7,Maker8=ln8,Maker9=ln9,Maker10=ln10,
           Maker11=ln11,Maker12=ln12,Maker13=ln13,Maker14=ln14,
           Maker15=ln15,Maker16=ln16,Makers=lnCon)
}

if(N==17){
  ln1=lnx(p=1);LogLn1=log(ln1$Matrix)
  ln2=lnx(p=2);LogLn2=log(ln2$Matrix)
  ln3=lnx(p=3);LogLn3=log(ln3$Matrix)
  ln4=lnx(p=4);LogLn4=log(ln4$Matrix)
  ln5=lnx(p=5);LogLn5=log(ln5$Matrix)
  ln6=lnx(p=6);LogLn6=log(ln6$Matrix)
  ln7=lnx(p=7);LogLn7=log(ln7$Matrix)
  ln8=lnx(p=8);LogLn8=log(ln8$Matrix)
  ln9=lnx(p=9);LogLn9=log(ln9$Matrix)
  ln10=lnx(p=10);LogLn10=log(ln10$Matrix)
  ln11=lnx(p=11);LogLn11=log(ln11$Matrix)
  ln12=lnx(p=12);LogLn12=log(ln12$Matrix)
  ln13=lnx(p=13);LogLn13=log(ln13$Matrix)
  ln14=lnx(p=14);LogLn14=log(ln14$Matrix)
  ln15=lnx(p=15);LogLn15=log(ln15$Matrix)
  ln16=lnx(p=16);LogLn16=log(ln16$Matrix)
  ln17=lnx(p=17);LogLn17=log(ln17$Matrix)
  ConLogLn=(LogLn1+LogLn2+LogLn3+LogLn4+LogLn5+LogLn6+LogLn7+LogLn8+LogLn9+
              LogLn10+LogLn11+LogLn12+LogLn13+LogLn14+LogLn15+LogLn16+
              LogLn17)/N
  ConLn=exp(ConLogLn)
  lambda=ConLambda(ConLn)
  CI=(lambda-n)/(n-1)
  CR=(lambda-n)/((2.7699*n-4.3513)-n)
  ExpMarginConLogLn=exp(margin.table(ConLogLn,1)/n)
  RGGM=prop.table(ExpMarginConLogLn)
  dimnames(ConLn)=list(row.names(data),row.names(data))
  lnCon=list(Matrix=ConLn,Weights=RGGM,CI=CI,CR=CR)
  rst=list(Maker1=ln1,Maker2=ln2,Maker3=ln3,Maker4=ln4,Maker5=ln5,
           Maker6=ln6,Maker7=ln7,Maker8=ln8,Maker9=ln9,Maker10=ln10,
           Maker11=ln11,Maker12=ln12,Maker13=ln13,Maker14=ln14,
           Maker15=ln15,Maker16=ln16,Maker17=ln17,Makers=lnCon)
}

if(N==18){
  ln1=lnx(p=1);LogLn1=log(ln1$Matrix)
  ln2=lnx(p=2);LogLn2=log(ln2$Matrix)
  ln3=lnx(p=3);LogLn3=log(ln3$Matrix)
  ln4=lnx(p=4);LogLn4=log(ln4$Matrix)
  ln5=lnx(p=5);LogLn5=log(ln5$Matrix)
  ln6=lnx(p=6);LogLn6=log(ln6$Matrix)
  ln7=lnx(p=7);LogLn7=log(ln7$Matrix)
  ln8=lnx(p=8);LogLn8=log(ln8$Matrix)
  ln9=lnx(p=9);LogLn9=log(ln9$Matrix)
  ln10=lnx(p=10);LogLn10=log(ln10$Matrix)
  ln11=lnx(p=11);LogLn11=log(ln11$Matrix)
  ln12=lnx(p=12);LogLn12=log(ln12$Matrix)
  ln13=lnx(p=13);LogLn13=log(ln13$Matrix)
  ln14=lnx(p=14);LogLn14=log(ln14$Matrix)
  ln15=lnx(p=15);LogLn15=log(ln15$Matrix)
  ln16=lnx(p=16);LogLn16=log(ln16$Matrix)
  ln17=lnx(p=17);LogLn17=log(ln17$Matrix)
  ln18=lnx(p=18);LogLn18=log(ln18$Matrix)
  ConLogLn=(LogLn1+LogLn2+LogLn3+LogLn4+LogLn5+LogLn6+LogLn7+LogLn8+LogLn9+
              LogLn10+LogLn11+LogLn12+LogLn13+LogLn14+LogLn15+LogLn16+
              LogLn17+LogLn18)/N
  ConLn=exp(ConLogLn)
  lambda=ConLambda(ConLn)
  CI=(lambda-n)/(n-1)
  CR=(lambda-n)/((2.7699*n-4.3513)-n)
  ExpMarginConLogLn=exp(margin.table(ConLogLn,1)/n)
  RGGM=prop.table(ExpMarginConLogLn)
  dimnames(ConLn)=list(row.names(data),row.names(data))
  lnCon=list(Matrix=ConLn,Weights=RGGM,CI=CI,CR=CR)
  rst=list(Maker1=ln1,Maker2=ln2,Maker3=ln3,Maker4=ln4,Maker5=ln5,
           Maker6=ln6,Maker7=ln7,Maker8=ln8,Maker9=ln9,Maker10=ln10,
           Maker11=ln11,Maker12=ln12,Maker13=ln13,Maker14=ln14,
           Maker15=ln15,Maker16=ln16,Maker17=ln17,Maker18=ln18,Makers=lnCon)
}

if(N==19){
  ln1=lnx(p=1);LogLn1=log(ln1$Matrix)
  ln2=lnx(p=2);LogLn2=log(ln2$Matrix)
  ln3=lnx(p=3);LogLn3=log(ln3$Matrix)
  ln4=lnx(p=4);LogLn4=log(ln4$Matrix)
  ln5=lnx(p=5);LogLn5=log(ln5$Matrix)
  ln6=lnx(p=6);LogLn6=log(ln6$Matrix)
  ln7=lnx(p=7);LogLn7=log(ln7$Matrix)
  ln8=lnx(p=8);LogLn8=log(ln8$Matrix)
  ln9=lnx(p=9);LogLn9=log(ln9$Matrix)
  ln10=lnx(p=10);LogLn10=log(ln10$Matrix)
  ln11=lnx(p=11);LogLn11=log(ln11$Matrix)
  ln12=lnx(p=12);LogLn12=log(ln12$Matrix)
  ln13=lnx(p=13);LogLn13=log(ln13$Matrix)
  ln14=lnx(p=14);LogLn14=log(ln14$Matrix)
  ln15=lnx(p=15);LogLn15=log(ln15$Matrix)
  ln16=lnx(p=16);LogLn16=log(ln16$Matrix)
  ln17=lnx(p=17);LogLn17=log(ln17$Matrix)
  ln18=lnx(p=18);LogLn18=log(ln18$Matrix)
  ln19=lnx(p=19);LogLn19=log(ln19$Matrix)
  ConLogLn=(LogLn1+LogLn2+LogLn3+LogLn4+LogLn5+LogLn6+LogLn7+LogLn8+LogLn9+
              LogLn10+LogLn11+LogLn12+LogLn13+LogLn14+LogLn15+LogLn16+
              LogLn17+LogLn18+LogLn19)/N
  ConLn=exp(ConLogLn)
  lambda=ConLambda(ConLn)
  CI=(lambda-n)/(n-1)
  CR=(lambda-n)/((2.7699*n-4.3513)-n)
  ExpMarginConLogLn=exp(margin.table(ConLogLn,1)/n)
  RGGM=prop.table(ExpMarginConLogLn)
  dimnames(ConLn)=list(row.names(data),row.names(data))
  lnCon=list(Matrix=ConLn,Weights=RGGM,CI=CI,CR=CR)
  rst=list(Maker1=ln1,Maker2=ln2,Maker3=ln3,Maker4=ln4,Maker5=ln5,
           Maker6=ln6,Maker7=ln7,Maker8=ln8,Maker9=ln9,Maker10=ln10,
           Maker11=ln11,Maker12=ln12,Maker13=ln13,Maker14=ln14,
           Maker15=ln15,Maker16=ln16,Maker17=ln17,Maker18=ln18,
           Maker19=ln19,Makers=lnCon)
}

if(N==20){
  ln1=lnx(p=1);LogLn1=log(ln1$Matrix)
  ln2=lnx(p=2);LogLn2=log(ln2$Matrix)
  ln3=lnx(p=3);LogLn3=log(ln3$Matrix)
  ln4=lnx(p=4);LogLn4=log(ln4$Matrix)
  ln5=lnx(p=5);LogLn5=log(ln5$Matrix)
  ln6=lnx(p=6);LogLn6=log(ln6$Matrix)
  ln7=lnx(p=7);LogLn7=log(ln7$Matrix)
  ln8=lnx(p=8);LogLn8=log(ln8$Matrix)
  ln9=lnx(p=9);LogLn9=log(ln9$Matrix)
  ln10=lnx(p=10);LogLn10=log(ln10$Matrix)
  ln11=lnx(p=11);LogLn11=log(ln11$Matrix)
  ln12=lnx(p=12);LogLn12=log(ln12$Matrix)
  ln13=lnx(p=13);LogLn13=log(ln13$Matrix)
  ln14=lnx(p=14);LogLn14=log(ln14$Matrix)
  ln15=lnx(p=15);LogLn15=log(ln15$Matrix)
  ln16=lnx(p=16);LogLn16=log(ln16$Matrix)
  ln17=lnx(p=17);LogLn17=log(ln17$Matrix)
  ln18=lnx(p=18);LogLn18=log(ln18$Matrix)
  ln19=lnx(p=19);LogLn19=log(ln19$Matrix)
  ln20=lnx(p=20);LogLn20=log(ln20$Matrix)
  ConLogLn=(LogLn1+LogLn2+LogLn3+LogLn4+LogLn5+LogLn6+LogLn7+LogLn8+LogLn9+
              LogLn10+LogLn11+LogLn12+LogLn13+LogLn14+LogLn15+LogLn16+
              LogLn17+LogLn18+LogLn19+LogLn20)/N
  ConLn=exp(ConLogLn)
  lambda=ConLambda(ConLn)
  CI=(lambda-n)/(n-1)
  CR=(lambda-n)/((2.7699*n-4.3513)-n)
  ExpMarginConLogLn=exp(margin.table(ConLogLn,1)/n)
  RGGM=prop.table(ExpMarginConLogLn)
  dimnames(ConLn)=list(row.names(data),row.names(data))
  lnCon=list(Matrix=ConLn,Weights=RGGM,CI=CI,CR=CR)
  rst=list(Maker1=ln1,Maker2=ln2,Maker3=ln3,Maker4=ln4,Maker5=ln5,
           Maker6=ln6,Maker7=ln7,Maker8=ln8,Maker9=ln9,Maker10=ln10,
           Maker11=ln11,Maker12=ln12,Maker13=ln13,Maker14=ln14,
           Maker15=ln15,Maker16=ln16,Maker17=ln17,Maker18=ln18,
           Maker19=ln19,Maker20=ln20,Makers=lnCon)
}

return(rst)

}

Try the easyAHP package in your browser

Any scripts or data that you put into this service are public.

easyAHP documentation built on May 2, 2019, 7:58 a.m.