Dear all,
 
I want to calculate AIC values of PLSR models. But I find that AIC and 
extractAIC functions in R could not be used to calculate AIC values of PLSR 
models. Now I write a section of code(below) to calculate it. But I don't known 
whether the result is right or not. If I am wrong, please give me some 
suggestions. Thanks a lot.
 
Rong Huang
 
data<-data.frame(
y=c(-1,-1,-0.9,-0.88,-0.85,-0.41,-0.38,-0.04,0,0.1,0.23,0.3,0.32,
0.42,0.43,0.48,0.77,0.82,0.82,0.89,0.92,1.02,1.03,1.07,1.13,1.36,1.36,1.4,1.41,
1.55,1.84),
X1=c(-0.101,-0.1629,-0.1004,-0.4688,-0.1005,-0.1006,-0.098,-0.1478,-0.5146,
-0.1611,-0.1619,-0.1442,-0.2566,-0.1308,-0.16,-0.1634,-0.1623,-0.1469,-0.148,
-0.1628,-0.161,-0.1618,-0.1619,-0.1612,-0.1603,-0.161,-0.0938,-0.1616,-0.1628,
-0.1611,-0.076),
X2=c(-1.6953,-0.9866,-1.7833,-1.1233,-1.7022,-1.7001,-1.6017,-0.8415,-0.9508,
-0.9389,-1.0148,-0.861,-1.3785,-1.6241,-1.0883,-2.0914,-1.5157,-0.7912,-0.8419,
-0.8149,-0.7935,-0.8606,-0.8699,-0.7949,-0.7832,-0.824,-1.0875,-0.8313,-0.8149,
-0.7949,-1.0338),
X3=c(250.4,307.8,396.2,342.3,380.0,282.8,328.0,405.0,353.6,304.8,280.4,
353.6,328.8,328.8,328.3,216.2,328.5,320.6,372.6,340.2,332.0,321.6,321.6,
336.1,333.8,332.3,387.1,320.6,340.2,354.0,313.8),
X4=c(3.007,3.686,7.23,5.73,7.239,4.06 5,5.96,9.52,5.67,4.888,5.354,5.681,
7.372,7.372,6.811,4.654,6.18,6.994,8.47,8.466,6.113,6.695,6.695,7.269,6.205,
6.838,9.3,6.994,7.408,7.869,6.755),
X5=c(0.25,0.67,0.28,0.52,0.25,0.25,0.25,0.67,0.54,0.67,0.67,0.54,0.2,0.2,
0.67,0.67,0.67,0.67,0.67,0.67,0.67,0.67,0.67,0.67,0.67,0.67,1.08,0.67,0.67,
0.67,0.51)
)
ncomp<-5
model<-plsr(y~ 
.,data=data,ncomp=ncomp,validation="LOO",x="TRUE",y="TRUE",model="TRUE")
y<-model$y
y.hat<-model$fitted.value[,,ncomp]
residuals<-model$residuals[,,ncomp]
sigmaML<-sqrt(mean(residuals^2))
loglik<-sum(dnorm(y,y.hat,sigmaML,log=T))
AIC<--2*loglik+2*(ncomp+1)



      ___________________________________________________________ 
  好玩贺卡等你发,邮箱贺卡全新上线! 

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to