Rolling Window PCA- Save Explained factors for every period
Ältere Kommentare anzeigen
I need to do rolling window PCA and I have a rolling window size=20. But I want to save all explained factors for [coeff,scores,explained]=pcacov(X) function in for loop.
What would be the most simple solution?
Thank you very much.
Antworten (1)
the cyclist
am 19 Dez. 2015
One way;
numberOfVars = 100; % Set to however big your data are
numberOfWindows = 10;
explainedArray = zeros(numberOfVars,numberOfRuns);
for nw = 1:numberOfWindows
[coeff,scores,explained]=pcacov(X);
explainedArray(:,nw) = explained;
end
4 Kommentare
meral serçe
am 19 Dez. 2015
the cyclist
am 19 Dez. 2015
I assumed you only needed help with the storage in the for loop, since that is all you asked about.
Just modify this line
[coeff,scores,explained]=pcacov(X);
so that you have the rolling window within X each time. Maybe something like
X = biggerX(<define window in here>,:)
Do you need help in how to define a rolling window?
meral serçe
am 21 Dez. 2015
the cyclist
am 24 Dez. 2015
Insert a line like this in the loop:
rollingWindowX = fullX(nw:nw+20,:)
and do the PCA on rollingWindowX.
Kategorien
Mehr zu Dimensionality Reduction and Feature Extraction finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!