2013년 8월 17일 토요일

partial least squares regression(PLSR) - R example

Partial least squares regression(PLSR)은 chemometric 분야에서 많이 사용되는 회귀분석 방법으로, 다수의 Y(종속변수)를 예측하고자 하는 경우, 변수(variable)의 갯수가 관측치(observation)의 갯수보다 많은 경우, X(독립변수)들 간에 다중공선성(multicollinearity)이 존재하는 경우에 적합한 분석 방법이다.

다중 선형 회귀(Multiple linear regression, MLR)는 X들 간에 다중공선성이 존재하는 경우 정확한 회귀모수의 추정이 어렵기 때문에 적용하기 어렵다. 이 경우 능형회귀(ridge regression), 주성분 회귀(principal component regression, PCR), 그리고 PLSR을 이용하여 분석할 수 있다.


간단히 PLSR을 도식화 하면 다음과 같이 표현할 수 있다.

X : 독립변수 행렬(n x m)
Y : 종속변수 행렬(n x p)
T : X의 요인(factor) 행렬(n x l)
U : Y의 요인(factor) 행렬(n x l)
P : X의 요인 적재값(factor loading) 행렬(m x l)
Q : Y의 요인 적재값(factor loading) 행렬(p x l)
E, F : 오차항(error term)
       ~ iid(independent and identically distributed)

즉, PLSR은 공분산(covariance)이 최대가되는 X의 선형결합과 Y의 선형결합을 찾는 방법론이다.



[R example]
library(pls)

data(gasoline)


# Figure 1. NIR spectra

wavelengths <- seq(900, 1700, by=2)
matplot(wavelengths, t(gasoline$NIR), type="l", lty=1,
    xlab="wavelengths(nm)", ylab="log(1/R)")

# gasoline 데이터로 PLSR 분석
# 성분 수: 10
# leave-one-out(LOO) cross validated prediction
gas1 <- plsr(octane ~ NIR, ncomp = 10, data = gasoline,
    validation = "LOO")

# 분석 결과 요약
summary(gas1)

# Cross-validated RMSEP curves
plot(RMSEP(gas1), legendpos = "topright")

# Cross-validated predictions with 3 components vs. measured
plot(gas1, ncomp = 3, asp = 1, line = TRUE)

# Loading plot
plot(gas1, "loadings", comps = 1:3, legendpos = "topleft")
abline(h = 0)


참고자료
YouTube - Partial Least Squares Regression 1 Introduction
R News Volume 6/3, August 2006 - The pls package

댓글 없음:

댓글 쓰기