s-news
[Top] [All Lists]

question on cor function

To: s-news@lists.biostat.wustl.edu
Subject: question on cor function
From: "Data Analytics Corp." <dataanalytics@earthlink.net>
Date: Thu, 07 May 2009 11:15:40 -0400
Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; d=earthlink.net; b=cmtms2kJAugtH8ZpeBtFW+bz8pwlN1oMrCK1DbWDD5XrewdoIRvb2EK7m5aGqZwJ; h=Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:Content-Type:Content-Transfer-Encoding:X-ELNK-Trace:X-Originating-IP;
User-agent: Thunderbird 2.0.0.21 (Windows/20090302)
Hi,

I'm confused about what the cor function is producing. I have two data frames: pat and att. Each has 417 rows with missing data. The first, pat, has 4 columns; att has 30. I want the correlations between each column of pat with each column of att. My results should be a 30 by 4 matrix. I used at first

t(cor(pat, att, na.method = "omit"))

and got my 30X4 matrix. The first cell, which should be for the correlation between pat[, 1] and att[, 1] is -0.24399252 But then, just for a check, I did cor(pat[, 1], att[, 1], na.method = "omit") and got a different answer! I got 0.001174417. What's going on??? According to the Help file, the answer for my first statement with the transpose should be "a matrix such that the [i,j] element is the covariance (correlation) of x[,i] and either y[,j] or x[,j]. " So the [1,1] answer should be the correlation between pat[, 1] and att[, 1] - but it's not. What am I missing?? Am I just not seeing the obvious?? I'm using S+8.0 on a Vista machine.

Thanks,

Walt



--
________________________

Walter R. Paczkowski, Ph.D.
Data Analytics Corp.
44 Hamilton Lane
Plainsboro, NJ 08536
________________________
(V) 609-936-8999
(F) 609-936-3733
dataanalytics@earthlink.net
www.dataanalyticscorp.com


<Prev in Thread] Current Thread [Next in Thread>