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 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

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

2015-06-18 Thread Sarah Bazzocco
This post was called help before, I changed the Subject. Thanks for the comments. Here the example: (I have the two lists saved as .csv and I can open them in R) Sheet one- Genes (10 genes expression, not binary, meaured in 10 cell lines) genes Genes Cell.line1 Cell.line2 Cell.line3

Re: [R] Correlation Matrix with a Covariate

2014-09-02 Thread David L Carlson
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: [R] Correlation Matrix

Re: [R] Correlation Matrix with a Covariate

2014-09-02 Thread Patzelt, Edward
: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Patzelt, Edward Sent: Monday, September 1, 2014 7:47 AM To: R-help@r-project.org Subject: [R] Correlation Matrix with a Covariate R Help - I'm trying to run a correlation matrix with a covariate of age

[R] Correlation Matrix with a Covariate

2014-09-01 Thread Patzelt, Edward
R Help - I'm trying to run a correlation matrix with a covariate of age and will at some point will also want to covary other variables concurrently. I'm using the psych package and have tried other methods such as writing a loop to extract semi-partial correlations, but it does not seem to be

Re: [R] Correlation Matrix with a Covariate

2014-09-01 Thread David L Carlson
-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Patzelt, Edward Sent: Monday, September 1, 2014 7:47 AM To: R-help@r-project.org Subject: [R] Correlation Matrix with a Covariate R Help - I'm trying to run a correlation matrix with a covariate of age and will at some point will also want

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

2012-05-29 Thread jeff6868
Hi everybody. I'm trying to do a correlation matrix in a list of files. Each file contains 2 columns: capt1 and capt2. For the example, I merged all in one data.frame. My data also contains many missing data. The aim is to do a correlation matrix for the same data for course (one correlation

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

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:

[R] Correlation Matrix

2012-05-17 Thread mahdi
Could anyone can help me telling the way how I can build correlation matrix in R? Thanks in advance. -- View this message in context: http://r.789695.n4.nabble.com/Correlation-Matrix-tp4630389.html Sent from the R help mailing list archive at Nabble.com.

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. __

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 on

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,

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

[R] Correlation Matrix Kendall Tau-b with P value

2012-05-15 Thread Nick Duncan
Dear All, I have been trying to find some code to enable this matrix to be generated, but don't seem to find one in which the tau-b and p values are inserted into the matrix. I have found a number that seem to require two matrices, which is a bit clumsy. Any guidance much appreciated. Best, Nick

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(Sensors)

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

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 data

[R] correlation matrix between data from different files

2012-04-12 Thread jeff6868
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 data file for the N°2 for the year

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

[R] Correlation matrix removing insignificant R values

2011-11-23 Thread mgranlie
Hello. I have a large dataset with sales pr month for 56 products with 10 months and i have tried to see how the sales are correlated using cor() This has given me a 56X56 matrix with the R value for each product pair. Most of these correlations are insignificant, and i want only to retain the

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 -

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[i])

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

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 alexandre.chaus...@unil.ch wrote: Hello, Thank you for your replies. I cannot run the function rcor.test

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.c.p

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.

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 -

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 other

[R] Correlation Matrix in R

2011-10-25 Thread AlexC
Hi, I am currently working with a data set which contains a list of julian dates of phenological (flowering, leaf growth etc.) I obtained a correlation matrix by simply using the cor function with the dataset cor(dataset,use=complete.obs) that gives me a correlation matrix but the

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 alexandre.chaus...@unil.ch wrote: Hi, I am

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

[R] correlation matrix

2011-10-10 Thread 1Rnwb
Hello Gurus I have two correlation matrices 'xa' and 'xb' set.seed(100) d=cbind(x=rnorm(20)+1, x1=rnorm(20)+1, x2=rnorm(20)+1) d1=cbind(x=rnorm(20)+2, x1=rnorm(20)+2, x2=rnorm(20)+2) xa=cor(d,use='complete') xb=cor(d1,use='complete') I want to combine these two to get a third

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 'xa' and

Re: [R] correlation matrix

2011-10-10 Thread Peter Alspach
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of 1Rnwb Sent: Tuesday, 11 October 2011 6:20 a.m. To: r-help@r-project.org Subject: [R] correlation matrix Hello Gurus I have two correlation matrices 'xa' and 'xb' set.seed(100

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. :)

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, Rowv=FALSE,

[R] Correlation Matrix - p value?

2011-08-09 Thread ScottM
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 correlation matrix between the one dependent variable and all of the predictors, which gives me a nice output of Spearman's Rho values.

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 correlation matrix

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

Re: [R] Correlation Matrix - p value?

2011-08-09 Thread R. Michael Weylandt michael.weyla...@gmail.com
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 scott.mcgr...@abdn.ac.uk wrote: Cheers Jorge, I've tried this, but keep getting error messages, relating to either: Error:

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. Do

[R] Correlation Matrix

2011-04-07 Thread Dmitry Berman
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 correlation matrix using just three of the variable

Re: [R] Correlation Matrix

2011-04-07 Thread Jeremy Miles
On 7 April 2011 12:09, Dmitry Berman ravenb...@gmail.com 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

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 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 the first

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

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 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

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

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 only the left bottom

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 case,

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. Now I'd like to have it one

[R] Correlation matrix one side with significance

2008-03-05 Thread Martin Kaffanke
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 * where the p-value is lower than 0.05 and ** lower than 0.01. How can I do this? And

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 * where the

[R] Correlation matrix for data in long format

2008-01-29 Thread Serguei Kaniovski
Hello, I cannot figure out how to use tapply to compute the correlation matrix in the variable x between the states? The data is in long format, e.g.: state,year,x Alabama,2001,0.45 Alabama,2002,0.47 Alabama,2003,0.48 Alabama,2004,0.44 Arizona,2001,0.34 Arizona,2002,0.32 Arizona,2003,0.38

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 states? The

[R] correlation matrix - large dataset

2008-01-08 Thread suman Duvvuru
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 regarding a feasible way to compute correlations on such a huge dataset,

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 regarding