Plotting PLS Package Object

21 views Asked by At

The code below produces a plot where the labels do not change with the change in data (one principal component to another).

library(pls)  
library(mtcars)

set.seed(1)

model <- plsr(hp~mpg+disp+drat+wt+qsec, data=mtcars, scale = TRUE, validation="CV") 

summary(model) 

pls_compoent_number <- 3   
plot(x=sort(model$loadings[,pls_component_number]),
     y=index(sort(model$loadings[,pls_component_number])),type="p",yaxt='n',xlab="PC Loadings",ylab="")  
axis(2,at=index(sort(model$loadings[,pls_component_number])),
     labels = names(sort(model$loadings[,pls_component_number])),las=2,cex.axis=1)    

head(sort(model$loadings[,pls_component_number]))  
head(names(sort(model$loadings[,pls_component_number])))

I was expecting the labels from the pls object component to match the points on the graph from the pls object component. The graph doesn't match up with the data input to plot as shown by the head statements.

0

There are 0 answers