Learn R Programming

textir (version 1.8-5)

pls: Partial Least Squares

Description

A simple partial least squares procedure.

Usage

pls(X, y, K=1, scale=TRUE, verb=TRUE)

Arguments

X
The covariate matrix, in either simple_triplet_matrix or matrix format.
y
The response vector.
K
The number of desired PLS directions.
scale
An indicator for whether to standardize X; usually a good idea. If scale=TRUE, X will be scaled to have variance-one columns.
verb
Whether or not to print a small progress script.

Value

  • A pls object list with the following entries
  • yThe response vector.
  • XThe covariate matrix. If scale=TRUE, scaled to have variance-one columns.
  • directionsThe pls directions X%*%loadings.
  • factorsResponse factors.
  • phiThe pls loadings.
  • fittedK columns of fitted y values for each number of directions.
  • fwdmodThe lm object from forward regression lm(as.numeric(y)~directions).
  • scaleIf scale=TRUE on input, the standard deviations used to scale X.

Details

Fits the Partial Least Squares algorithm described in Taddy (2011; Section 3.1). In particular, we obtain loadings loadings[,k] as the correlation between X and factors factors[,k], where factors[,1] is initialized at normalize(as.numeric(y)) and subsequent factors are orthogonal to the k'th pls direction, directions[,k]=X%*%loadings[,k].

References

Taddy (2011), Inverse Regression for Analysis of Sentiment in Text. http://arxiv.org/abs/1012.2098

Wold, H. (1975), Soft modeling by latent variables: The nonlinear iterative partial least squares approach. In Perspectives in Probability and Statistics, Papers in Honour of M.S. Bartlett.

See Also

plot.pls, normalize, freq, corr, we8there, congress109

Examples

Run this code
data(congress109)
summary( fit <- pls(freq(congress109Counts), congress109Ideology$repshare, K=3) )
plot(fit, pch=21, bg=c(4,3,2)[congress109Ideology$party])
predict(fit, newdata=freq(congress109Counts[c(68,388),]))

data(we8there)
summary( fit <- pls(freq(we8thereCounts),as.factor(we8thereRatings$Overall)) )
plot(fit, col=c(2,2,2,3,3))

Run the code above in your browser using DataLab