Displaying 20 results from an estimated 1200 matches similar to: "Streamlining Prcomp Data"
2010 Jun 16
2
Accessing the elements of summary(prcomp(USArrests))
Hello again,
I was hoping one of you could help me with this problem. Consider the sample data from R:
> summary(prcomp(USArrests))
Importance of components:
PC1 PC2 PC3 PC4
Standard deviation 83.732 14.2124 6.4894 2.48279
Proportion of Variance 0.966 0.0278 0.0058 0.00085
Cumulative Proportion 0.966 0.9933 0.9991 1.00000
How do I access the
2000 Oct 03
3
prcomp compared to SPAD
Hi !
I've used the example given in the documentation for the prcomp function
both in R and SPAD to compare the results obtained.
Surprisingly, I do not obtain the same results for the coordinates of
the principal composantes with these two softwares.
using USArrests data I obtain with R :
> summary(prcomp(USArrests))
Importance of components:
PC1 PC2
2009 Dec 23
1
prcomp : plotting only explanatory axis arrows
Dear all,
I have a very large dataset (1712351 , 20) and would like
to plot only the arrows that represent the
contribution of each variables.
On the sample below I woild like to plot
only the explanatory variables (Murder, Assault..)
and not the sites.
prcomp(USArrests) # inappropriate
prcomp(USArrests, scale = TRUE)
prcomp(~ Murder + Assault + Rape, data = USArrests, scale = TRUE)
2013 Mar 14
2
Same eigenvalues but different eigenvectors using 'prcomp' and 'principal' commands
Dear all,
I've used the 'prcomp' command to
calculate the eigenvalues and eigenvectors of a matrix(gg).
Using the command 'principal' from the
'psych' packageĀ I've performed the same exercise. I got the same
eigenvalues but different eigenvectors. Is there any reason for that
difference?
Below are the steps I've followed:
1. PRCOMP
#defining the matrix
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
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
2008 Nov 03
1
Input correlation matrix directly to princomp, prcomp
Hello fellow Rers,
I have a no-doubt simple question which is turning into a headache so
would be grateful for any help.
I want to do a principal components analysis directly on a correlation
matrix object rather than inputting the raw data (and specifying cor =
TRUE or the like). The reason behind this is I need to use polychoric
correlation coefficients calculated with John Fox's
2012 May 23
1
prcomp with previously scaled data: predict with 'newdata' wrong
Hello folks,
it may be regarded as a user error to scale() your data prior to prcomp() instead of using its 'scale.' argument. However, it is a user thing that may happen and sounds a legitimate thing to do, but in that case predict() with 'newdata' can give wrong results:
x <- scale(USArrests)
sol <- prcomp(x)
all.equal(predict(sol), predict(sol, newdata=x))
## [1]
2011 Sep 09
2
prcomp: results with reversed sign in output?
Dear All,
when I'm running a PCA with
prcomp(USArrests, scale = TRUE)
I get the right principal components, but with the wrong sign infront
Rotation:
PC1 PC2 PC3 PC4
Murder 0.5358995 -0.4181809 0.3412327 0.64922780
Assault 0.5831836 -0.1879856 0.2681484 -0.74340748
UrbanPop 0.2781909 0.8728062 0.3780158 0.13387773
Rape 0.5434321 0.1673186 -0.8177779 0.08902432
instead of
PC1 PC2 PC3 PC4
2011 Aug 14
1
PCA Using prcomp()
Hey guys,
I am new to R and apologize for the basic question - I do not mean to
offend.
I have been using R to perform PCA on a set several hundred objects using a
set of 30 descriptors. From the results generated by prcomp(), is there a
way to print a matrix showing the contributions of the original variables to
each PC? My hope is to identify which of the original 30 variables are the
most
2004 Nov 09
1
PCA prcomp problem
I've just starting using the prcomp function, and I want to be able to extract
individual principal components (e.g. PC1, PC2) in vector format. I haven't
been able to find any documentation that explains how to do this (or even if it
is possible). Any help on the subject would be greatly appreciated.
Many thanks
Deirdre Toher
Teagasc National Food Centre
2007 Dec 18
9
Scatterplot Showing All Points
Hello all,
I'm trying to graph a scatterplot of a large (5,000 x,y coordinates) of data
with the caveat that many of the data points overlap with each other (share the
same x AND y coordinates). In using the usual "plot" command,
> plot(education, xlab="etc", ylab="etc")
it seems that the overlap of points is not shown in the graph. Namely, there
are
2007 Dec 12
4
Importing Large Dataset into Excel
Hello all,
I seem to be having a problem importing a data set from Excel into R. I'm using
the "read.table" command to import the data with the following line of code:
> newborn<-read.table("newborn edit.csv", header=T, sep=",")
where "newborn edit.csv" is the name of the file. Unfortunately, I'm getting
back the following error message:
2008 Feb 10
1
prcomp vs. princomp vs fast.prcomp
Hi R People:
When performing PCA, should I use prcomp, princomp or fast.prcomp, please?
thanks.
Erin
--
Erin Hodgess
Associate Professor
Department of Computer and Mathematical Sciences
University of Houston - Downtown
mailto: erinm.hodgess at gmail.com
2013 Jan 23
0
na.omit option in prcomp: formula interface only
Dear r-devel list, dear Ben
I came across a post of Ben Bolker from Feb 2012 (see below) on handling NA
values in prcomp(). As I faced the same issue and found Ben's suggestions
interesting, I was wondering whether this led to further discussions I
might have missed? I understand handling NA values is far from trivial, but
would it be possible to add a warning in the documentation, and/or
2006 Jun 16
2
bug in prcomp (PR#8994)
The following seems to be an bug in prcomp():
> test <- ts( matrix( c(NA, 2:5, NA, 7:10), 5, 2))
> test
Time Series:
Start = 1
End = 5
Frequency = 1
Series 1 Series 2
1 NA NA
2 2 7
3 3 8
4 4 9
5 5 10
> prcomp(test, scale.=TRUE, na.action=na.omit)
Erro en svd(x, nu = 0) : infinite or missing values in 'x'
2004 Jan 15
2
prcomp scale error (PR#6433)
Full_Name: Ryszard Czerminski
Version: 1.8.1
OS: GNU/Linux
Submission from: (NULL) (205.181.102.120)
prcomp(..., scale = TRUE) does not work correctly:
$ uname -a
Linux 2.4.20-28.9bigmem #1 SMP Thu Dec 18 13:27:33 EST 2003 i686 i686 i386
GNU/Linux
$ gcc --version
gcc (GCC) 3.2.2 20030222 (Red Hat Linux 3.2.2-5)
> a <- matrix(rnorm(6), nrow = 3)
> sum((scale(a %*% svd(cov(a))$u, scale
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
2012 Feb 09
0
na.omit option in prcomp: formula interface only
This is a wishlist/request for discussion about the behaviour of the
na.action option in prcomp, specifically the fact that it only applies
to the formula interface.
I had a question from a friend (who is smart and careful and
generally R's TFM, although like all of us he misses things sometimes)
asking why the na.action= argument didn't seem to be doing anything in
prcomp (i.e. one
2008 May 18
1
predict.prcomp: 'newdata' does not have the correct number of columns
Hi,
I'm doing PCA on wide matrices and I don't understand why calling
predict.prcomp on it throws an error:
> x1 <- matrix(rnorm(100), 5, 20)
> x2 <- matrix(rnorm(100), 5, 20)
> p <- prcomp(x1)
> predict(p, x2)
Error in predict.prcomp(p, x2) :
'newdata' does not have the correct number of columns
> dim(x2)
[1] 5 20
> dim(p$rotation)
[1] 20 5