Dear all, I am trying to calculate certain critical values from bivariate normal distribution (please see the function below).
m <- 10 rho <- 0.1 k <- 2 alpha <- 0.05 ## calculate critical constants cc_z <- numeric(m) var <- matrix(c(1,rho,rho,1), nrow=2, ncol=2, byrow=T) for (i in 1:m){ if (i <= k) {cc_z[i] <- qmvnorm((k*(k-1))/(m*(m-1))*alpha, tail="upper", sigma=var)$quantile} else {cc_z[i] <- qmvnorm((k*(k-1))/((m-i+k)*(m-i+k-1))*alpha, tail="upper", sigma=var)$quantile} } After the critical constants cc_z is calculated, I wanted to check whether they are correct. > ##check whether cc_z is correct > pmvnorm(lower=c(cc_z[1], cc_z[1]), upper=Inf,sigma=var)-(k*(k-1))/(n*(n-1)) [1] 0.001111025 attr(,"error") [1] 1e-15 attr(,"msg") [1] "Normal Completion" > pmvnorm(lower=c(cc_z[3], cc_z[3]), upper=Inf,sigma=var)-(k*(k-1))/((n-1)*(n-2)) [1] 0.001388974 attr(,"error") [1] 1e-15 attr(,"msg") [1] "Normal Completion" As you can see, there is some error. Supposedly, the answer should be zero for all cc_z[i] in the above checking function. Is there something wrong with my code? Can someone give some help? Thank you very much! Hannah [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.