[rkward-cvs] SF.net SVN: rkward: [1327] trunk/rkward

tfry at users.sourceforge.net tfry at users.sourceforge.net
Mon Feb 5 18:25:51 UTC 2007


Revision: 1327
          http://svn.sourceforge.net/rkward/?rev=1327&view=rev
Author:   tfry
Date:     2007-02-05 10:25:51 -0800 (Mon, 05 Feb 2007)

Log Message:
-----------
Add support for calculating p-values to correlation matrix plugin

Modified Paths:
--------------
    trunk/rkward/ChangeLog
    trunk/rkward/rkward/plugins/analysis/corr_matrix/code.php
    trunk/rkward/rkward/plugins/analysis/corr_matrix/description.xml

Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog	2007-02-05 14:54:46 UTC (rev 1326)
+++ trunk/rkward/ChangeLog	2007-02-05 18:25:51 UTC (rev 1327)
@@ -1,3 +1,4 @@
+- support for calculating p-values in correlation matrix plugin
 - fixed: pressing F8 in the console would remove input focus from the console
 - pressing tab changes focus while in a single line text input field
 - fix several small problems with detached windows

Modified: trunk/rkward/rkward/plugins/analysis/corr_matrix/code.php
===================================================================
--- trunk/rkward/rkward/plugins/analysis/corr_matrix/code.php	2007-02-05 14:54:46 UTC (rev 1326)
+++ trunk/rkward/rkward/plugins/analysis/corr_matrix/code.php	2007-02-05 18:25:51 UTC (rev 1327)
@@ -1,9 +1,9 @@
 <?
-	function preprocess () {
-	}
+function preprocess () {
+}
 	
-	function calculate () {
-		$vars = "substitute (" . str_replace ("\n", "), substitute (", trim (getRK_val ("x"))) . ")";
+function calculate () {
+	$vars = "substitute (" . str_replace ("\n", "), substitute (", trim (getRK_val ("x"))) . ")";
 
 ?>rk.temp.objects <- list (<? echo ($vars); ?>)
 
@@ -11,21 +11,40 @@
 # Here we construct such a temporary frame from the input variables
 rk.temp.frame <- data.frame (lapply (rk.temp.objects, eval))
 
+# calculate correlation matrix
 rk.temp <- cor (rk.temp.frame, use="<? getRK ("use"); ?>", method="<? getRK ("method"); ?>")
-<?
+<?	if (getRK_val ("do_p")) { ?>
+# calculate matrix of probabilities
+rk.temp.p <- matrix (nrow = length (rk.temp.objects), ncol = length (rk.temp.objects))
+local (
+	for (i in 1:length (rk.temp.objects)) {
+		for (j in i:length (rk.temp.objects)) {
+			if (i != j) {
+				t <- cor.test (eval (rk.temp.objects[[i]]), eval (rk.temp.objects[[j]]), use="<? getRK ("use"); ?>", method="<? getRK ("method"); ?>")
+				rk.temp.p[i, j] <<- t$p.value
+				rk.temp.p[j, i] <<- t$parameter["df"]
+			}
+		}
 	}
-	
-	function printout () {
+)
+<?	}
+}
+
+function printout () {
 ?>
 rk.header ("Correlation Matrix", parameters=list ("Method", "<? getRK ("method"); ?>", "Exclusion", "<? getRK ("use"); ?>"))
-rk.temp <- data.frame (I (sapply (rk.temp.objects, FUN=function (x) { rk.get.description (x, is.substitute=TRUE)})), as.data.frame (rk.temp))
 
-rk.results (rk.temp, titles=c ('Variable Name', sapply (rk.temp.objects, rk.get.short.name)))
+rk.temp <- data.frame (I (sapply (rk.temp.objects, FUN=function (x) rk.get.description (x, is.substitute=TRUE))), as.data.frame (rk.temp))
+rk.results (rk.temp, titles=c ('Coefficient', sapply (rk.temp.objects, rk.get.short.name)))
+
+<?	if (getRK_val ("do_p")) { ?>
+rk.temp.p <- data.frame (I (sapply (rk.temp.objects, FUN=function (x) rk.get.description (x, is.substitute=TRUE))), as.data.frame (rk.temp.p))
+rk.results (rk.temp.p, titles=c ('df \\ p', sapply (rk.temp.objects, rk.get.short.name)))
+<?	}
+}
+
+function cleanup () {
+?>rm (list=grep ("^rk.temp", ls (), value=TRUE))
 <?
-	}
-	
-	function cleanup () {
-?>rm (rk.temp)
-<?
-	}
+}
 ?>

Modified: trunk/rkward/rkward/plugins/analysis/corr_matrix/description.xml
===================================================================
--- trunk/rkward/rkward/plugins/analysis/corr_matrix/description.xml	2007-02-05 14:54:46 UTC (rev 1326)
+++ trunk/rkward/rkward/plugins/analysis/corr_matrix/description.xml	2007-02-05 18:25:51 UTC (rev 1327)
@@ -12,6 +12,7 @@
 				</row>
 			</tab>
 			<tab label="options">
+				<checkbox id="do_p" label="Calculate p values" checked="true"/>
 				<radio id="method" label="Method">
 					<option value="pearson" label="Pearson"/>
 					<option value="kendall" label="Kendall"/>


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the rkward-tracker mailing list