How to fit a PLS function with an intercept?

1 view (last 30 days)
gsourop
gsourop on 29 Jan 2021
Dear all,
I am using the plsregress function to derive the betas. I want to test a different number of components to see which number fits the model best based on the BIC or another criterion (rather than using the default mse). I would like to use an intercept within my specifications. However, I am not sure if the following is correct
T =100;
x = [ones(T,1) randn(T,10)];
y = randn(T,1);
for k = 1 :11
[xl, yl,xs,ys,betapls] = plsregress(x,y,k);
beta_k(k,:) = betapls;
xfitted = xs(:,1:k) * xl(:,1:k)';
yfitted = xs(:,1:k) * yl(:,1:k)';
xresiduals = x - xfitted;
yresiduals = y - yfitted;
N=k+1;
BICCriterionY(k)=log(yresiduals'*yresiduals/T)+N*log(T)/T;
end
[minBIC,k_star]=min(BICCriterionY);
Is the above correct or do I also need to calculate the criterion for the intercept differently? Should I also calculate the BIC for xfitted as well? If yes, I am not quite sure how to do it.
Thank you in advance.

Answers (0)

Categories

Find more on Chemistry 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!