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

tfry at users.sourceforge.net tfry at users.sourceforge.net
Wed Sep 26 11:31:23 UTC 2012


Revision: 4313
          http://rkward.svn.sourceforge.net/rkward/?rev=4313&view=rev
Author:   tfry
Date:     2012-09-26 11:31:22 +0000 (Wed, 26 Sep 2012)
Log Message:
-----------
Add test for polychoric correlation matrix, and adjust test standards

Modified Paths:
--------------
    trunk/rkward/ChangeLog
    trunk/rkward/rkward/plugins/analysis/corr_matrix.xml
    trunk/rkward/tests/analysis_plugins/correlation_matrix.rkcommands.R
    trunk/rkward/tests/analysis_plugins/correlation_matrix.rkout
    trunk/rkward/tests/analysis_plugins.R

Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog	2012-09-26 10:57:09 UTC (rev 4312)
+++ trunk/rkward/ChangeLog	2012-09-26 11:31:22 UTC (rev 4313)
@@ -15,7 +15,7 @@
 - Fixed: Plot history and graphical menus broken in some cases with R 2.15.0
 - Fixed: If the rkward package was loaded in a plain R session, q() and quit() still work
 - combined all Wilcoxon/Mann-Whitney-tests in one plugin (from previously two separate plugins)			TODO: adjust test(s)
-- Added polyserial/polychoric correlations to correlation matrix plugin			TODO: adjust test(s)
+- Added polyserial/polychoric correlations to correlation matrix plugin
 - Added more compression options to the "Save objects as R code" plugin
 - Added MacPorts support, see README.MacPorts and bundle build script in the macports folder
 - Added dynamically generated table-of-contents menu to output document

Modified: trunk/rkward/rkward/plugins/analysis/corr_matrix.xml
===================================================================
--- trunk/rkward/rkward/plugins/analysis/corr_matrix.xml	2012-09-26 10:57:09 UTC (rev 4312)
+++ trunk/rkward/rkward/plugins/analysis/corr_matrix.xml	2012-09-26 11:31:22 UTC (rev 4313)
@@ -20,7 +20,7 @@
 				</row>
 			</tab>
 			<tab label="Options" id="tab_Options">
-				<checkbox id="do_p" label="Calculate p values" value="true" checked="true" />
+				<checkbox id="do_p" label="Calculate p values" value="1" checked="true" />
 				<radio id="method" label="Method">
 					<option label="Pearson's product-moment correlation" value="pearson" checked="true" />
 					<option label="Kendall's tau" value="kendall" />

Modified: trunk/rkward/tests/analysis_plugins/correlation_matrix.rkcommands.R
===================================================================
--- trunk/rkward/tests/analysis_plugins/correlation_matrix.rkcommands.R	2012-09-26 10:57:09 UTC (rev 4312)
+++ trunk/rkward/tests/analysis_plugins/correlation_matrix.rkcommands.R	2012-09-26 11:31:22 UTC (rev 4313)
@@ -2,7 +2,8 @@
 ## Compute
 # cor requires all objects to be inside the same data.frame.
 # Here we construct such a temporary frame from the input variables
-data <- as.data.frame (rk.list (test50x, test50y, test50z), check.names=FALSE)
+data.list <- rk.list (test50x, test50y, test50z)
+data <- as.data.frame (data.list, check.names=FALSE)
 
 # calculate correlation matrix
 result <- cor (data, use="pairwise.complete.obs", method="pearson")
@@ -21,15 +22,43 @@
 rk.header ("Correlation Matrix", parameters=list ("Method", "pearson", "Exclusion", "pairwise.complete.obs"))
 
 rk.results (data.frame (result, check.names=FALSE), titles=c ("Coefficient", names (data)))
