Displaying 20 results from an estimated 10000 matches similar to: "A bug in princomp(), perhaps?"
2007 Dec 18
1
PCA - "cov.wt(z) : 'x' must contain finite values only"
I am trying to run PCA on a matrix (the first column and row are
headers). There are several cells with NA's. When I run PCA with the
following code:
______________________________________
setwd("I:/PCA")
AsianProp<-read.csv("Matrix.csv", sep=",", header=T, row.names=1)
attach(AsianProp)
AsianProp
AsianProp.pca<-princomp(AsianProp, na.omit)
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) # =^=
2003 Jul 15
2
"na.action" parameter in princomp() (PR#3481)
Full_Name: Jerome Asselin
Version: 1.7.1
OS: Red Hat Linux 7.2
Submission from: (NULL) (24.77.125.119)
Setting the parameter na.action=na.omit should remove
incomplete records in princomp. However this does not
seem to work as expected. See example below.
Sincerely,
Jerome Asselin
data(USArrests)
princomp(USArrests, cor = TRUE) #THIS WORKS
USArrests[1,3] <- NA
princomp(USArrests, cor =
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 Dec 24
1
bug in princomp example (PR#14167)
When I run
example(princomp)
I get the following error message:
prncmp> ## The variances of the variables in the
prncmp> ## USArrests data vary by orders of magnitude, so scaling is
appropriate
prncmp> (pc.cr <- princomp(USArrests)) # inappropriate
Error in cov.wt(z) : 'x' must contain finite values only
Seth Roberts
--
blog.sethroberts.net
www.shangriladiet.com
2013 Apr 25
2
Vectorized code for generating the Kac (Clement) matrix
Hi,
I am generating large Kac matrices (also known as Clement matrix). This a tridiagonal matrix. I was wondering whether there is a vectorized solution that avoids the `for' loops to the following code:
n <- 1000
Kacmat <- matrix(0, n+1, n+1)
for (i in 1:n) Kacmat[i, i+1] <- n - i + 1
for (i in 2:(n+1)) Kacmat[i, i-1] <- i-1
The above code is fast, but I am curious about
2013 Mar 20
2
Dealing with missing values in princomp (package "psych")
Hello!
I am running principle components analysis using princomp function in
pacakge psych.
mypc <- princomp(mydataforpc, cor=TRUE)
Question: I'd like to use pairwise deletion of missing cases when
correlations are calculated. I.e., I'd like to have a correlation between
any 2 variables to be based on all cases that have valid values on both
variables.
What should my na.action be in
2013 Jul 12
3
While using R CMD check: LaTex error: File `inconsolata.sty' not found
Hi,
While using R CMD check I get the following Latex error message which occurs when creating PDF version of manual:
LaTex error: File `inconsolata.sty' not found
I am using Windows 7 (64-bit) and R 3.0.1. I have MikTex 2.9.
I see that the incosolata.sty is present under \doc\fonts folder. How can I eliminate this problem?
Thanks,
Ravi
[[alternative HTML version deleted]]
2007 Jul 26
1
princomp error
I am attempting to run principal components analysis on a dataset of
spectral reflectance (6 decimal places). I imported the data using
read.table and there are both column and row headers. When I run
princomp I receive the following error:
Error in cov.wt(z) : 'x' must contain finite values only
Where am I going wrong?
Ross
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
2017 Jun 06
0
Subject: glm and stepAIC selects too many effects
More principled would be to use a lasso-type approach, which combines selection and estimation in one fell swoop!
Ravi
________________________________
From: Ravi Varadhan
Sent: Tuesday, June 6, 2017 10:16 AM
To: r-help at r-project.org
Subject: Subject: [R] glm and stepAIC selects too many effects
If AIC is giving you a model that is too large, then use BIC (log(n) as the penalty for adding
2006 Nov 14
2
Matrix-vector multiplication without loops
Hi,
I am trying to do the following computation:
p <- rep(0, n)
coef <- runif(K+1)
U <- matrix(runif(n*(2*K+1)), n, 2*K+1)
for (i in 0:K){
for (j in 0:K){
p <- p + coef[i+1]* coef[j+1] * U[,i+j+1]
} }
I would appreciate any suggestions on how to perform this computation
efficiently without the "for" loops?
Thank
2013 Jan 30
1
starting values in glm(..., family = binomial(link =log))
Try this:
Age_log_model = glm(Arthrose ~ Alter, data=x, start=c(-1, 0), family=quasibinomial(link = log))
Ravi
Ravi Varadhan, Ph.D.
Assistant Professor
The Center on Aging and Health
Division of Geriatric Medicine & Gerontology
Johns Hopkins University
rvaradhan@jhmi.edu<mailto:rvaradhan@jhmi.edu>
410-502-2619
[[alternative HTML version deleted]]
2017 Jun 06
2
Subject: glm and stepAIC selects too many effects
If AIC is giving you a model that is too large, then use BIC (log(n) as the penalty for adding a term in the model). This will yield a more parsimonious model. Now, if you ask me which is the better option, I have to refer you to the huge literature on model selection.
Best,
Ravi
[[alternative HTML version deleted]]
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
2013 Jul 25
2
What algorithm is R using to calculate mean?
I am curious to know what algorithm R's mean function uses. Is there
some reference to the numerical properties of this algorithm?
I found the following C code in summary.c:do_summary():
case REALSXP:
PROTECT(ans = allocVector(REALSXP, 1));
for (i = 0; i < n; i++) s += REAL(x)[i];
s /= n;
if(R_FINITE((double)s)) {
for (i = 0; i < n; i++) t += (REAL(x)[i] -
2006 Jul 17
1
multiplying multidimensional arrays (was: Re: [R] Manipulation involving arrays)
I am moving this to r-devel.
The problem and solution below posted on r-help could have been
a bit slicker if %*% worked with multidimensional arrays multiplying
them so that if the first arg is a multidimensional array it is mulitplied
along the last dimension (and first dimension for the second arg).
Then one could have written:
Tbar <- tarray %*% t(wt) / rep(wti, each = 9)
which is a bit
2003 Aug 08
1
covmat argument in princomp() (PR#3682)
R version: 1.7.1
OS: Red Hat Linux 7.2
When "covmat" is supplied in princomp(), the output value "center" is all
NA's, even though the input matrix was indeed centered. I haven't read
anything about this in the help file for princomp(). See code below for an
example: pc2$center is all NA's.
Jerome Asselin
x <- rnorm(6)
y <- rnorm(6)
X <- cbind(x,y)
2012 Nov 08
3
vectorized uni-root?
dear R experts--- I have (many) unidimensional root problems. think
loc.of.root <- uniroot( f= function(x,a) log( exp(a) + a) + a,
c(.,9e10), a=rnorm(1) ) $root
(for some coefficients a, there won't be a solution; for others, it
may exceed the domain. implied volatilities in various Black-Scholes
formulas and variant formulas are like this, too.)
except I don't need 1 root, but a