for (i in 1:(p-1)) {
Y<- rbind(Y, yy[,(p-i):(t-i)])
}
With this code, I am able to get the same 96 by 432 Y matrix in RStudio.
The matrix y in the above MATLAB code should be yy in my RStudio environment. I was indexing/accessing the wrong matrix in my previous RStudio code. My sincere apologies for the earlier mistake. For my own learning and understanding, would you please explain why putting parentheses in the for loop of the RStudio code worked? Many thanks.
First thing, no apologies due. We all do this sort of thing all the time. Human brains see what they think is there instead of what's actually there much too often.
In Matlab, the minus sign is applied before the colon. In R, that isn't true. Hence the need for parentheses.