How can I test PCR model?
3 views (last 30 days)
Show older comments
I'm new to modeling principle component regression. I used MATLAB documentation to see an example on how to do it using the built-in functions. I just want to know how to test the model to try other examples than the training set.
This is the piece of code I want to investigate:
[PCALoadings,PCAScores,PCAVar] = princomp(X); %,'Economy',false);
betaPCR = regress(y-mean(y), PCAScores(:,1:2));
betaPCR = PCALoadings(:,1:2)*betaPCR;
betaPCR = [mean(y) - mean(X)*betaPCR; betaPCR];
yfitPCR = [ones(n,1) X]*betaPCR;
I think X should be the X that I want to test. The question is, what is 'y' here? This y I don't know, I actually want to predict it. Thanks!
0 Comments
Answers (0)
See Also
Categories
Find more on Dimensionality Reduction and Feature Extraction in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!