Rolling Window PCA- Save Explained factors for every period
Afficher commentaires plus anciens
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.
Réponses (1)
the cyclist
le 19 Déc 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 commentaires
meral serçe
le 19 Déc 2015
the cyclist
le 19 Déc 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
le 21 Déc 2015
the cyclist
le 24 Déc 2015
Insert a line like this in the loop:
rollingWindowX = fullX(nw:nw+20,:)
and do the PCA on rollingWindowX.
Catégories
En savoir plus sur Dimensionality Reduction and Feature Extraction dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!