Re: [R] Correlation matrix for pearson correlation (r,p,BH(FDR))

2015-06-18 Thread Peter Langfelder
You have multiple options. I will advertise my own solution - install the package WGCNA, installation instructions at http://labs.genetics.ucla.edu/horvath/CoexpressionNetwork/Rpackages/WGCNA/#cranInstall then you can use the function cp = corAndPvalue(t(genes), t(features)). You need to transpo

Re: [R] Correlation matrix for pearson correlation (r,p,BH(FDR))

2015-06-18 Thread Rainer Schuermann
The way the sample data is provided is not useful. I have re-built your data, please find the dput() version below (and pls check whether I got it right...). This is not my area of competence at all, but from what I see from the help page is that the expected parameters are, among others: x

Re: [R] Correlation Matrix with a Covariate

2014-09-02 Thread Patzelt, Edward
Even reducing the command to less variables than observations I still get: set.cor(y = (66:76), x = c(1:6), z = 65, data = dat5) Error in solve.default(x.matrix, xy.matrix) : Lapack routine dgesv: system is exactly singular: U[2,2] = 0 On Mon, Sep 1, 2014 at 12:25 PM, David L Carlson wrote:

Re: [R] Correlation Matrix with a Covariate

2014-09-02 Thread David L Carlson
1. col 1 is perfectly correlated with col 2 col 3 is perfectly correlated with col 4 col 5 is perfectly correlated with col 6 David C From: Patzelt, Edward [mailto:patz...@g.harvard.edu] Sent: Tuesday, September 2, 2014 9:21 AM To: David L Carlson Cc: R-help@r-project.org Subject: Re:

Re: [R] Correlation Matrix with a Covariate

2014-09-01 Thread David L Carlson
Thanks for including your data with dput(). I'm not familiar with set correlation, but altogether you are working with 76 variables (columns) and only 46 observations. Since the error message says "the system is exactly singlular," it is likely that you have too many variables for the number of

Re: [R] correlation matrix only if enough non-NA values

2012-05-29 Thread Rui Barradas
Hello, Instead of 'sum' use 'mean' ok <- apply(tbl, 2, function(x) mean(!is.na(x)) >= 0.5) cor(tbl[, ok], use="pairwise.complete.obs") Hope this helps, Rui Barradas Em 29-05-2012 10:03, jeff6868 escreveu: Hi everybody. I'm trying to do a correlation matrix in a list of files. Each file cont

Re: [R] Correlation Matrix

2012-05-17 Thread mahdi
thanks a lot dear. I will keep your advice in my mind. -- View this message in context: http://r.789695.n4.nabble.com/Correlation-Matrix-tp4630389p4630448.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing lis

Re: [R] Correlation Matrix

2012-05-17 Thread Bert Gunter
Josh: A very nice, clear, polite, concise, and reasoned alternative to "RTFM" ! Probably should be templated somehow, given the volume of queries of this sort that this list receives. (The posting guide is too involved to serve in its stead.) Cheers, Bert On Thu, May 17, 2012 at 9:31 AM, Josh

Re: [R] Correlation Matrix

2012-05-17 Thread Joshua Wiley
Hi Mahdi, Look at the documentation for cor(), by typing ?cor or help("cor"). Pearson is the default and it is trivial to select the others. I suggest you try searching google or reading R's documentation before posting to the list. You may not understand it all, but it shows you tried to work o

Re: [R] Correlation Matrix

2012-05-17 Thread mahdi
Thanks a lot. Suppose I want to use Pearson's method, then what I have to do? -- View this message in context: http://r.789695.n4.nabble.com/Correlation-Matrix-tp4630389p4630396.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r

Re: [R] Correlation Matrix

2012-05-17 Thread Cren
Hi, unless you're dealing with heteroskedastic datas, the command *cor(x)* will be enough, where *x* is your data matrix; in this function you can easily select the method which has to be used: Pearson's, Kendall's or Spearman's correlation. -- View this message in context: http://r.789695.n4.na

Re: [R] correlation matrix between data from different files

2012-04-18 Thread jeff6868
I improved yesterday a bit your script (mostly according to station numbers for the automatization). Here's the final version. thanks again! filenames <- list.files(pattern="\\_2008_reconstruit.csv$") Sensors <- paste("capteur_", 1:4, sep="") Stations <-substr(filenames,1,5) nsensors <- length

Re: [R] correlation matrix between data from different files

2012-04-17 Thread jeff6868
Hello Rui, Thanks a lot for your answer. Hou hoped that your script would help me? I answer you: It is WON-DER-FUL! It works very well! I had first some difficulties to adapt it to my data, but I succeeded afterwords when I made a test between 2 stations. It's not perfect yet (I still have to mo