+rk.header ("p-values and sample size", level=4)
 rk.results (data.frame (result.p, check.names=FALSE), titles=c ("n \\ p", names (data)))
 })
 local({
+## Prepare
+require(polycor)
 ## Compute
 # cor requires all objects to be inside the same data.frame.
 # Here we construct such a temporary frame from the input variables
-data <- as.data.frame (rk.list (women[["weight"]], women[["height"]]), check.names=FALSE)
+data.list <- rk.list (test10y, test10a)
+data <- as.data.frame (data.list, check.names=FALSE)
 
 # calculate correlation matrix
+result <- matrix (nrow = length (data), ncol = length (data), dimnames=list (names (data), names (data)))
+# calculate matrix of probabilities
+result.p <- matrix (nrow = length (data), ncol = length (data), dimnames=list (names (data), names (data)))
+for (i in 1:length (data)) {
+	for (j in i:length (data)) {
+		if (i != j) {
+			t <- polychor(data[[i]], data[[j]])
+			result[i, j] <- result[j, i] <- t
+		}
+	}
+}
+## Print result
+rk.header ("Correlation Matrix", parameters=list ("Method", "polychoric", "Exclusion", "pairwise"))
+
+rk.results (data.frame (result, check.names=FALSE), titles=c ("Coefficient", names (data)))
+})
+local({
+## Compute
+# cor requires all objects to be inside the same data.frame.
+# Here we construct such a temporary frame from the input variables
+data.list <- rk.list (women[["weight"]], women[["height"]])
+data <- as.data.frame (data.list, check.names=FALSE)
+
+# calculate correlation matrix
 result <- cor (data, use="pairwise.complete.obs", method="pearson")
 ## Print result
 rk.header ("Correlation Matrix", parameters=list ("Method", "pearson", "Exclusion", "pairwise.complete.obs"))

Modified: trunk/rkward/tests/analysis_plugins/correlation_matrix.rkout
===================================================================
--- trunk/rkward/tests/analysis_plugins/correlation_matrix.rkout	2012-09-26 10:57:09 UTC (rev 4312)
+++ trunk/rkward/tests/analysis_plugins/correlation_matrix.rkout	2012-09-26 11:31:22 UTC (rev 4313)
@@ -10,6 +10,8 @@
 <tr><td>test50y</td><td>1</td><td>1</td><td>1</td></tr>
 <tr><td>test50z</td><td>1</td><td>1</td><td>1</td></tr>
 </table>
+<h4>p-values and sample size</h4>
+<br />
 <table border="1">
 <tr><td>n \ p</td><td>test50x</td><td>test50y</td><td>test50z</td></tr>
 <tr><td>test50x</td><td>NA</td><td>0</td><td>0</td></tr>
@@ -18,6 +20,17 @@
 </table>
 <h1>Correlation Matrix</h1>
 <h2>Parameters</h2>
+<ul><li>Method: polychoric</li>
+<li>Exclusion: pairwise</li>
+</ul>
+DATE<br />
+<table border="1">
+<tr><td>Coefficient</td><td>test10y</td><td>test10a</td></tr>
+<tr><td>test10y</td><td>NA</td><td>0.60718</td></tr>
+<tr><td>test10a</td><td>0.60718</td><td>NA</td></tr>
+</table>
+<h1>Correlation Matrix</h1>
+<h2>Parameters</h2>
 <ul><li>Method: pearson</li>
 <li>Exclusion: pairwise.complete.obs</li>
 </ul>

Modified: trunk/rkward/tests/analysis_plugins.R
===================================================================
--- trunk/rkward/tests/analysis_plugins.R	2012-09-26 10:57:09 UTC (rev 4312)
+++ trunk/rkward/tests/analysis_plugins.R	2012-09-26 11:31:22 UTC (rev 4313)
@@ -17,6 +17,7 @@
 			assign ("test10x", 100+c (1:10, NA), envir=globalenv())
 			assign ("test10y", 200+c (1:10, NA), envir=globalenv())
 			assign ("test10z", c (1:10, NA)*4, envir=globalenv())
+			assign ("test10a", c (1:5, 1:5, NA), envir=globalenv())
 			x <- data.frame ("A" = rep (c (1, 2), 8), "B" = rep (c (1, 1, 2, 2), 4), "C" = rep (c (1, 1, 1, 1, 2, 2, 2, 2), 2), "D"= c (rep (1, 8), rep (2, 8)))
 			x[2,2] <- NA
 			assign ("test_table", x, envir=globalenv())
@@ -32,6 +33,8 @@
 		new ("RKTest", id="correlation_matrix", call=function () {		
 			rk.call.plugin ("rkward::corr_matrix", do_p.state="1", method.string="pearson", use.string="pairwise", x.available="test50x\ntest50y\ntest50z", submit.mode="submit")
 
+			rk.call.plugin ("rkward::corr_matrix", do_p.state="", method.string="polychoric", use.string="pairwise", x.available="test10y\ntest10a", submit.mode="submit")
+
 			rk.call.plugin ("rkward::corr_matrix", do_p.state="", method.string="pearson", use.string="pairwise", x.available="women[[\"weight\"]]\nwomen[[\"height\"]]", submit.mode="submit")
 		}),
 		new ("RKTest", id="correlation_matrix_plot", call=function () {

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