In R I have the following matrix (each row represents a bootstrap 95% confidence interval generated from the same sample data):
low high
[1,] 22.2 25.5
[2,] 23.1 25.9
[3,] 23.4 26.1
...
I know the true population mean of the data, it’s 23.3. So the first two include the true mean but the third does not.
In R, I want to run a for loop i through nrow(matrix) times, each i checking whether or not the true population mean of the data is in that particular interval, then return a column vector of height nrow(matrix) of TRUE if the interval contains the true mean, and FALSE otherwise.
How could I do this?
You can simply use the inequality operators directly on the matrix columns. So I would have simply done: