How do you format the function 'pcrsse' required for crossval?

4 Ansichten (letzte 30 Tage)
David
David am 13 Aug. 2012
Hi,
I am working through the demo file provided in the Mathworks help file for the statistical toolbox, specifically the section on Partial Least Squares Regression and Principal Components Regression. I have reached the part discussing cross validation as a method to determine the necessary number of principle components.
The instructions say it is necessary to calculate the mean squared prediction error (MSEP) for the principle component regression (PCR) using the function 'crossval.' In order to do this, you must make a function to determine the sum of squared error for PCR, but they do not give the code for this function only the name 'pcrsse.' However, inserting a function into crossval requires tricky formatting, and I have tried
pcrsse = @(yfit, y)((yfit-y).^2)
but it has not worked. I have also tried to follow the help file on 'crossval' with no success. Will someone please look at this example in the help file and help me develop this 'pcrsse' function? Many thanks.
David

Antworten (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by