econdprime<-function(m){

  #compute proportion-matrix from input matrix  
  P <- pmatrix(m)
  
  #compute d'prime of A conditional on B1
  h1 <- P[1,1] / (P[1,1] + P[1,2])
  fa1 <- P[2,1] / (P[2,1] + P[2,2])
  h2 <- P[1,3] / (P[1,3] + P[1,4])
  fa2 <- P[2,3] / (P[2,3] + P[2,4])
  
  #compute z-score of p-values
  A <- testd(h1, fa1, h2, fa2, sum(m[1,1:2]), sum(m[2,1:2]), sum(m[1,3:4]), sum(m[2,3:4]))
  
  # store string with decision about test
  if (A$p_value < 0.05) {
    Pass<- 'NO'
  } else {
    Pass<- 'YES'
  }
  
  #store results in dataframe
  results<-data.frame(Test="d_A conditional on B1",dprime_hit=A$d[1],dprime_miss=A$d[2],z=A$z,p_value=A$p_value,Pass=Pass,stringsAsFactors=FALSE)
  
  #compute d'prime of A conditional on B2
  h1<-P[3,3]/(P[3,3]+P[3,4])
  fa1<-P[4,3]/(P[4,3]+P[4,4])
  h2<-P[3,1]/(P[3,1]+P[3,2])
  fa2<-P[4,1]/(P[4,1]+P[4,2])
  
  #compute z-score of p-values
  A<-testd(h1,fa1,h2,fa2,sum(m[3,3:4]),sum(m[4,3:4]),sum(m[3,1:2]),sum(m[4,1:2]))
  
  # store string with decision about test
  if (A$p_value < 0.05) {
    Pass<- 'NO'
  } else {
    Pass<- 'YES'
  }
  
  #add results to dataframe
  results<-rbind(results,c("d_A conditional on B2",dprime_hit=A$d[1],dprime_miss=A$d[2], z=A$z,p_value=A$p_value,Pass=Pass))
  
  #compute d'prime of B conditional on A1
  h1<-P[1,1]/(P[1,1]+P[1,3])
  fa1<-P[3,1]/(P[3,1]+P[3,3])
  h2<-P[1,2]/(P[1,2]+P[1,4])
  fa2<-P[3,2]/(P[3,2]+P[3,4])
  
  #compute z-score of p-values
  A<-testd(h1,fa1,h2,fa2,sum(m[1,c(1,3)]),sum(m[3,c(1,3)]),sum(m[1,c(2,4)]),sum(m[3,c(2,4)]))
  
  # store string with decision about test
  if (A$p_value < 0.05) {
    Pass<- 'NO'
  } else {
    Pass<- 'YES'
  }
  
  #add results to dataframe
  results<-rbind(results,c("d_B conditional on A1",dprime_hit=A$d[1],dprime_miss=A$d[2], z=A$z,p_value=A$p_value,Pass=Pass))
  
  #compute d'prime of B conditional on A2
  h1<-P[2,2]/(P[2,2]+P[2,4])
  fa1<-P[4,2]/(P[4,2]+P[4,4])
  h2<-P[2,1]/(P[2,1]+P[2,3])
  fa2<-P[4,1]/(P[4,1]+P[4,3])
  
  #compute z-score of p-values
  A<-testd(h1,fa1,h2,fa2,sum(m[2,c(2,4)]),sum(m[4,c(2,4)]),sum(m[2,c(1,3)]),sum(m[4,c(1,3)]))
  
  # store string with decision about test
  if (A$p_value < 0.05) {
    Pass<- 'NO'
  } else {
    Pass<- 'YES'
  }
  
  #add results to dataframe
  results<-rbind(results,c("d_B conditional on A2",dprime_hit=A$d[1],dprime_miss=A$d[2], z=A$z,p_value=A$p_value,Pass=Pass))
  
  #output
  return(results)
}
