I have a code that i use to generate balanced incomplete block design in R. We have value of trt as 14 and k as 4 which are fixed. However we change value of b in the find.bib() function to generate a design and check if that design is balanced incomplete block design using isGYD() function.
bibd <- find.BIB(trt = 14, k = 4, b = 64)
bibd
isGYD(bibd)
The problem is i have to do this multiple times and may be hundreds of times until we get confirmation from isGYD function that this design is a balanced incomplete block design. We do this task manually!
My question is can we automate this with a combination of for loop and If Then condition? my algorithm is, for i =1 to 100, create a block design and then test if that design is balanced incomplete design. If it is, save this design and exit from loop. If it was not balanced incomplete design, continue to next iteration of loop.
# run this 1 to 100 times
for (i in 1:100) {
#create balanced incomplete block design by passing value of i fo b
bibd <- find.BIB(trt = 14, k = 4, b = i)
#check if this design is a balanced incomplete block design
if (isGYD(bibd)) {
#save this design and exit loop
}
#if this iteration didn't give us balanced incomplete block design, take us to next iteration
}
Any help?