Displaying 20 results from an estimated 6000 matches similar to: "prcomp & princomp - revised"
1998 Apr 24
1
Warning: ignored non function "scale"
I've been working on a revised version of prcomp and princomp. Below is my
current draft of prcomp, which is marginally different from V&R. I've added
center and scale as optional arguments. However, scale causes the following:
> zi _ prcomp(iris[,,2])
Warning: ignored non function "scale"
because scale is both a variable and a function. Is there any way to avoid this
2010 Nov 10
2
prcomp function
Hello,
I have a short question about the prcomp function. First I cite the
associated help page (help(prcomp)):
"Value:
...
SDEV the standard deviations of the principal components (i.e., the square
roots of the eigenvalues of the covariance/correlation matrix, though the
calculation is actually done with the singular values of the data matrix).
ROTATION the matrix of variable loadings
1998 Aug 21
2
couldn't find FUN
The call to sweep in this function which was working in 0.62.2 is giving me
trouble in 62.3:
prcomponents <- function(x, center=TRUE, scale=TRUE, N=nrow(x)-1)
{if (center) center <- apply(x,2,mean)
else center <- rep(0, ncol(x))
if (scale) scale <- sqrt(apply(x,2,var))
else scale <- rep(1, ncol(x))
s <- svd(sweep(sweep(x,2, center),2, scale,
2005 Sep 16
1
About princomp
Hi,
I run the example for princomp for R211
I got the following error for biplot
> ## The variances of the variables in the
> ## USArrests data vary by orders of magnitude, so scaling is appropriate
> (pc.cr <http://pc.cr> <- princomp(USArrests)) # inappropriate
Erreur dans cov.wt(z) : 'x' must contain finite values only
> princomp(USArrests, cor = TRUE) # =^=
2009 Nov 25
1
which to trust...princomp() or prcomp() or neither?
According to R help:
princomp() uses eigenvalues of covariance data.
prcomp() uses the SVD method.
yet when I run the (eg., USArrests) data example and compare with my own
"hand-written" versions of PCA I get what looks like the opposite.
Example:
comparing the variances I see:
Using prcomp(USArrests)
-------------------------------------
Standard deviations:
[1] 83.732400 14.212402
2002 Oct 29
0
patch to mva:prcomp to use La.svd instead of svd (PR#2227)
Per the discussion about the problems with prcomp() when n << p, which
boils down to a problem with svd() when n << p,
here is a patch to prcomp() which substitutes La.svd() instead of svd().
-Greg
(This is really a feature enhancement, but submitted to R-bugs to make sure
it doesn't get lost. )
*** R-1.6.0/src/library/mva/R/prcomp.R Mon Aug 13 17:41:50 2001
---
2000 Jan 31
1
Feature requests for princomp(.) : Allow cor() specifications
(all in subject).
If I want to do a PC analysis in a situation with missing data,
I may want to have same flexibility as with "cor(.)",
e.g., I may want
princomp(x, ..., use.obs = "pairwise.complete")
Actually, I may want even more flexibility.
Currently,
princomp(.)
has
if (cor)
cv <- get("cor", envir = .GlobalEnv)(z)
else cv <-
2000 Sep 29
2
non-ideal behavior in princomp/ not a feature but a bug
... I checked and Brian and I are both right (see bottom for prior mail
exchange).
Let me explain:
=============================================================
1. Indeed, in principle, princomp allows data matrices with are wider than
high.
Example:
> x1
[,1] [,2] [,3] [,4]
[1,] 1 1 2 2
[2,] 1 1 2 2
> princomp(x1)
Call:
princomp(x = x1)
Standard deviations:
2000 Sep 29
2
non-ideal behavior in princomp/ not a feature but a bug
... I checked and Brian and I are both right (see bottom for prior mail
exchange).
Let me explain:
=============================================================
1. Indeed, in principle, princomp allows data matrices with are wider than
high.
Example:
> x1
[,1] [,2] [,3] [,4]
[1,] 1 1 2 2
[2,] 1 1 2 2
> princomp(x1)
Call:
princomp(x = x1)
Standard deviations:
2009 Jan 14
1
Adressing list-elements
Dear all,
I'm using R 2.8.1 under Vista.
I programmed a Simulation with the code enclosed at the end of the eMail.
After the simulation I want to analyse the columns of the single
simulation-runs, i.e. e.g. Simulation[[1]][,1] sth. like that but I
cannot address these columns...
Can anybody please help?
Best,
Thomas
############################ CODE ############################
2007 Mar 02
2
Wishlist: Make screeplot() a generic (PR#9541)
Full_Name: Gavin Simpson
Version: 2.5.0
OS: Linux (FC5)
Submission from: (NULL) (128.40.33.76)
Screeplots are a common plot-type used to interpret the results of various
ordination methods and other techniques. A number of packages include ordination
techniques not included in a standard R installation. screeplot() works for
princomp and prcomp objects, but not for these other techniques as it
2000 Apr 26
1
Factor Rotation
How does one rotate the loadings from a principal component analysis?
Help on function prcomp() from package mva mentions rotation:
Arguments
retx a logical value indicating whether the rotated
variables should be returned.
Values
rotation the matrix of variable loadings (i.e., a matrix
whose olumns contain the eigenvectors). The
function princomp returns this in the element
2010 May 15
2
Attempt to customise the "plotpc()" function
Dear R-list,
Among the (R-)tools, I've seen on the net, for (bivariate) Principal Component
scatter plots (+histograms), "plotpc" [1] is the one I like most.
By default it performs PCA on a bivariate dataset based on R's "princomp()"
(which is the eigenvector-based algebraic solution to PCA). I would like to
modify "plotpc()" in order be able, as an
2004 Nov 03
2
Princomp(), prcomp() and loadings()
In comparing the results of princomp and prcomp I find:
1. The reported standard deviations are similar but about 1% from
each other, which seems well above round-off error.
2. princomp returns what I understand are variances and cumulative
variances accounted for by each principal component which are
all equal. "SS loadings" is always 1.
3. Same happens
2010 May 31
0
Documentation of biplot for princomp
Hi,
I think that the documentation for the biplot function `biplot.princomp' is
inconsistent with what it actually does. Here is what the documentation
states:
pc.biplot
If true, use what Gabriel (1971) refers to as a "principal component
biplot", with lambda = 1 and observations scaled up by sqrt(n) and variables
scaled down by sqrt(n). Then inner products between
2011 Jun 30
2
sdev value returned by princomp function (used for PCA)
Dear all,
I have a question about the 'sdev' value returned by the princomp function (which does principal components analysis).
On the help page for princomp it says 'sdev' is 'the standard deviations of the principal components'.
However, when I calculate the principal components for the USArrests data set, I don't find this to be the case:
Here is how I
2005 Mar 24
0
Mapping actual to expected columns for princomp object
I am working with data sets in which the number and order of columns
may vary, but each column is uniquely identified by its name. E.g.,
one data set might have columns
MW logP Num_Rings Num_H_Donors
while another has columns
Num_Rings Num_Atoms Num_H_Donors logP MW
I would like to be able to perform a principal component analysis (PCA)
on one data set and save the PCA object to
2005 Mar 24
1
RE: [R] Mapping actual to expected columns for princomp object
[Re-directing to R-devel, as I think this needs changes to the code.]
Can I suggest a modification to stats:predict.princomp so that it will check
for column (variable) names?
In src/library/stats/R/princomp-add.R, insert the following after line 4:
if (!is.null(cn <- names(object$center))) newdata <- newdata[, cn]
Now Dana's example looks like:
> predict(pca1, frz)
Error in
2008 Sep 17
1
rgl: plot3d and ellipse3d
Hi
I'm trying to make a 3d plot showing a point cloud, the corresponding
data ellipse
and the principal axes of the ellipse as vectors.
library(rgl)
data(trees)
cov <- cov(trees)
mu <- mean(trees)
plot3d(trees, type="s", size=0.5, col="blue", cex=2)
In this step, an extra box is added. I've tried using box=FALSE, but it
has no effect.
# how to avoid the
2009 Oct 19
2
What is the difference between prcomp and princomp?
Some webpage has described prcomp and princomp, but I am still not
quite sure what the major difference between them is. Can they be used
interchangeably?
In help, it says
'princomp' only handles so-called R-mode PCA, that is feature
extraction of variables. If a data matrix is supplied (possibly
via a formula) it is required that there are at least as many
units as