I'm trying to create a matrix using a for loop, simple but not working so far .... I'm starting now with R.
n = 17
M is a matrix containing kendall tau-b values, ncol = 10 nrows = 1.
n <- length(plot[,2]);
z1a <- 1.96;
M1=matrix(data=NA, ncol= 10, nrow = 2);
for (i in M[,1:10]){
#print(i)
zr <- (1/2)*log((1+i)/(1-i));
SE <- sqrt(0.437/(n-4));
zU <- zr+z1a*SE;
zL <- zr-z1a*SE;
rL <- (exp(2*zL)-1)/(exp(2*zL)+1);
rU <- (exp(2*zU)-1)/(exp(2*zU)+1);
#print(rL)
#print(rU)
M1 [1,1:10] <- (exp(2*zL)-1)/(exp(2*zL)+1);
M1 [2,1:10] <- (exp(2*zU)-1)/(exp(2*zU)+1);
}
The last line of code is just to understand how I want to fill matrix. How can i solve the issue?
I'm not sure if I understand the question. Is this what you are looking for? I have initiated M as a random uniform number from 0 to 1
z1a <- 1.96;
n <- 17
set.seed(1)
M = runif(10)
M1 = matrix(data = NA, ncol = 10, nrow = 2);
zr <- (1/2)*log((1+M)/(1-M));
SE <- sqrt(0.437/(n-4));
zU <- zr+z1a*SE;
zL <- zr-z1a*SE;
rL <- (exp(2*zL)-1)/(exp(2*zL)+1);
rU <- (exp(2*zU)-1)/(exp(2*zU)+1);
M1 [1,1:10] <- (exp(2*zL)-1)/(exp(2*zL)+1);
M1 [2,1:10] <- (exp(2*zU)-1)/(exp(2*zU)+1);