# [R] Question about PLS regression

Andris Jankevics andza at osi.lv
Tue Apr 18 17:05:51 CEST 2006

```I am sorry. It was my fault. My example is wrong. I need also rearrange a
validation data set too.
But I have a sligthy different results with my real data. Where can the
problem be?

Andris Jankevics

On Otrdiena, 18. Aprīlis 2006 17:55, Andris Jankevics wrote:
> Hello useRs,
>
> I am new user to R and also statistics. Why predicted results in this
> example are different? Is the order of variables in X matrix important?
>
> library (pls)
> set.seed (1)
> Y1 <- c(1,2,3,4,5,6,7,8,9,10)
> Y2 <- c(0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0)
> X1 <- rnorm(10,sd=0.2)
> X2 <- rnorm(10,sd=1)
> X3 <- rnorm(10,sd=0.1)
> X4 <- rnorm(10,sd=0.1)
> X5 <- rnorm(10,sd=0.1)
>
> KAL <- data.frame(num=c(1:10))
> KAL\$Y <- as.matrix(cbind (Y1,Y2))
> KAL\$X <- as.matrix(cbind (X1,X2,X3,X4,X5))
> KAL2 <- data.frame(num=c(1:10))
> KAL2\$Y <- as.matrix(cbind (Y1,Y2))
> KAL2\$X <- as.matrix(cbind (X5,X4,X3,X2,X1))
>
> PLS <- plsr (Y~X,data=KAL, 4,validation = "CV")
> PLS2 <- plsr (Y~X,data=KAL2,4, validation = "CV")
>
> X1v <- rnorm(10,sd=0.1)
> X2v <- rnorm(10,sd=1)
> X3v <- rnorm(10,sd=0.1)
> X4v <- rnorm(10,sd=0.1)
> X5v <- rnorm(10,sd=0.1)
> VAL <- data.frame(num=c(1:10))
> VAL\$X <- as.matrix(cbind(X1v,X2v,X3v,X4v,X5v))
>
> predict (PLS,VAL,4)
> predict (PLS2,VAL,4)
>
> Thank You,
>
> Andris Jankevics
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help