I have a time series of X and Y variables and I want to run a linear regression on it based on a specific time window length. This ends up giving me a time series of regression coefficients. My current implmentation using a loop to picking out data and running a regression on it. How can I vectorize this piece of code?
window_length = 10;regression_coeff = [];for i =1:length(X) - window_length regression_coeff = [regression_coeff; regress(Y(i:i+window_length ),X(i:i+window_length )];end
Best Answer