Re: [R] correlation by factor

2021-07-27 Thread Rui Barradas
Hello, And here are three more ways. I will put the data, corrected in Bert's post, in a data.frame. R <- c(1,8,3,6,7,2,3,7,2,3,3,4,3,7,3) Day <- c(1,1,1,1,1,2,2,2,2,2,3,3,3,3,3) Freq <- paste0("a", rep(1:5,3)) df1 <- data.frame(R, Day, Freq) # Base R, as for the function, see Bert's post sa

Re: [R] correlation by factor

2021-07-27 Thread Bert Gunter
Well, first of all, your example is messed up. You missed the "c" in front of the ( in Freq <-; and all of the Freq entries need to be enclosed in quotes for proper syntax. A simpler way to do it is just to use paste() and rep(): Freq <- paste0("a", rep(1:5,3)) (If you are not familiar with such "

Re: [R] correlation between nominal and ordinal

2017-09-03 Thread David Winsemius
> On Sep 2, 2017, at 3:41 AM, Jim Lemon wrote: > > hi merlin, > Check out the hetcor package. I found a hetcor function in the polycor package. Another method might be to use the lrm function in the rms package. It supports proportional odds ordinal logistic regression models. -- David.

Re: [R] correlation between nominal and ordinal

2017-09-02 Thread Jim Lemon
hi merlin, Check out the hetcor package. Jim On Sat, Sep 2, 2017 at 6:25 AM, wrote: > I would be very grateful if you would tell me how I can find the degree of > correlation between a nominal dependent variable and an independent ordinal > variable. The nominal variable has only two levels: Y

Re: [R] correlation between nominal and ordinal

2017-09-01 Thread Mathew Guilfoyle
Any of the usual rank correlation methods should be fine if you're expecting a monotonic relationship e.g. Spearman's rho or Kendall's tau. > On 1 Sep 2017, at 21:25, merlinverde...@infomed.sld.cu wrote: > > I would be very grateful if you would tell me how I can find the degree of > correlatio

Re: [R] correlation between nominal and ordinal

2017-09-01 Thread Bert Gunter
Wrong list. This list is about programming in R, not statistics. Try stats.stackexchange.com instead for statistics questions. Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloo

Re: [R] Correlation between continuous and binary vectors.

2017-04-01 Thread David Winsemius
I suspect this has been discussed in the past in rhelp. My favorite search engine is Markmail Sent from my iPhone > On Mar 31, 2017, at 8:53 PM, Art U wrote: > > Hi, > I'm trying to create number of vectors, part of them are binary and part > are continuous. Is there a way in R to generate the

Re: [R] Correlation between continuous and binary vectors.

2017-04-01 Thread Boris Steipe
Yes. > On Mar 31, 2017, at 11:53 PM, Art U wrote: > > Hi, > I'm trying to create number of vectors, part of them are binary and part > are continuous. Is there a way in R to generate them with specific > correlation between each pair? > Thank you in advance. > Ariel > -- > *I like to pretend

Re: [R] Correlation code not working but not sure why

2017-03-22 Thread John C Frain
I can't see anything wrong with your code. You should read the posting guide and produce a minimal example showing the problem and any other details requested there. If I take just the small sample of data that you have provided and run a slightly adapted version of your code data = read.table("q

Re: [R] Correlation between package output

2016-04-12 Thread Sarah Goslee
Hi Fabio, Using the first example from ?dbFD ex1 <- dbFD(dummy$trait, dummy$abun) If you look at that help page, or at str(ex1), you'll see that the returned object is a list with named components. So, you can access the different indices just as you would access any other list. If that's confus

Re: [R] correlation matricies: getting p-values?

2015-06-28 Thread David Winsemius
On Jun 28, 2015, at 10:03 AM, David Winsemius wrote: > > On Jun 27, 2015, at 8:06 PM, JAVAD BAYAT wrote: > >> Dear Bill Venables; >> >> Hi, I am using "cor" command to get the correlation coefficients for my data >> frame. I found somthing in the following site: " >>

Re: [R] correlation matricies: getting p-values?

2015-06-28 Thread Bert Gunter
?cor.test Please read Help files (for cor, which linked cor.test) before posting. And, as David says, post in plain text. -- Bert Bert Gunter "Data is not information. Information is not knowledge. And knowledge is certainly not wisdom." -- Clifford Stoll On Sat, Jun 27, 2015 at 8:06 PM, J

Re: [R] correlation matricies: getting p-values?

2015-06-28 Thread David Winsemius
On Jun 27, 2015, at 8:06 PM, JAVAD BAYAT wrote: > Dear Bill Venables; > > Hi, I am using "cor" command to get the correlation coefficients for my data > frame. I found somthing in the following site: " > > https://stat.ethz.ch/pipe

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 question

2015-02-22 Thread David L Carlson
1] -3.281849 David L. Carlson Department of Anthropology Texas A&M University -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Jonathan Thayn Sent: Sunday, February 22, 2015 12:01 AM To: Kehl Dániel Cc: r-help@r-project.org Subject: Re: [R] Correlat

Re: [R] Correlation question

2015-02-21 Thread Jonathan Thayn
Of course! Thank you, I knew I was missing something painfully obvious. Its seems, then, that this line 1-sum((cars$dist-fitted.wrong)^2)/sum((cars$dist-mean(cars$dist))^2) is finding something other than the traditional correlation. I found this in a lecture introducing correlation, but , now,

Re: [R] Correlation question

2015-02-21 Thread Kehl Dániel
Hi, try cor(fitted.right,fitted.wrong) should give 1 as both are a linear function of speed! Hence cor(cars$dist,fitted.right)^2 and cor(x=cars$dist,y=fitted.wrong)^2 must be the same. HTH d Feladó: R-help [r-help-boun...@r-project.org] ; meghatalmazó:

Re: [R] correlation between categorical data

2015-01-28 Thread Heinz Tuechler
comment inline David Winsemius wrote on 24.01.2015 21:08: On Jan 23, 2015, at 5:54 PM, JohnDee wrote: Heinz Tuechler wrote At 07:40 21.06.2009, J Dougherty wrote: [...] There are other ways of regarding the FET. Since it is precisely what it says - an exact test - you can argue that you s

Re: [R] correlation between categorical data

2015-01-24 Thread David Winsemius
On Jan 23, 2015, at 5:54 PM, JohnDee wrote: > Heinz Tuechler wrote >> At 07:40 21.06.2009, J Dougherty wrote: >> >> [...] >>> There are other ways of regarding the FET. Since it is precisely >>> what it says >>> - an exact test - you can argue that you should avoid carrying over any >>> conclu

Re: [R] correlation between categorical data

2015-01-23 Thread JohnDee
Heinz Tuechler wrote > At 07:40 21.06.2009, J Dougherty wrote: > > [...] >>There are other ways of regarding the FET. Since it is precisely >>what it says >>- an exact test - you can argue that you should avoid carrying over any >>conclusions drawn about the small population the test was applied

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

2014-07-27 Thread Rui Barradas
Hello, If I understand it correctly the following should do it. Note that it removes both columns and rows. idx <- corData > 0.5 diag(idx) <- FALSE idx2 <- which(apply(idx, 2, function(x) !any(x))) corData[-idx2, -idx2] Use corData[, -idx2] to remove only columns. Hope this helps, Rui Bar

Re: [R] Correlation

2014-07-16 Thread PIKAL Petr
Hi I looked in the help page which states See Also cor.test for confidence intervals (and tests). cov.wt for weighted covariance computation. Then I looked to cov.wt help page and it seems that it does what you want cov.wt(data.frame(x,y), wt=c(.5,.25,.25), cor=T) $cov xy x 1.1 4.1 y

Re: [R] correlation given p value and sample size

2014-06-16 Thread peter dalgaard
There's a simple relation t = r / sqrt(1 - r^2) * sqrt(n - 2) r = t / sqrt(n - 2 + t^2) where t has a t distribution on n-2 df. Insert t = +-qt(p/2, n-2). -pd On 16 Jun 2014, at 11:23 , Witold E Wolski wrote: > Hi, > > > Looking for and function which produces the minimum r (pearson > cor

Re: [R] correlation with missing values.. different answers

2014-04-14 Thread peter dalgaard
On 14 Apr 2014, at 05:02 , Paul Tanger wrote: > Thanks, I did not realize it was deleting rows! I was afraid to try > "pairwise.complete.obs" because it said something about resulting in a > matrix which is not "positive semi-definite" (and googling that term > just confused me more). It mea

Re: [R] correlation with missing values.. different answers

2014-04-13 Thread Paul Tanger
Thanks, I did not realize it was deleting rows! I was afraid to try "pairwise.complete.obs" because it said something about resulting in a matrix which is not "positive semi-definite" (and googling that term just confused me more). But I ran the dataset through JMP and got the same answers so I t

Re: [R] correlation with missing values.. different answers

2014-04-13 Thread arun
Hi, I think in this case, when you use "na.or.complete", all the NA rows are removed for the full dataset. cor(swM[-1,1:2]) # FrtltyAgrclt  #Frtlty 1.000 0.3920289 #Agrclt 0.3920289 1.000 cor(swM[-1,])[1:2,1:2] #FrtltyAgrclt #Frtlty 1.000 0.3920289 #Agrclt 0

Re: [R] correlation with missing values.. different answers

2014-04-13 Thread Jeff Newmiller
Please post in plain text per the Posting Guide. Read ?cor, particularly the part about "complete.cases". Your two cases have different effective input rows. --- Jeff NewmillerThe . .

Re: [R] correlation between rows of different data frames

2013-08-28 Thread Bert Gunter
You appear to have no idea what you are doing. I suggest you post on the Bioconductor list, not here, for guidance. Better yet, get help locally from someone who does know what they are doing. Cheers, Bert On Wed, Aug 28, 2013 at 6:36 AM, Robin Mjelle wrote: > Hi, > > I have two data frames with

Re: [R] Correlation Loops in time series

2013-08-02 Thread TMiller
Thanks David, that went perfectly fine. Best Tom -- View this message in context: http://r.789695.n4.nabble.com/Correlation-Loops-in-time-series-tp4672732p4672879.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org m

Re: [R] Correlation Loops in time series

2013-07-31 Thread David Carlson
sapply(1:200, function(x) cor(mts1[,x], mts2[,x], use="complete.obs", method=c("pearson"))) - David L Carlson Associate Professor of Anthropology Texas A&M University College Station, TX 77840-4352 -Original Message- From: r-help-boun...@r-project.org

Re: [R] Correlation Loops in time series

2013-07-31 Thread arun
Hi, May be this helps: set.seed(25) mt1<- matrix(sample(c(NA,1:40),20*200,replace=TRUE),ncol=200) set.seed(487) mt2<- matrix(sample(c(NA,1:80),20*200,replace=TRUE),ncol=200) res<- sapply(seq_len(ncol(mt1)),function(i) cor(mt1[,i],mt2[,i],use="complete.obs",method="pearson")) A.K. Hello,

Re: [R] Correlation with p value

2013-02-13 Thread David L Carlson
I Velez'; 'Nico Met' > Cc: 'R help' > Subject: Re: [R] Correlation with p value > > You can use package Hmisc. Assuming your data.frame is called "dta": > > > library(Hmisc) > > dta2 <- do.call(cbind, split(dta[,2], dta$Name)) &

Re: [R] Correlation with p value

2013-02-13 Thread arun
Hi, #data: dat1 mat1<-matrix(dat1[,2],ncol=3,nrow=7) colnames(mat1)<-unique(dat1[,1]) library(Hmisc) rcorr(mat1)$P  #     TTK   CTJ   PKR #TTK    NA 0.0151874 0.6277163 #CTJ 0.0151874    NA 0.5214368 #PKR 0.6277163 0.5214368    NA A.K. - Original Message - From:

Re: [R] Correlation with p value

2013-02-13 Thread David L Carlson
org] On Behalf Of Jorge I Velez > Sent: Wednesday, February 13, 2013 5:22 AM > To: Nico Met > Cc: R help > Subject: Re: [R] Correlation with p value > > Nico, > > Check https://stat.ethz.ch/pipermail/r-help/2008-May/161725.html for > some > alternatives. You might ha

