iwpca.matrix(aroma.light)
iwpca.matrix()所属R语言包:aroma.light
Fits an R-dimensional hyperplane using iterative re-weighted PCA
适合一个R-维超平面,使用迭代重加权主成分分析
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Fits an R-dimensional hyperplane using iterative re-weighted PCA.
适合使用迭代重加权PCA的一个R-维超平面。
用法----------Usage----------
参数----------Arguments----------
参数:X
N-times-K matrix where N is the number of observations and K is the number of dimensions.
N次 - Kmatrix其中N是一些意见和K的维数。
参数:w
An N vector of weights for each row (observation) in the data matrix. If NULL, all observations get the same weight.
一个Nvector数据矩阵中的每一行(观察)的重量。如果NULL,所有的意见得到了相同的重量。
参数:R
Number of principal components to fit. By default a line is fitted.
数量的主要组成部分,以适应。默认情况下安装线。
参数:method
If "symmetric" (or "bisquare"), Tukey's biweight is used. If "tricube", the tricube weight is used. If "L1", the model is fitted in L_1. If a function, it is used to calculate weights for next iteration based on the current iteration's residuals.
如果"symmetric"(或"bisquare"),Tukey的biweight正在使用。如果"tricube"中,tricube重量使用。如果"L1",模型安装在L_1。如果function,它被用来计算下一次迭代的权重,根据当前迭代的残差。
参数:maxIter
Maximum number of iterations.
最大迭代次数。
参数:acc
The (Euclidean) distance between two subsequent parameters fit for which the algorithm is considered to have converged.
随后的两个参数之间的(欧几里德)距离为适应算法被认为有融合。
参数:reps
Small value to be added to the residuals before the the weights are calculated based on their inverse. This is to avoid infinite weights.
小值被添加到前的重量计算其反残差。这是为了避免无限的重量。
参数:fit0
A list containing elements vt and pc specifying an initial fit. If NULL, the initial guess will be equal to the (weighted) PCA fit.
一个list包含的元素vt和pc指定一个初始的契合。如果NULL,初始猜测将等于(加权)PCA的契合。
参数:...
Additional arguments accepted by *wpca().
*wpca()接受额外的参数。
Details
详情----------Details----------
This method uses weighted principal component analysis (WPCA) to fit a R-dimensional hyperplane through the data with initial internal weights all equal. At each iteration the internal weights are recalculated based on the "residuals". If method=="L1", the internal weights are 1 / sum(abs(r) + reps). This is the same as method=function(r) 1/sum(abs(r)+reps). The "residuals" are orthogonal Euclidean distance of the principal components R,R+1,...,K. In each iteration before doing WPCA, the internal weighted are multiplied by the weights given by argument w, if specified.
这种方法采用加权主成分分析(WPCA)适合通过一个R-维超平面的数据与最初的人人平等的内部砝码。在每一次迭代的内部重新计算权重的基础上的“残差”。如果method=="L1",内部重量的1 / SUM(ABS(R)+销售代表)。这是相同的method=function(r) 1/sum(abs(r)+reps)。 “残差”是正交的主要组成部分欧几里德距离R,R +1,...,K。在每次迭代之前做WPCA,内部参数给出的权重乘以加权w,如果指定。
值----------Value----------
Returns the fit (a list) from the last call to *wpca() with the additional elements nbrOfIterations and converged.
返回从最后一次通话的额外元素list和*wpca()nbrOfIterations(converged)适合。
作者(S)----------Author(s)----------
Henrik Bengtsson (<a href="http://www.braju.com/R/">http://www.braju.com/R/</a>)
参见----------See Also----------
Internally *wpca() is used for calculating the weighted PCA.
国内*wpca()用于计算加权PCA。
举例----------Examples----------
for (zzz in 0) {
# This example requires plot3d() in R.basic [http://www.braju.com/R/][这个例子需要plot3d()R.basic [http://www.braju.com/R/]]
if (!require(R.basic)) break
# Simulate data from the model y <- a + bx + eps(bx)[从模型模拟数据Y < - A + BX + EPS(BX)]
x <- rexp(1000)
a <- c(2,15,3)
b <- c(2,3,4)
bx <- outer(b,x)
eps <- apply(bx, MARGIN=2, FUN=function(x) rnorm(length(x), mean=0, sd=0.1*x))
y <- a + bx + eps
y <- t(y)
# Add some outliers by permuting the dimensions for 1/10 of the observations[加入一些离群置换尺寸为1/10的意见]
idx <- sample(1:nrow(y), size=1/10*nrow(y))
y[idx,] <- y[idx,c(2,3,1)]
# Plot the data with fitted lines at four different view points[绘制在四个不同的观点与数据拟合线]
opar <- par(mar=c(1,1,1,1)+0.1)
N <- 4
layout(matrix(1:N, nrow=2, byrow=TRUE))
theta <- seq(0,270,length=N)
phi <- rep(20, length.out=N)
xlim <- ylim <- zlim <- c(0,45);
persp <- list();
for (kk in seq(theta)) {
# Plot the data[绘制数据]
persp[[kk]] <- plot3d(y, theta=theta[kk], phi=phi[kk], xlim=xlim, ylim=ylim, zlim=zlim)
}
# Weights on the observations[重量上的意见]
# Example a: Equal weights[例如:平等权]
w <- NULL
# Example b: More weight on the outliers (uncomment to test)[例如B:离群的重量(去掉测试)]
w <- rep(1, length(x)); w[idx] <- 0.8
# ...and show all iterations too with different colors.[...显示所有迭代用不同的颜色。]
maxIter <- c(seq(1,20,length=10),Inf)
col <- topo.colors(length(maxIter))
# Show the fitted value for every iteration[显示每次迭代的拟合值]
for (ii in seq(along=maxIter)) {
# Fit a line using IWPCA through data[适合通过数据线使用IWPCA]
fit <- iwpca(y, w=w, maxIter=maxIter[ii], swapDirections=TRUE)
ymid <- fit$xMean
d0 <- apply(y, MARGIN=2, FUN=min) - ymid
d1 <- apply(y, MARGIN=2, FUN=max) - ymid
b <- fit$vt[1,]
y0 <- -b * max(abs(d0))
y1 <- b * max(abs(d1))
yline <- matrix(c(y0,y1), nrow=length(b), ncol=2)
yline <- yline + ymid
for (kk in seq(theta)) {
# Set pane to draw in[设置窗格提请]
par(mfg=c((kk-1) %/% 2, (kk-1) %% 2) + 1);
# Set the viewpoint of the pane[设置窗格的观点]
options(persp.matrix=persp[[kk]]);
# Get the first principal component[得到的第一主成分]
points3d(t(ymid), col=col[ii])
lines3d(t(yline), col=col[ii])
# Highlight the last one[突出的最后一]
if (ii == length(maxIter))
lines3d(t(yline), col="red", lwd=3)
}
}
par(opar)
} # for (zzz in 0)[(0 ZZZ)]
rm(zzz)
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|