Re: [R] correlation matrix between data from different files

2012-04-13 Thread Rui Barradas
Hello, jeff6868 wrote > > Dear users, > > I'm quite a new french R-user, and I have a problem about doing a > correlation matrix. > I have temperature data for each weather station of my study area and for > each year (for example, a data file for the weather station N°1 for the > year 2009, a

Re: [R] Correlation matrix removing insignificant R values

2011-11-23 Thread R. Michael Weylandt
Looking over the code below, I think this patched version might return a better answer: spec.cor <- function(dat, r, ...) { x <- cor(dat, ...) x[upper.tri(x, TRUE)] <- NA i <- which(abs(x) >= r, arr.ind = TRUE) data.frame(V1 = rownames(x)[i[,1]], V2 = colnames(x)[i[,2]], Value = x[

Re: [R] Correlation matrix removing insignificant R values

2011-11-23 Thread R. Michael Weylandt
There have been two threads dealing with this in the last few weeks: please search the recent archives for those threads for a good discussion -- end result: Josh Wiley provided a useful little function to do so that I'll copy below. RSeek.org is a good place to do your searching. spec.cor <- func

Re: [R] Correlation matrix removing insignificant R values

2011-11-23 Thread Frank Harrell
I think it would be better to think of this as an estimation problem rather than a selection problem. If the correlation matrix is of interest, estimate the entire matrix. If you want to show that you can make decisions on the basis of the matrix, then use the bootstrap to get a confidence interv

Re: [R] Correlation Matrix in R

2011-11-01 Thread William Revelle
Alexandre, The output from corr.test is a list of matrices. To export one of those matrices, simply specify which one you want: Using the example from my previous note: > library(psych) > examp <- corr.test(sat.act) > mat.c.p <- lower.tri(examp$r)*examp$r + t(lower.tri(examp$p)*examp$p) > mat

Re: [R] Correlation Matrix in R

2011-11-01 Thread andrija djurovic
Hi, one solution is to use sink. Check ?sink to see explanation and following example. sink("sink-examp.txt") i <- 1:10 outer(i, i, "*") sink() Andrija On Tue, Nov 1, 2011 at 10:43 AM, AlexC wrote: > Hello, > > Thank you for your replies. I cannot run the function rcor.test even when > having

Re: [R] Correlation Matrix in R

2011-11-01 Thread AlexC
Hello, Thank you for your replies. I cannot run the function rcor.test even when having loaded package ltm. Perhaps it has to do with the fact that I am using the latest version of R and this package wasn't created under that version The function corr.test in package psych works fine. Is ther

Re: [R] Correlation Matrix in R

2011-10-26 Thread Mark Podolsky
Hi, rcor.test in library(ltm) will provide a correlation matrix with p-values on the bottom-half of the matrix. Mark On 2011-10-26, at 7:03 AM, AlexC wrote: > Thank you for your quick reply and helpful advice. > > Using this argument allows me to do what I needed to do > > Now the only othe

Re: [R] Correlation Matrix in R

2011-10-26 Thread William Revelle
Alex, corr.test in psych will give you a matrix of correlations, a matrix of sample sizes, and a matrix of probabilities. You can combine the correlations and the probabilities to form what you want: try the following: > library(psych) > examp <- corr.test(sat.act) > mat.c.p <- lower.tri(exa

Re: [R] Correlation Matrix in R

2011-10-26 Thread AlexC
Thank you for your quick reply and helpful advice. Using this argument allows me to do what I needed to do Now the only other thing I wanted to accomplish was to obtain the top half of the matrix with p values and the bottom half with the correlations, to observe the significant correlations. I

Re: [R] Correlation Matrix in R

2011-10-25 Thread R. Michael Weylandt
I believe it has to do with the "complete.obs" choice and the presence of NAs in your data. The differences should vanish with "pairwise.complete.obs" but whether that's what you want is up to you. Michael On Tue, Oct 25, 2011 at 5:09 PM, AlexC wrote: > Hi, > > I am currently working with a dat

Re: [R] correlation matrix

2011-10-11 Thread 1Rnwb
Thank you all for your suggestions. Sharad -- View this message in context: http://r.789695.n4.nabble.com/correlation-matrix-tp3891085p3894329.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://st

Re: [R] correlation matrix

2011-10-10 Thread 1Rnwb
okay so fixed what i need to do this way finit=0 for(ri in 1:dim(xa)[1]) { finit=finit+1 xc[ri,1:finit]<-xa[ri,1:finit] xc[1:finit,ri]<-xb[1:finit,ri] } but getting error in heatmap.2 > mycol <- colorpanel(n=40,low="red",mid="white",high="blue") > heatmap.2(xc, breaks=pairs.breaks, col=mycol, Ro

Re: [R] correlation matrix

2011-10-10 Thread Dénes TÓTH
And you might also consider packages like corrplot, corrgram etc. for other plotting options of a correlation matrix. They can be more informative than simply invoking image(heat) > What a pleasant post to respond to - with self-contained code. :) > > heat<-matrix(0,nrow=dim(xa)[1],ncol=dim(xa)

Re: [R] correlation matrix

2011-10-10 Thread Peter Alspach
Tena koe Sharad If I understand you correctly, you want the lower triangle of your combined matrix to be the lower triangle of one of the correlation matrices, and the upper triangle to be the upper triangle from the other. If so, check lower.tri() and upper.tri(). HTH Peter Alspach >

Re: [R] correlation matrix

2011-10-10 Thread Daniel Malter
What a pleasant post to respond to - with self-contained code. :) heat<-matrix(0,nrow=dim(xa)[1],ncol=dim(xa)[2]) heat[lower.tri(heat)]<-xa[lower.tri(xa)] heat[upper.tri(heat)]<-xb[upper.tri(xb)] diag(heat)<-1 heat HTH, Daniel 1Rnwb wrote: > > Hello Gurus > I have two correlation matrices 'x

Re: [R] Correlation Matrix - p value?

2011-08-09 Thread Dennis Murphy
Works for me: > x <- rnorm(10) > y <- rnorm(10) > cor.test(x, y, method = 'spearman')$p.value [1] 0.166058 What are the classes of your inputs? A reproducible example would be helpful. From the help page of cor.test(): x, y numeric vectors of data values. x and y must have the same length.

Re: [R] Correlation Matrix - p value?

2011-08-09 Thread R. Michael Weylandt
Just pointing out that Jorge wrote cor.test not cor. Don't know if you saw that but it should help. Michael Weylandt On Aug 9, 2011, at 8:58 AM, ScottM wrote: > Cheers Jorge, > > I've tried this, but keep getting error messages, relating to either: > > Error: unexpected '$' in "$" > >

Re: [R] Correlation Matrix - p value?

2011-08-09 Thread ScottM
Cheers Jorge, I've tried this, but keep getting error messages, relating to either: Error: unexpected '$' in "$" or Error in cor(data, method = "spearman")$p.value : $ operator is invalid for atomic vectors Very annoying! S Scott McGrane MA (Hons), MRes SAGES Theme 1 PhD Student Northern R

Re: [R] Correlation Matrix - p value?

2011-08-09 Thread Jorge Ivan Velez
?cor.test cor.test(x, y, method = "spearman")$p.value HTH, Jorge On Tue, Aug 9, 2011 at 8:44 AM, ScottM <> wrote: > Hello all, > > I've run a Spearman's Rank test to discern relationships between landscape > characteristics and a specific aspect of river behaviour. > > I've executed a correlati

Re: [R] Correlation Matrix

2011-04-07 Thread David Winsemius
On Apr 7, 2011, at 3:09 PM, Dmitry Berman wrote: Listers, I have a question regarding correlation matrices. It is fairly straight forward to build a correlation matrix of an entire data frame. I simply use the command cor(MyDataFrame). However, what I would like to do is construct a smal

Re: [R] Correlation Matrix

2011-04-07 Thread Jorge Ivan Velez
I am sorry for the noise, but with(MyDataFrame[, 1:3]) should have been with(cor(MyDataFrame[, 1:3])) Best, Jorge On Thu, Apr 7, 2011 at 3:21 PM, Jorge Ivan Velez <> wrote: > Hi Dmitry, > > You might try > > with(MyDataFrame[, 1:3]) > > is variable1, variable2 and variable3 correspond to th

Re: [R] Correlation Matrix

2011-04-07 Thread Jorge Ivan Velez
Hi Dmitry, You might try with(MyDataFrame[, 1:3]) is variable1, variable2 and variable3 correspond to the first three columns of your data, or with( MyDataFrame( cor( cbind( variable1, variable2, variable3) ) ) ) otherwise. HTH, Jorge On Thu, Apr 7, 2011 at 3:09 PM, Dmitry Berman <> wrote:

Re: [R] Correlation Matrix

2011-04-07 Thread Jeremy Miles
On 7 April 2011 12:09, Dmitry Berman wrote: > Listers, > > I have a question regarding correlation matrices. It is fairly straight > forward to build a correlation matrix of an entire data frame. I simply use > the command cor(MyDataFrame). However, what I would like to do is construct > a smaller

Re: [R] Correlation Matrix

2010-06-10 Thread sayan dasgupta
Hi , you can try using cov2cor(vcov(lm(calorie~height))) to get the correlation matrix of estimated coefficients boltonboy999 wrote: > > Hi everyone, > > This is pretty urgent so if anyone can help that would be great. > > I have a table of information. The categories are weight, height

Re: [R] Correlation matrix one side with significance

2009-01-25 Thread Kingsford Jones
On the topic of visualizing correlation, see also Murdoch, D.J. and Chow, E.D. (1996). A graphical display of large correlation matrices. The American Statistician 50, 178-180. with examples here: # install.packages('ellipse') example(plotcorr, package='ellipse') On Sat, Mar 8, 2008 at 3:01 A

Re: [R] Correlation matrix one side with significance

2009-01-25 Thread Gabor Grothendieck
If your purpose is simply to represent a correlation matrix it in a more compact way see ?symnum, the corrgram package and an example in the book Multivariate Data Visualization (regarding which gives a lattice implementation). On Fri, Mar 7, 2008 at 2:15 PM, Martin Kaffanke wrote: > Thank you, t

Re: [R] Correlation matrix one side with significance

2008-03-08 Thread Liviu Andronic
On 3/5/08, Martin Kaffanke <[EMAIL PROTECTED]> wrote: > Now I'd like to have it one sided, means only the left bottom side to be > printed (the others are the same) and I'd like to have * where the > p-value is lower than 0.05 and ** lower than 0.01. Look here [1], at "Visualizing Correlations"

Re: [R] Correlation matrix one side with significance

2008-03-07 Thread Martin Kaffanke
Thank you, thats really good and gives me very good information. Thanks, Martin Am Donnerstag, den 06.03.2008, 14:35 -0500 schrieb Chuck Cleland: > On 3/6/2008 2:07 PM, Martin Kaffanke wrote: > > Am Mittwoch, den 05.03.2008, 14:38 -0300 schrieb Henrique Dallazuanna: > >> Try this: > >> > >> On 05

Re: [R] Correlation matrix one side with significance

2008-03-06 Thread Chuck Cleland
On 3/6/2008 2:07 PM, Martin Kaffanke wrote: > Am Mittwoch, den 05.03.2008, 14:38 -0300 schrieb Henrique Dallazuanna: >> Try this: >> >> On 05/03/2008, Martin Kaffanke <[EMAIL PROTECTED]> wrote: >>> Hi there! >>> >>> In my case, >>> >>> cor(d[1:20]) >>> >>> makes me a good correlation matrix. >>>

Re: [R] Correlation matrix one side with significance

2008-03-06 Thread Henrique Dallazuanna
Please provide a example of what you want On 06/03/2008, Martin Kaffanke <[EMAIL PROTECTED]> wrote: > > Am Mittwoch, den 05.03.2008, 14:38 -0300 schrieb Henrique Dallazuanna: > > > Try this: > > > > On 05/03/2008, Martin Kaffanke <[EMAIL PROTECTED]> wrote: > > > Hi there! > > > > > > In my

Re: [R] Correlation matrix one side with significance

2008-03-06 Thread Martin Kaffanke
Am Mittwoch, den 05.03.2008, 14:38 -0300 schrieb Henrique Dallazuanna: > Try this: > > On 05/03/2008, Martin Kaffanke <[EMAIL PROTECTED]> wrote: > > Hi there! > > > > In my case, > > > > cor(d[1:20]) > > > > makes me a good correlation matrix. > > > > Now I'd like to have it one sided, means

Re: [R] Correlation matrix one side with significance

2008-03-05 Thread Henrique Dallazuanna
Try this: On 05/03/2008, Martin Kaffanke <[EMAIL PROTECTED]> wrote: > Hi there! > > In my case, > > cor(d[1:20]) > > makes me a good correlation matrix. > > Now I'd like to have it one sided, means only the left bottom side to be > printed (the others are the same) and I'd like to have * wher

Re: [R] Correlation matrix for data in long format

2008-01-29 Thread Henrique Dallazuanna
If I understand your question, you can try something like this: cor(data.frame(lapply(split(x, x$state), "[", 3))) On 29/01/2008, Serguei Kaniovski <[EMAIL PROTECTED]> wrote: > Hello, > > I cannot figure out how to use "tapply" to compute the correlation matrix > in the variable "x" between the s

Re: [R] correlation matrix - large dataset

2008-01-08 Thread Douglas Bates
On Jan 8, 2008 12:34 AM, suman Duvvuru <[EMAIL PROTECTED]> wrote: > Hello, > I have a dataset with 20,000 variables.and I would like to compute a pearson > correlation matrix which will be 2*2. The cor() function doesnt work > in this case due to memory problem. If you have any ideas regar