Re: [R] Correlation with p value

2013-02-13 Thread Jorge I Velez
Nico, Check https://stat.ethz.ch/pipermail/r-help/2008-May/161725.html for some alternatives. You might have to change the structure of your data, though. HTH, Jorge.- On Wed, Feb 13, 2013 at 10:13 PM, Nico Met <> wrote: > Dear all, > > I have a data (bellow) and I want to make a correlation

Re: [R] Correlation between random effects in the package coxme

2012-09-17 Thread Terry Therneau
On 09/14/2012 05:00 AM, r-help-requ...@r-project.org wrote: Hello, Why the correlation between the random effects is negative? library(coxme) rats1<- coxme(Surv(time, status) ~ (1|litter), rats) random.effects(rats1)[[1]] #one value for each of the 50 litters print(rats1) rats2<- lmekin(time

Re: [R] Correlation in Rattle

2012-06-11 Thread mlonghi
Same problem here. I have updated rattle from the repository as suggested by Graham, but this, unfortunately, did not solve the issue. (The release date in the 'About Rattle' dialog is 2012-04-22.) Any other ideas? Graham Williams wrote > > It is fixed and 2.6.19 will include the fix. > When

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

2012-05-18 Thread Graham Williams
Thanks for assisting here Paul. It turns out there is a bug in this release of Rattle. It is fixed and 2.6.19 will include the fix. In the mean time you can download an updated 2.6.18 from http://www.togaware.com.au/repository/ Regards, Graham On 19 May 2012 01:14, Paul Miller wrote: > Hi Avid

