Hi, I have recently been using the R program and encountered a recurring problem. I have been trying calculate the correlation of a 16 column table. Everytime I type in cor(test), where test is data that I uploaded into R using the read.table function, I get an error: Error in cor(test) : missing observations in cov/cor In addition: Warning message: In cor(test) : NAs introduced by coercion Can anyone tell me what I am doing wrong and what I need to do to correct this? Also I intend on running the T-Stats, P-Stats, Information Coefficient and Information Ratios once I get the correlation table calculated. If you know which packages, if any, have are able to calculate this, that would be helpful. Thanks. Best, Michael Tong Futures Associate Quantitative Research Services Franklin Templeton Investments, Inc. 600 Fifth Ave New York, NY 10020 (212) 632-4254 mtong@templeton.com Notice: All email and instant messages (including attachments) sent to or from Franklin Templeton Investments (FTI) personnel may be retained, monitored and/or reviewed by FTI and its agents, or authorized law enforcement personnel, without further notice or consent. [[alternative HTML version deleted]]
?cor you can't calculate a correlation on a missing data point. I think you need to use the argument use=pairwise.complete.obs in the cor call, but look at the function description it will tell you what you need to know (I think). Also, search the list-R nabble, Rsitsearch, or ... Good Luck Stephen On Mon, Jun 23, 2008 at 3:31 PM, Tong, Michael <MTONG@templeton.com> wrote:> Hi, > > I have recently been using the R program and encountered a recurring > problem. I have been trying calculate the correlation of a 16 column table. > Everytime I type in cor(test), where test is data that I uploaded into R > using the read.table function, I get an error: > > Error in cor(test) : missing observations in cov/cor > In addition: Warning message: > In cor(test) : NAs introduced by coercion > > Can anyone tell me what I am doing wrong and what I need to do to correct > this? > > Also I intend on running the T-Stats, P-Stats, Information Coefficient and > Information Ratios once I get the correlation table calculated. If you know > which packages, if any, have are able to calculate this, that would be > helpful. > > Thanks. > > Best, > > Michael Tong > Futures Associate > Quantitative Research Services > Franklin Templeton Investments, Inc. > 600 Fifth Ave > New York, NY 10020 > (212) 632-4254 > mtong@templeton.com > > Notice: All email and instant messages (including attachments) sent to > or from Franklin Templeton Investments (FTI) personnel may be retained, > monitored and/or reviewed by FTI and its agents, or authorized > law enforcement personnel, without further notice or consent. > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis [[alternative HTML version deleted]]
Hi Michael, May be you have NA on your dataset. x<-runif(20) y<-runif(20) cor(x,y) x[10]<-NA x cor(x,y) # SEE the error because NA cor(x,y, use = "pairwise.complete.obs") Good luck, miltinho brazil On 6/23/08, Tong, Michael <MTONG@templeton.com> wrote:> > Hi, > > I have recently been using the R program and encountered a recurring > problem. I have been trying calculate the correlation of a 16 column table. > Everytime I type in cor(test), where test is data that I uploaded into R > using the read.table function, I get an error: > > Error in cor(test) : missing observations in cov/cor > In addition: Warning message: > In cor(test) : NAs introduced by coercion > > Can anyone tell me what I am doing wrong and what I need to do to correct > this? > > Also I intend on running the T-Stats, P-Stats, Information Coefficient and > Information Ratios once I get the correlation table calculated. If you know > which packages, if any, have are able to calculate this, that would be > helpful. > > Thanks. > > Best, > > Michael Tong > Futures Associate > Quantitative Research Services > Franklin Templeton Investments, Inc. > 600 Fifth Ave > New York, NY 10020 > (212) 632-4254 > mtong@templeton.com > > Notice: All email and instant messages (including attachments) sent to > or from Franklin Templeton Investments (FTI) personnel may be retained, > monitored and/or reviewed by FTI and its agents, or authorized > law enforcement personnel, without further notice or consent. > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]