Figure with probability values for every combination in a 2x2 contingency table with 2 experiments of 10 and 7 trials.

library(mtest)
library(plot3D)
MAKEPDF <- T
PDFPATH <- 'D:/Math/Bernouilli/ms/vtex-soft-texsupport.ims-aos-07708a9/vtex-soft-texsupport.ims-aos-07708a9/fig1.pdf'
n1 <- 10
n2 <- 7
s1 <- seq(0, n1, length=(n1+1))
s2 <- seq(0, n2, length=(n2+1))
clrs <- c()
z <- matrix(nrow = n1+1, ncol = n2+1)
z2 <- matrix(nrow = n1+1, ncol = n2+1)
for (x in s1){
  for (y in s2){
    z2[x+1, y+1] <- tbpval(list(c(x, n1-x), c(y, n2-y)))
    z[x+1, y+1] <- bpval(list(c(x, n1-x), c(y, n2-y)))
  }
}

plot3D::persp3D(z=z, x=s1, y=s2, theta = 155, phi = 35, ticktype='detailed', bty='b2', xlab='s1', ylab='s2', zlab='\n\nP')
plot3D::persp3D(z=z2, x=s1, y=s2, theta = 145, phi = 35, ticktype='detailed', bty='b2', xlab='s1', ylab='s2', zlab='\n\nP')

if (MAKEPDF == T){
  pdf(PDFPATH, width = 8, height = 4)
  par(mfrow=c(1, 2), pty="s", oma=c(0, 1, 0, 1), pin=c(2.8, 2.8))
  plot3D::persp3D(z=z, x=s1, y=s2, theta = 155, phi = 35, ticktype='detailed', bty='b2', xlab='\n\ns1', ylab='\n\ns2', zlab='\n\n\nP')
  #mtext('A', adj = 0, cex=2)
  par(pin=c(2.8, 2.8))
  plot3D::persp3D(z=z2, x=s1, y=s2, theta = 145, phi = 35, ticktype='detailed', bty='b2', xlab='\n\ns1', ylab='\n\ns2', zlab='\n\n\nP')
  #mtext('B', adj = 0, cex=2)
  dev.off()
  #persp(s1, s2, z, theta = 135, phi = 35, ticktype = 'detailed', col = colset(z, c(0, 0, 1), c(1, 0, 0)))
}
n1 <- 10
n2 <- 7
s1 <- seq(0, n1, length=(n1+1))
s2 <- seq(0, n2, length=(n2+1))
clrs <- c()
z <- matrix(nrow = n1+1, ncol = n2+1)
z2 <- matrix(nrow = n1+1, ncol = n2+1)
for (x in s1){
  for (y in s2){
    z[x+1, y+1] <- m.test(list(c(x, n1-x), c(y, n2-y)))
    z2[x+1, y+1] <- os.m.test(list(c(x, n1-x), c(y, n2-y)))
  }
}

plot3D::persp3D(z=z, x=s1, y=s2, theta = 155, phi = 35, ticktype='detailed', bty='b2', xlab='s1', ylab='s2', zlab='\n\nPval')
plot3D::persp3D(z=z2, x=s1, y=s2, theta = 145, phi = 35, ticktype='detailed', bty='b2', xlab='s1', ylab='s2', zlab='\n\nPval')


vqf/mtest documentation built on Dec. 23, 2021, 4:11 p.m.