Re: [R] Correlation in Rattle

2012-05-18 Thread Paul Miller
Hi Avideh, Sorry to hear you're still having a problem. Tried usinging this two options on my 64-bit and 32-bit versions of R 2.15.0. Everything works fine. So I've at least been able to determine that there's nothing wrong with Rattle or with the combination of Ratttle and either the 64-bit an

Re: [R] Correlation in Rattle

2012-05-18 Thread Paul Miller
Hi Avideh, I have Rattle installed on the 64-bit version of R 2.15.0 and this seems to work OK. I had a dataset of my own loaded into Rattle when I saw your email. Tried creating the plot using these data but got a warning saying I should limit the number of variables to 40. So I changed to the

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 among variables in the same subset

2012-05-16 Thread R. Michael Weylandt
? cor e.g., x <- data.frame(rnorm(5), rnorm(5), rnorm(5), rnorm(5), rnorm(5)) cor(x) Best, Michael On Wed, May 16, 2012 at 6:52 AM, Andrea Sica wrote: > Dear all, > > I have created a subset from my dataset, which contains 6 variables. > I need to make the correlation among all of them, possi

Re: [R] correlation between XY coordinates

2012-05-07 Thread David L Lorenz
: Sarah Goslee To: Christopher Kurby Cc: "r-help@r-project.org" Subject: Re: [R] correlation between XY coordinates Message-ID: <4a58b3c4-c5b6-4c22-a7d3-bd79b8c1f...@gmail.com> Content-Type: text/plain; charset=us-ascii Hi Chris, To get a single value you might need something li

