-1

I´m using the plsr package in R, with the SIMPLS method, but this didn´t give me the weight matrix W, somebody can help me, and tell me how to create or get this W matrix ? This is part of my code:

plsr(Y ~ X, ncomp, validation = "CV", dframe = T, method = "SIMPLS")

I need the W matrix to implement a VIP method.

akrun
  • 874,273
  • 37
  • 540
  • 662
  • please provide us with the data (i.e. what is ``T`` ?) Also explain the problem more thoroughly. "but this didn´t give me the weight matrix W" -is the command ``plsr`` suppose to return a W matrix? If it is and its not returning it, then are you getting a warning message or an error? – Cyrus Mohammadian Aug 30 '16 at 06:51
  • Also, just in passing -``dframe`` looks odd to me as does the capital letters for ``method=SIMPLS``, instead try, ``plsr(Y ~ X, ncomp, validation = "CV", data = T, method = "simpls")`` – Cyrus Mohammadian Aug 30 '16 at 06:59
  • `T = TRUE`. In fact code runs well, in Matlab `plsregress` (package) returns a W matrix (weight matrix), but in R, `plsr` doesn´t have this option, I need an alternative to get the W matrix. This is the matlab implementation [link](http://www.mathworks.com/help/stats/plsregress.html?requestedDomain=www.mathworks.com) – Erick Coronado Aug 30 '16 at 07:35
  • well what is it a weights matrix of? also i tried the code and it returns an errror unless lowercase simpls is used – Cyrus Mohammadian Aug 30 '16 at 07:41
  • You are right, it's in lowercase, I do transcript wrong, but that´s not the problem, Thnx – Erick Coronado Aug 30 '16 at 08:04
  • Unfortunately isn't the answer, I had to use Matlab. – Erick Coronado Sep 20 '16 at 01:24
  • What is wrong with the code below? – Cyrus Mohammadian Sep 20 '16 at 01:24

1 Answers1

0
library(pls) #only for preloaded data
library(plsdepot)
plsreg1(yarn$NIR, yarn$density) #using preloaded yarn dataset from pls library

PLS Regression 1
--------------------------------------------
$x.scores     X-scores (T-components)
$x.loads      X-loadings
$y.scores     Y-scores (U-components)
$y.loads      Y-loadings
$cor.xyt      score correlations
$raw.wgs      raw weights
$mod.wgs      modified weights
$std.coefs    standard coefficients
$reg.coefs    regular coefficients
$R2           R-squared
$R2Xy         explained variance of X-y by T
$y.pred       y-predicted
$resid        residuals
$T2           T2 hotelling
$Q2           Q2 cross validation
--------------------------------------------

We can access the raw weights via:

#Example of first 5 rows of weights matrix.
head(plsreg1(yarn$NIR, yarn$density)$raw.wgs #or plsreg1(yarn$NIR, yarn$density)[6]

     w1          w2
X1 0.01716477 -0.04809644
X2 0.03875600 -0.06025352
X3 0.04857839 -0.06807797
X4 0.05023674 -0.07540982
X5 0.04571729 -0.08515648
X6 0.03690089 -0.09647263

Same goes for the $mod.wgs modified weights

Cyrus Mohammadian
  • 4,982
  • 6
  • 33
  • 62