Re: [R] correlation between XY coordinates

2012-05-06 Thread Sarah Goslee
Hi Chris, To get a single value you might need something like a Mantel test, available in both ecodist and vegan. That test is a permutation test of significance of the correlation between two distance matrices. Sarah On May 6, 2012, at 8:06 AM, Christopher Kurby wrote: > Hey Josh (and every

Re: [R] correlation between XY coordinates

2012-05-06 Thread Christopher Kurby
Hey Josh (and everyone), My apologies, let me be more specific. I have two sets of XY coordinates in Cartesian space. I would like to compute a correlation between the two sets. For example, let's say I have two N X 2 matrices, with the first column being the X coordinate, the second column bei

Re: [R] correlation between XY coordinates

2012-05-05 Thread Joshua Wiley
Hi Chris, As Jeff mentioned, it is hard to tell what you want (correlations between sets of coordinates could mean many things it seems like to me), but here is something that perhaps helps: ## some data (usually nice if you provide this rather than us having to make something up) d1 <- cbind(x <

Re: [R] correlation between XY coordinates

2012-05-05 Thread Jeff Newmiller
Isn't that one of the main things base R is used for? Maybe your question is not specific enough. Can you provide some sample data and your best estimate of what the result should look like? The Posting Guide mentioned below could help you elicit more effective answers. --

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 between 2 matrices but with subset of variables

2012-03-09 Thread A Ezhil
Dear Peter, Thank you very much. Best regards, Ezhil --- On Fri, 3/9/12, Petr Savicky wrote: > From: Petr Savicky > Subject: Re: [R] Correlation between 2 matrices but with subset of variables > To: r-help@r-project.org > Date: Friday, March 9, 2012, 1:18 PM > On Thu, Mar 08

Re: [R] Correlation between 2 matrices but with subset of variables

2012-03-08 Thread Petr Savicky
On Thu, Mar 08, 2012 at 03:57:06PM -0800, A Ezhil wrote: > Dear All, > I have two matrices A (40 x 732) and B (40 x 1230) and would like to > calculate correlation between them. ?I can use: cor(A,B, method="pearson") to > calculate correlation between all possible pairs. But the issue is that the

Re: [R] Correlation between 2 matrices but with subset of variables

2012-03-08 Thread chuck.01
Example data would be helpful A Ezhil wrote > > Dear All, > I have two matrices A (40 x 732) and B (40 x 1230) and would like to > calculate correlation between them.  I can use: cor(A,B, method="pearson") > to calculate correlation between all possible pairs. But the issue is that > there is

Re: [R] Correlation between 2 matrices but with subset of variables

2012-03-08 Thread A Ezhil
Thanks a lot, Michael.  --- On Fri, 3/9/12, R. Michael Weylandt wrote: From: R. Michael Weylandt Subject: Re: [R] Correlation between 2 matrices but with subset of variables To: "A Ezhil" Cc: r-help@r-project.org Date: Friday, March 9, 2012, 7:59 AM Well, it would be possi

Re: [R] Correlation between 2 matrices but with subset of variables

2012-03-08 Thread R. Michael Weylandt
Well, it would be possible to set something up to select out just the right pairs each time, but on my system the following a <- matrix(rnorm(40 * 732), 40) b <- matrix(rnorm(40 * 1230), 40) system.time(cor(a,b,method = "pearson")) takes about a tenth of a second so any more elective approach wi

Re: [R] Correlation analysis for an exon array

2012-03-08 Thread R. Michael Weylandt
This question seems more suited to the Bioconductor mailing list: you'll get specialized (and very good) help if you post there. Michael On Thu, Mar 8, 2012 at 6:22 AM, Ekta Jain wrote: > Dear All, > I have an exon array and did not find any differential gene expression > between two samples. I

Re: [R] Correlation of huge matrix saved as binary file

2012-03-03 Thread Thomas Lumley
On Sat, Mar 3, 2012 at 2:36 PM, Peter Langfelder wrote: > 3. Instead of calculating the correlations one-by-one, calculate them > in small blocks (if you have enough memory and you run a 64-bit R). > With 900M rows, you will only be able to put a 900Mx2 into an R > object, but if you have two suc

Re: [R] Correlation of huge matrix saved as binary file

2012-03-02 Thread Peter Langfelder
I don't think you can speed it up by a whole lot... but you can try a few things, especially if you don't have missing data in the matrix (which you probably don't). The main question is what takes most of the time- the api calls or the cor() call? If it's cor, here's what you can try: 1. Pre-stan

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 analysis

2011-11-06 Thread R. Michael Weylandt
You might find useful tools if you look at Bioconductor as well. M On Nov 6, 2011, at 4:58 PM, Minh Bui wrote: > Hi everyone, > > I am new to R-project. I did search through the list for my problem but i > can't find it. I am sorry if this question has been asked. > > I would like to perfo

Re: [R] Correlation analysis

2011-11-06 Thread B77S
I would start by reading one or more of the introduction manuals available here: http://mirrors.ibiblio.org/pub/mirrors/CRAN/ wizi wrote: > > Hi everyone, > > I am new to R-project. I did search through the list for my problem but i > can't find it. I am sorry if this question has been

Re: [R] Correlation between matrices

2011-11-06 Thread Dennis Murphy
Hi: On Sat, Nov 5, 2011 at 11:06 PM, Kaiyin Zhong wrote: > Thank you Dennis, your tips are really helpful. > I don't quite understand the lm(y~mouse) part; my intention was -- in > pseudo code -- lm(y(Enzyme) ~ y(each elem)). As I said in my first response, I didn't quite understand what you wer

Re: [R] Correlation between matrices

2011-11-06 Thread Kaiyin Zhong
Thank you Dennis, your tips are really helpful. I don't quite understand the lm(y~mouse) part; my intention was -- in pseudo code -- lm(y(Enzyme) ~ y(each elem)). In addition, attach(d) seems necessary before using lm(y~mouse), and since d$mouse has a length 125, while each elem for each region ha

Re: [R] Correlation between matrices

2011-11-05 Thread Dennis Murphy
Hi: I don't think you want to keep these objects separate; it's better to combine everything into a data frame. Here's a variation of your example - the x variable ends up being a mouse, but you may have another variable that's more appropriate to plot so take this as a starting point. One plot us

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 of variables with repeated measures.

2011-09-23 Thread Heverkuhn Heverkuhn
I guess that I have just to consider the means of each subject, as indicated here. http://www-users.york.ac.uk/~mb55/intro/corrsim.htm Thanks On Thu, Sep 22, 2011 at 9:16 PM, Heverkuhn Heverkuhn wrote: > Hello > I have a dataframe that looks like this: > > Date Min Subj VAR1

Re: [R] Correlation discrepancy

2011-08-23 Thread Kohta Ishikawa
Divide by 8 leads biased estimator of covariance. R cov function calculates unbiased estimator(divide by (sample size)-1). Regards, Kohta -- View this message in context: http://r.789695.n4.nabble.com/Correlation-discrepancy-tp3762457p3762491.html Sent from the R help mailing list archive at Nab

Re: [R] Correlation discrepancy

2011-08-23 Thread Vincy Pyne
Dear Mr Dimitris and Mr Harding, by mistake I have typed my colleagues name (i.e. Ashok) while thanking you. Please excuse me for that. Regards Vincy --- On Tue, 8/23/11, ted.hard...@wlandres.net wrote: From: ted.hard...@wlandres.net Subject: Re: [R] Correlation discrepancy To: r-help@r

Re: [R] Correlation discrepancy

2011-08-23 Thread Vincy Pyne
Dear Mr. Dimitris and Mr Harding, thanks a lot for your guidance. It will be interesting to find out how the Excel deals with this formula. I will try it. Thanks again. Regards Ashok --- On Tue, 8/23/11, ted.hard...@wlandres.net wrote: From: ted.hard...@wlandres.net Subject: Re: [R

Re: [R] Correlation discrepancy

2011-08-23 Thread Ted Harding
In addition, something has gone wrong, Vincy, with your data x,y between evaluating cov(x,y) and evaluating your explicit formula. If I repeat your commands: x = c(44,46,46,47,45,43,45,44) y = c(44,43,41,41,46,48,44,43) cov(x, y) # [1] -2.428571 sum((x-mean(x))*(y-mean(y)))/8 # [1] -

Re: [R] Correlation discrepancy

2011-08-23 Thread Dimitris Rizopoulos
well, you don't have the correct denominator, i.e., n-1, with n denoting the sample size. Have a look at the *Details* section of the online help file for cov(), and try also sum((x-mean(x))*(y-mean(y)))/7 cov(x, y) I hope it helps. Best, Dimitris On 8/23/2011 1:18 PM, Vincy Pyne wrote: D

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:

  1   2   >