[rkward-cvs] SF.net SVN: rkward:[2616] trunk/rkward
tfry at users.sourceforge.net
tfry at users.sourceforge.net
Thu Aug 20 16:11:39 UTC 2009
Revision: 2616
http://rkward.svn.sourceforge.net/rkward/?rev=2616&view=rev
Author: tfry
Date: 2009-08-20 16:11:39 +0000 (Thu, 20 Aug 2009)
Log Message:
-----------
Start writing tests for the analysis plugins
Modified Paths:
--------------
trunk/rkward/ChangeLog
trunk/rkward/tests/all_tests.R
Added Paths:
-----------
trunk/rkward/tests/analysis_plugins/
trunk/rkward/tests/analysis_plugins/RKTestStandard.basic_statistics_a.rkcommands.R
trunk/rkward/tests/analysis_plugins/RKTestStandard.basic_statistics_a.rkout
trunk/rkward/tests/analysis_plugins/RKTestStandard.basic_statistics_b.rkcommands.R
trunk/rkward/tests/analysis_plugins/RKTestStandard.basic_statistics_b.rkout
trunk/rkward/tests/analysis_plugins/RKTestStandard.correlation_matrix.rkcommands.R
trunk/rkward/tests/analysis_plugins/RKTestStandard.correlation_matrix.rkout
trunk/rkward/tests/analysis_plugins/RKTestStandard.correlation_matrix_plot.rkcommands.R
trunk/rkward/tests/analysis_plugins/RKTestStandard.correlation_matrix_plot.rkout
trunk/rkward/tests/analysis_plugins/RKTestStandard.descriptive_stats.rkcommands.R
trunk/rkward/tests/analysis_plugins/RKTestStandard.descriptive_stats.rkout
trunk/rkward/tests/analysis_plugins/RKTestStandard.t_test_two_vars.rkcommands.R
trunk/rkward/tests/analysis_plugins/RKTestStandard.t_test_two_vars.rkout
trunk/rkward/tests/analysis_plugins/RKTestStandard.wilcoxon_test.rkcommands.R
trunk/rkward/tests/analysis_plugins/RKTestStandard.wilcoxon_test.rkout
trunk/rkward/tests/analysis_plugins.R
Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog 2009-08-20 16:05:37 UTC (rev 2615)
+++ trunk/rkward/ChangeLog 2009-08-20 16:11:39 UTC (rev 2616)
@@ -1,4 +1,4 @@
-- Tolerate missing libraries in testing framework TODO: - Update Wiki! - Encourage running 'make plugintests' after install in all relevant places
+- Tolerate missing libraries in testing framework TODO: - Encourage running 'make plugintests' after install in all relevant places
- Double-clicking an item in the workspace browser now opens an object viewer, or (if possible) editor
- Safeguard against removal of essential packages via the GUI
- Add context menu action to unload packages in the workspace browser window
Modified: trunk/rkward/tests/all_tests.R
===================================================================
--- trunk/rkward/tests/all_tests.R 2009-08-20 16:05:37 UTC (rev 2615)
+++ trunk/rkward/tests/all_tests.R 2009-08-20 16:11:39 UTC (rev 2616)
@@ -1,7 +1,7 @@
if (!isClass ("RKTestSuite")) source ("test_framework.R")
## add your test suite files, to this vector:
-testsuites <- c ("rkward_application_tests.R", "import_export_plugins.R", "item_response_theory.R")
+testsuites <- c ("rkward_application_tests.R", "import_export_plugins.R", "item_response_theory.R", "analysis_plugins.R")
allresults <- new ("RKTestResult")
for (testsuite in testsuites) {
Added: trunk/rkward/tests/analysis_plugins/RKTestStandard.basic_statistics_a.rkcommands.R
===================================================================
--- trunk/rkward/tests/analysis_plugins/RKTestStandard.basic_statistics_a.rkcommands.R (rev 0)
+++ trunk/rkward/tests/analysis_plugins/RKTestStandard.basic_statistics_a.rkcommands.R 2009-08-20 16:11:39 UTC (rev 2616)
@@ -0,0 +1,52 @@
+local({
+## Prepare
+## Compute
+vars <- list (substitute (women[["weight"]]), substitute (test50x))
+results <- data.frame ('Variable Name'=rep (NA, length (vars)), check.names=FALSE)
+
+for (i in 1:length (vars)) {
+ var <- eval (vars[[i]], envir=globalenv());
+ results[i, 'Variable Name'] <- rk.get.description(vars[[i]], is.substitute=TRUE)
+
+ results[i, 'Number of obs'] <- length(var)
+ results[i, 'Number of missing values'] <- sum(is.na(var))
+ results[i, 'Mean'] <- mean(var,na.rm=TRUE)
+ results[i, 'Variance'] <- var(var,na.rm=TRUE)
+ results[i, 'Sd'] <- sd(var,na.rm=TRUE)
+ results[i, 'Minimum'] <- min(var,na.rm=TRUE)
+ results[i, 'Maximum'] <- max(var,na.rm=TRUE)
+ results[i, 'Median'] <- median(var,na.rm=TRUE)
+ results[i, 'Inter Quartile Range'] <- IQR(var,na.rm=TRUE)
+ temp <- quantile (var,na.rm=TRUE)
+ results[i, 'Quartiles'] <- paste (names (temp), temp, sep=": ", collapse=" ")
+ temp <- quantile (var, probs=seq (0, 1, length.out=6), na.rm=TRUE)
+ results[i, 'Quantiles'] <- paste (names (temp), temp, sep=": ", collapse=" ")
+
+ #robust statistics
+ results[i, 'Trimmed Mean'] <- mean (var, trim=0.05000000, na.rm=TRUE)
+ results[i, 'Median Absolute Deviation'] <- mad (var, constant=1.46280000, na.rm=TRUE)
+ require ("MASS")
+ temp <- list (c('Location Estimate','Mad scale estimate'), c(NA,NA))
+ try({
+ temp <- hubers (var, k = 1.50000000,tol=0.070000, mu=3, s=,initmu =median(var))
+ })
+ results[i, 'Huber M-Estimator'] <- paste (temp[[1]], temp[[2]], sep=": ", collapse=" ")
+}
+
+# store results
+'my.data' <- results
+## Print result
+rk.header ("Univariate statistics", parameters=list (
+"Remove Missing values", TRUE, "Trimmed value for trimmed mean", "0.05000000"
+, "Constant for the MAD estimation", "1.46280000"
+, "Winsorized values for Huber estimator", "1.50000000"
+, "Tolerance in Huber estimator", "0.070000"
+, "Mu for Huber estimator", "3"
+, "S for Huber estimator", ""
+, "Initial value", "median"
+))
+
+rk.results (results)
+})
+.rk.rerun.plugin.link(plugin="rkward::basic_statistics", settings="autre.real=6.000000\nconstMad.real=1.46280000\ncustomMu.state=1\ncustomS.state=1\nhuber.state=1\ninitmu.string=median\nirq.state=1\nlength.state=1\nmad.state=1\nmaximum.state=1\nmean.state=1\nmedian.state=1\nminimum.state=1\nmu.text=3\nnarm.state=1\nnbmaximum.real=0.000000\nnbminimum.real=0.000000\nnom.selection=my.data\npourcent.real=0.05000000\nquartile.state=1\nresult.state=1\ns.text=\nsd.state=1\ntol.real=0.070000\ntrim.state=1\nvari.state=1\nwinsor.real=1.50000000\nz.available=women[[\\\"weight\\\"]]\\ntest50x", label="Run again")
+.rk.make.hr()
Added: trunk/rkward/tests/analysis_plugins/RKTestStandard.basic_statistics_a.rkout
===================================================================
--- trunk/rkward/tests/analysis_plugins/RKTestStandard.basic_statistics_a.rkout (rev 0)
+++ trunk/rkward/tests/analysis_plugins/RKTestStandard.basic_statistics_a.rkout 2009-08-20 16:11:39 UTC (rev 2616)
@@ -0,0 +1,18 @@
+<h1>Univariate statistics</h1>
+<h2>Parameters</h2>
+<ul><li>Remove Missing values: TRUE</li>
+<li>Trimmed value for trimmed mean: 0.05000000</li>
+<li>Constant for the MAD estimation: 1.46280000</li>
+<li>Winsorized values for Huber estimator: 1.50000000</li>
+<li>Tolerance in Huber estimator: 0.070000</li>
+<li>Mu for Huber estimator: 3</li>
+<li>S for Huber estimator: </li>
+<li>Initial value: median</li>
+</ul>
+DATE<br>
+<table border="1">
+<tr><td>Variable Name</td><td>Number of obs</td><td>Number of missing values</td><td>Mean</td><td>Variance</td><td>Sd</td><td>Minimum</td><td>Maximum</td><td>Median</td><td>Inter Quartile Range</td><td>Quartiles</td><td>Quantiles</td><td>Trimmed Mean</td><td>Median Absolute Deviation</td><td>Huber M-Estimator</td></tr>
+<tr><td>weight</td><td>15</td><td>0</td><td>136.73</td><td>240.21</td><td>15.499</td><td>115</td><td>164</td><td>135</td><td>23.5</td><td>0%: 115 25%: 124.5 50%: 135 75%: 148 100%: 164</td><td>0%: 115 20%: 122.4 40%: 130.8 60%: 140.2 80%: 150.8 100%: 164</td><td>136.73</td><td>17.554</td><td>3: 143.017677999144</td></tr>
+<tr><td>test50x</td><td>50</td><td>0</td><td>125.5</td><td>212.5</td><td>14.577</td><td>101</td><td>150</td><td>125.5</td><td>24.5</td><td>0%: 101 25%: 113.25 50%: 125.5 75%: 137.75 100%: 150</td><td>0%: 101 20%: 110.8 40%: 120.6 60%: 130.4 80%: 140.2 100%: 150</td><td>125.5</td><td>18.285</td><td>3: 138.260549866364</td></tr>
+</table>
+<a href="rkward://runplugin/rkward::basic_statistics/autre.real=6.000000%0aconstMad.real=1.46280000%0acustomMu.state=1%0acustomS.state=1%0ahuber.state=1%0ainitmu.string=median%0airq.state=1%0alength.state=1%0amad.state=1%0amaximum.state=1%0amean.state=1%0amedian.state=1%0aminimum.state=1%0amu.text=3%0anarm.state=1%0anbmaximum.real=0.000000%0anbminimum.real=0.000000%0anom.selection=my.data%0apourcent.real=0.05000000%0aquartile.state=1%0aresult.state=1%0as.text=%0asd.state=1%0atol.real=0.070000%0atrim.state=1%0avari.state=1%0awinsor.real=1.50000000%0az.available=women%5b%5b%5c%22weight%5c%22%5d%5d%5cntest50x">Run again</a>
\ No newline at end of file
Added: trunk/rkward/tests/analysis_plugins/RKTestStandard.basic_statistics_b.rkcommands.R
===================================================================
--- trunk/rkward/tests/analysis_plugins/RKTestStandard.basic_statistics_b.rkcommands.R (rev 0)
+++ trunk/rkward/tests/analysis_plugins/RKTestStandard.basic_statistics_b.rkcommands.R 2009-08-20 16:11:39 UTC (rev 2616)
@@ -0,0 +1,28 @@
+local({
+## Prepare
+## Compute
+vars <- list (substitute (test10x), substitute (women[["height"]]))
+results <- data.frame ('Variable Name'=rep (NA, length (vars)), check.names=FALSE)
+
+for (i in 1:length (vars)) {
+ var <- eval (vars[[i]], envir=globalenv());
+ results[i, 'Variable Name'] <- rk.get.description(vars[[i]], is.substitute=TRUE)
+
+ if (length (var) >= 2) {
+ results[i, 'Minimum values'] <- paste (sort(var, decreasing=FALSE, na.last=TRUE)[1:2], collapse=" ")
+ }
+ if (length (var) >= 3) {
+ results[i, 'Maximum values'] <- paste (sort(var, decreasing=TRUE, na.last=TRUE)[1:3], collapse=" ")
+ }
+
+ #robust statistics
+}
+
+## Print result
+rk.header ("Univariate statistics", parameters=list (
+"Remove Missing values", TRUE))
+
+rk.results (results)
+})
+.rk.rerun.plugin.link(plugin="rkward::basic_statistics", settings="autre.real=0.000000\nhuber.state=\nirq.state=0\nlength.state=0\nmad.state=\nmaximum.state=0\nmean.state=0\nmedian.state=0\nminimum.state=0\nnarm.state=1\nnbmaximum.real=3.000000\nnbminimum.real=2.000000\nquartile.state=0\nresult.state=\nsd.state=0\ntrim.state=\nvari.state=0\nz.available=test10x\\nwomen[[\\\"height\\\"]]", label="Run again")
+.rk.make.hr()
Added: trunk/rkward/tests/analysis_plugins/RKTestStandard.basic_statistics_b.rkout
===================================================================
--- trunk/rkward/tests/analysis_plugins/RKTestStandard.basic_statistics_b.rkout (rev 0)
+++ trunk/rkward/tests/analysis_plugins/RKTestStandard.basic_statistics_b.rkout 2009-08-20 16:11:39 UTC (rev 2616)
@@ -0,0 +1,11 @@
+<h1>Univariate statistics</h1>
+<h2>Parameters</h2>
+<ul><li>Remove Missing values: TRUE</li>
+</ul>
+DATE<br>
+<table border="1">
+<tr><td>Variable Name</td><td>Minimum values</td><td>Maximum values</td></tr>
+<tr><td>test10x</td><td>101 102</td><td>110 109 108</td></tr>
+<tr><td>height</td><td>58 59</td><td>72 71 70</td></tr>
+</table>
+<a href="rkward://runplugin/rkward::basic_statistics/autre.real=0.000000%0ahuber.state=%0airq.state=0%0alength.state=0%0amad.state=%0amaximum.state=0%0amean.state=0%0amedian.state=0%0aminimum.state=0%0anarm.state=1%0anbmaximum.real=3.000000%0anbminimum.real=2.000000%0aquartile.state=0%0aresult.state=%0asd.state=0%0atrim.state=%0avari.state=0%0az.available=test10x%5cnwomen%5b%5b%5c%22height%5c%22%5d%5d">Run again</a>
\ No newline at end of file
Added: trunk/rkward/tests/analysis_plugins/RKTestStandard.correlation_matrix.rkcommands.R
===================================================================
--- trunk/rkward/tests/analysis_plugins/RKTestStandard.correlation_matrix.rkcommands.R (rev 0)
+++ trunk/rkward/tests/analysis_plugins/RKTestStandard.correlation_matrix.rkcommands.R 2009-08-20 16:11:39 UTC (rev 2616)
@@ -0,0 +1,53 @@
+local({
+## Prepare
+## Compute
+objects <- list (substitute (test50x), substitute (test50y), substitute (test50z))
+
+# cor requires all objects to be inside the same data.frame.
+# Here we construct such a temporary frame from the input variables
+data <- data.frame (lapply (objects, function (x) eval (x, envir=globalenv ())))
+
+# calculate correlation matrix
+result <- cor (data, use="pairwise.complete.obs", method="pearson")
+# calculate matrix of probabilities
+result.p <- matrix (nrow = length (data), ncol = length (data))
+for (i in 1:length (data)) {
+ for (j in i:length (data)) {
+ if (i != j) {
+ t <- cor.test (data[[i]], data[[j]], method="pearson")
+ result.p[i, j] <- t$p.value
+ result.p[j, i] <- sum (complete.cases (data[[i]], data[[j]]))
+ }
+ }
+}
+## Print result
+rk.header ("Correlation Matrix", parameters=list ("Method", "pearson", "Exclusion", "pairwise.complete.obs"))
+
+result <- data.frame (I (sapply (objects, FUN=function (x) rk.get.description (x, is.substitute=TRUE))), as.data.frame (result))
+rk.results (result, titles=c ('Coefficient', sapply (objects, rk.get.short.name)))
+
+result.p <- data.frame (I (sapply (objects, FUN=function (x) rk.get.description (x, is.substitute=TRUE))), as.data.frame (result.p))
+rk.results (result.p, titles=c ('n \\ p', sapply (objects, rk.get.short.name)))
+})
+.rk.rerun.plugin.link(plugin="rkward::corr_matrix", settings="do_p.state=1\nmethod.string=pearson\nuse.string=pairwise\nx.available=test50x\\ntest50y\\ntest50z", label="Run again")
+.rk.make.hr()
+local({
+## Prepare
+## Compute
+objects <- list (substitute (women[["weight"]]), substitute (women[["height"]]))
+
+# cor requires all objects to be inside the same data.frame.
+# Here we construct such a temporary frame from the input variables
+data <- data.frame (lapply (objects, function (x) eval (x, envir=globalenv ())))
+
+# 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"))
+
+result <- data.frame (I (sapply (objects, FUN=function (x) rk.get.description (x, is.substitute=TRUE))), as.data.frame (result))
+rk.results (result, titles=c ('Coefficient', sapply (objects, rk.get.short.name)))
+
+})
+.rk.rerun.plugin.link(plugin="rkward::corr_matrix", settings="do_p.state=\nmethod.string=pearson\nuse.string=pairwise\nx.available=women[[\\\"weight\\\"]]\\nwomen[[\\\"height\\\"]]", label="Run again")
+.rk.make.hr()
Added: trunk/rkward/tests/analysis_plugins/RKTestStandard.correlation_matrix.rkout
===================================================================
--- trunk/rkward/tests/analysis_plugins/RKTestStandard.correlation_matrix.rkout (rev 0)
+++ trunk/rkward/tests/analysis_plugins/RKTestStandard.correlation_matrix.rkout 2009-08-20 16:11:39 UTC (rev 2616)
@@ -0,0 +1,30 @@
+<h1>Correlation Matrix</h1>
+<h2>Parameters</h2>
+<ul><li>Method: pearson</li>
+<li>Exclusion: pairwise.complete.obs</li>
+</ul>
+DATE<br>
+<table border="1">
+<tr><td>Coefficient</td><td>test50x</td><td>test50y</td><td>test50z</td></tr>
+<tr><td>test50x</td><td>1</td><td>1</td><td>1</td></tr>
+<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>
+<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>
+<tr><td>test50y</td><td>50</td><td>NA</td><td>0</td></tr>
+<tr><td>test50z</td><td>50</td><td>50</td><td>NA</td></tr>
+</table>
+<a href="rkward://runplugin/rkward::corr_matrix/do_p.state=1%0amethod.string=pearson%0ause.string=pairwise%0ax.available=test50x%5cntest50y%5cntest50z">Run again</a><h1>Correlation Matrix</h1>
+<h2>Parameters</h2>
+<ul><li>Method: pearson</li>
+<li>Exclusion: pairwise.complete.obs</li>
+</ul>
+DATE<br>
+<table border="1">
+<tr><td>Coefficient</td><td>weight</td><td>height</td></tr>
+<tr><td>weight</td><td>1</td><td>0.9955</td></tr>
+<tr><td>height</td><td>0.9955</td><td>1</td></tr>
+</table>
+<a href="rkward://runplugin/rkward::corr_matrix/do_p.state=%0amethod.string=pearson%0ause.string=pairwise%0ax.available=women%5b%5b%5c%22weight%5c%22%5d%5d%5cnwomen%5b%5b%5c%22height%5c%22%5d%5d">Run again</a>
\ No newline at end of file
Added: trunk/rkward/tests/analysis_plugins/RKTestStandard.correlation_matrix_plot.rkcommands.R
===================================================================
--- trunk/rkward/tests/analysis_plugins/RKTestStandard.correlation_matrix_plot.rkcommands.R (rev 0)
+++ trunk/rkward/tests/analysis_plugins/RKTestStandard.correlation_matrix_plot.rkcommands.R 2009-08-20 16:11:39 UTC (rev 2616)
@@ -0,0 +1,38 @@
+local({
+## Prepare
+cor.graph <- function(x) {
+ panel.cor <- function(x, y, digits=3, cex.cor, use="pairwise.complete.obs", method="pearson", scale=TRUE) {
+ usr <- par("usr"); on.exit(par(usr))
+ par(usr = c(0, 1, 0, 1))
+ r <- abs(cor(x, y, use=use, method=method))
+ txt <- format(c(r, 0.123456789), digits=digits)[1]
+ if(missing(cex.cor)) cex <- 0.8/strwidth(txt)
+
+ test <- cor.test(x,y, use=use, method=method)
+ Signif <- symnum(test$p.value, corr = FALSE, na = FALSE,
+ cutpoints = c(0, 0.001, 0.01, 0.05, 0.1, 1),
+ symbols = c("***", "**", "*", ".", " "))
+
+ if(scale) text(0.5, 0.5, txt, cex = cex * r)
+ else text(0.5, 0.5, txt, cex = cex)
+ text(.8, .8, Signif, cex=cex, col=2)
+ }
+
+ pairs(x, lower.panel=panel.smooth, upper.panel=panel.cor)
+}
+## Compute
+## Print result
+data <- data.frame (rock)
+
+rk.header ("Correlation Matrix Plot", parameters=list ("Method", "pearson", "Exclusion", "pairwise.complete.obs", "Precision", "3 digits", "Scale text", "TRUE"))
+
+rk.graph.on ()
+try ({
+ cor.graph (data)
+})
+rk.graph.off ()
+
+rk.print("Legend:\t'***': p < 0.001 -- '**': p < 0.01 -- '*': p < 0.05 -- '.'': p < 0.1")
+})
+.rk.rerun.plugin.link(plugin="rkward::cor_graph", settings="digits.real=3.000000\nmethod.string=pearson\nscale.state=TRUE\nuse.string=pairwise.complete.obs\nx.available=rock", label="Run again")
+.rk.make.hr()
Added: trunk/rkward/tests/analysis_plugins/RKTestStandard.correlation_matrix_plot.rkout
===================================================================
--- trunk/rkward/tests/analysis_plugins/RKTestStandard.correlation_matrix_plot.rkout (rev 0)
+++ trunk/rkward/tests/analysis_plugins/RKTestStandard.correlation_matrix_plot.rkout 2009-08-20 16:11:39 UTC (rev 2616)
@@ -0,0 +1,10 @@
+<h1>Correlation Matrix Plot</h1>
+<h2>Parameters</h2>
+<ul><li>Method: pearson</li>
+<li>Exclusion: pairwise.complete.obs</li>
+<li>Precision: 3 digits</li>
+<li>Scale text: TRUE</li>
+</ul>
+DATE<br>
+<img src="graph.png" width="480" height="480"><br>
+<p class='character'>Legend: '***': p < 0.001 -- '**': p < 0.01 -- '*': p < 0.05 -- '.'': p < 0.1</p><a href="rkward://runplugin/rkward::cor_graph/digits.real=3.000000%0amethod.string=pearson%0ascale.state=TRUE%0ause.string=pairwise.complete.obs%0ax.available=rock">Run again</a>
\ No newline at end of file
Added: trunk/rkward/tests/analysis_plugins/RKTestStandard.descriptive_stats.rkcommands.R
===================================================================
--- trunk/rkward/tests/analysis_plugins/RKTestStandard.descriptive_stats.rkcommands.R (rev 0)
+++ trunk/rkward/tests/analysis_plugins/RKTestStandard.descriptive_stats.rkcommands.R 2009-08-20 16:11:39 UTC (rev 2616)
@@ -0,0 +1,34 @@
+local({
+## Prepare
+## Compute
+vars <- list (substitute (women[["height"]]), substitute (test10z))
+results <- data.frame ('Object'=rep (NA, length (vars)))
+for (i in 1:length (vars)) {
+ results[i, 'Object'] <- rk.get.description (vars[[i]], is.substitute=TRUE)
+ var <- eval (vars[[i]], envir=globalenv()) # fetch the real object
+
+ # we wrap each single call in a "try" statement to always continue on errors.
+ results[i, 'mean'] <- try (mean (var, trim = 0.00000000, na.rm=TRUE))
+ results[i, 'median'] <- try (median (var, na.rm=TRUE))
+ try ({
+ range <- try (range (var, na.rm=TRUE))
+ results[i, 'min'] <- range[1]
+ results[i, 'max'] <- range[2]
+ })
+ results[i, 'standard deviation'] <- try (sd (var, na.rm=TRUE))
+ results[i, 'sum'] <- try (sum (var, na.rm=TRUE))
+ results[i, 'product'] <- try (prod (var, na.rm=TRUE))
+ results[i, 'Median Absolute Deviation'] <- try (mad (var, constant = 1.46280000, na.rm=TRUE))
+ results[i, 'length of sample'] <- length (var)
+ results[i, 'number of NAs'] <- sum (is.na(var))
+}
+## Print result
+rk.header ("Descriptive statistics", parameters=list (
+ "Trim of mean", 0.00000000,
+ "Median Absolute Deviation",
+ paste ("constant:", 1.46280000, "average")))
+
+rk.results (results)
+})
+.rk.rerun.plugin.link(plugin="rkward::descriptive", settings="constMad.real=1.46280000\nlength.state=1\nmad.state=1\nmad_type.string=average\nmean.state=1\nmedian.state=1\nprod.state=1\nrange.state=1\nsd.state=1\nsum.state=1\ntrim.real=0.00000000\nx.available=women[[\\\"height\\\"]]\\ntest10z", label="Run again")
+.rk.make.hr()
Added: trunk/rkward/tests/analysis_plugins/RKTestStandard.descriptive_stats.rkout
===================================================================
--- trunk/rkward/tests/analysis_plugins/RKTestStandard.descriptive_stats.rkout (rev 0)
+++ trunk/rkward/tests/analysis_plugins/RKTestStandard.descriptive_stats.rkout 2009-08-20 16:11:39 UTC (rev 2616)
@@ -0,0 +1,12 @@
+<h1>Descriptive statistics</h1>
+<h2>Parameters</h2>
+<ul><li>Trim of mean: 0</li>
+<li>Median Absolute Deviation: constant: 1.4628 average</li>
+</ul>
+DATE<br>
+<table border="1">
+<tr><td>Object</td><td>mean</td><td>median</td><td>min</td><td>max</td><td>standard deviation</td><td>sum</td><td>product</td><td>Median Absolute Deviation</td><td>length of sample</td><td>number of NAs</td></tr>
+<tr><td>height</td><td>65</td><td>65</td><td>58</td><td>72</td><td>4.4721</td><td>975</td><td>1.5110e+27</td><td>5.8512</td><td>15</td><td>0</td></tr>
+<tr><td>test10z</td><td>22</td><td>22</td><td>4</td><td>40</td><td>12.111</td><td>220</td><td>3.8051e+12</td><td>14.628</td><td>11</td><td>1</td></tr>
+</table>
+<a href="rkward://runplugin/rkward::descriptive/constMad.real=1.46280000%0alength.state=1%0amad.state=1%0amad_type.string=average%0amean.state=1%0amedian.state=1%0aprod.state=1%0arange.state=1%0asd.state=1%0asum.state=1%0atrim.real=0.00000000%0ax.available=women%5b%5b%5c%22height%5c%22%5d%5d%5cntest10z">Run again</a>
\ No newline at end of file
Added: trunk/rkward/tests/analysis_plugins/RKTestStandard.t_test_two_vars.rkcommands.R
===================================================================
--- trunk/rkward/tests/analysis_plugins/RKTestStandard.t_test_two_vars.rkcommands.R (rev 0)
+++ trunk/rkward/tests/analysis_plugins/RKTestStandard.t_test_two_vars.rkcommands.R 2009-08-20 16:11:39 UTC (rev 2616)
@@ -0,0 +1,43 @@
+local({
+## Prepare
+names <- rk.get.description (test50x, test50y)
+## Compute
+result <- t.test (test50x, test50y, alternative="two.sided")
+## Print result
+rk.header (result$method,
+ parameters=list ("Comparing", paste (names[1], "against", names[2]),
+ "H1", rk.describe.alternative (result),
+ "Equal variances", "not assumed"))
+
+rk.results (list (
+ 'Variable Name'=names,
+ 'estimated mean'=result$estimate,
+ 'degrees of freedom'=result$parameter,
+ t=result$statistic,
+ p=result$p.value,
+ 'confidence interval percent'=(100 * attr(result$conf.int, "conf.level")),
+ 'confidence interval of difference'=result$conf.int ))
+})
+.rk.rerun.plugin.link(plugin="rkward::t_test_two_vars", settings="confint.state=1\nconflevel.real=0.95000000\nhypothesis.string=two.sided\npaired.state=0\nvarequal.state=0\nx.available=test50x\ny.available=test50y", label="Run again")
+.rk.make.hr()
+local({
+## Prepare
+names <- rk.get.description (test10y, test10z)
+## Compute
+result <- t.test (test10y, test10z, alternative="less", paired=TRUE, conf.level=0.99000000)
+## Print result
+rk.header (result$method,
+ parameters=list ("Comparing", paste (names[1], "against", names[2]),
+ "H1", rk.describe.alternative (result)))
+
+rk.results (list (
+ 'Variable Name'=names,
+ 'estimated mean'=result$estimate,
+ 'degrees of freedom'=result$parameter,
+ t=result$statistic,
+ p=result$p.value,
+ 'confidence interval percent'=(100 * attr(result$conf.int, "conf.level")),
+ 'confidence interval of difference'=result$conf.int ))
+})
+.rk.rerun.plugin.link(plugin="rkward::t_test_two_vars", settings="confint.state=1\nconflevel.real=0.99000000\nhypothesis.string=less\npaired.state=1\nx.available=test10y\ny.available=test10z", label="Run again")
+.rk.make.hr()
Added: trunk/rkward/tests/analysis_plugins/RKTestStandard.t_test_two_vars.rkout
===================================================================
--- trunk/rkward/tests/analysis_plugins/RKTestStandard.t_test_two_vars.rkout (rev 0)
+++ trunk/rkward/tests/analysis_plugins/RKTestStandard.t_test_two_vars.rkout 2009-08-20 16:11:39 UTC (rev 2616)
@@ -0,0 +1,27 @@
+<h1>Welch Two Sample t-test</h1>
+<h2>Parameters</h2>
+<ul><li>Comparing: test50x against test50y</li>
+<li>H1: true difference in means is not equal to 0</li>
+<li>Equal variances: not assumed</li>
+</ul>
+DATE<br>
+<table border="1">
+<tr><td>Variable Name</td><td>estimated mean</td><td>degrees of freedom</td><td>t</td><td>p</td><td>confidence interval percent</td><td>confidence interval of difference</td></tr>
+<tr><td>test50x
+<br/>test50y</td><td>125.5
+<br/>225.5</td><td>98</td><td>-34.3</td><td>2.1436e-56</td><td>95</td><td>-105.79
+<br/>-94.214</td></tr>
+</table>
+<a href="rkward://runplugin/rkward::t_test_two_vars/confint.state=1%0aconflevel.real=0.95000000%0ahypothesis.string=two.sided%0apaired.state=0%0avarequal.state=0%0ax.available=test50x%0ay.available=test50y">Run again</a><h1>Paired t-test</h1>
+<h2>Parameters</h2>
+<ul><li>Comparing: test10y against test10z</li>
+<li>H1: true difference in means is less than 0</li>
+</ul>
+DATE<br>
+<table border="1">
+<tr><td>Variable Name</td><td>estimated mean</td><td>degrees of freedom</td><td>t</td><td>p</td><td>confidence interval percent</td><td>confidence interval of difference</td></tr>
+<tr><td>test10y
+<br/>test10z</td><td>183.5</td><td>9</td><td>63.886</td><td>1</td><td>99</td><td>-Inf
+<br/>191.60</td></tr>
+</table>
+<a href="rkward://runplugin/rkward::t_test_two_vars/confint.state=1%0aconflevel.real=0.99000000%0ahypothesis.string=less%0apaired.state=1%0ax.available=test10y%0ay.available=test10z">Run again</a>
\ No newline at end of file
Added: trunk/rkward/tests/analysis_plugins/RKTestStandard.wilcoxon_test.rkcommands.R
===================================================================
--- trunk/rkward/tests/analysis_plugins/RKTestStandard.wilcoxon_test.rkcommands.R (rev 0)
+++ trunk/rkward/tests/analysis_plugins/RKTestStandard.wilcoxon_test.rkcommands.R 2009-08-20 16:11:39 UTC (rev 2616)
@@ -0,0 +1,49 @@
+local({
+## Prepare
+names = rk.get.description (test50x)
+## Compute
+result <- wilcox.test (test50x, alternative = "two.sided", mu = 0.00000000, exact=TRUE, correct = FALSE, conf.int = TRUE)
+
+## Print result
+rk.header (result$method,
+ parameters=list ("Comparing", paste (names, collapse=" against "),
+ "H1", rk.describe.alternative (result),
+ "Continuity correction in normal approximation for p-value", "FALSE",
+ "Compute exact p-value", "yes", "Paired test", "FALSE",
+ "mu", "0.00000000"))
+
+rk.results (list (
+ 'Variable Names'=names,
+ 'statistic'=result$statistic,
+ 'Location Shift'=result$null.value,
+ 'Hypothesis'=result$alternative,
+ p=result$p.value,
+ 'confidence interval percent'=(100 * attr(result$conf.int, "conf.level")),
+ 'confidence interval of difference'=result$conf.int,
+ 'Difference in Location' = result$estimate))
+})
+.rk.rerun.plugin.link(plugin="rkward::wilcoxon_test", settings="alternative.string=two.sided\nconfint.state=TRUE\nconflevel.real=0.95000000\ncorrect.state=FALSE\nexact.string=yes\nmu.real=0.00000000\nx.available=test50x\ny.available=", label="Run again")
+.rk.make.hr()
+local({
+## Prepare
+names = rk.get.description (test50x, test50y)
+## Compute
+result <- wilcox.test (test50x, test50y, alternative = "less", mu = 0.00000000, paired = TRUE, correct = TRUE, conf.int = FALSE)
+
+## Print result
+rk.header (result$method,
+ parameters=list ("Comparing", paste (names, collapse=" against "),
+ "H1", rk.describe.alternative (result),
+ "Continuity correction in normal approximation for p-value", "TRUE",
+ "Compute exact p-value", "automatic", "Paired test", "TRUE",
+ "mu", "0.00000000"))
+
+rk.results (list (
+ 'Variable Names'=names,
+ 'statistic'=result$statistic,
+ 'Location Shift'=result$null.value,
+ 'Hypothesis'=result$alternative,
+ p=result$p.value))
+})
+.rk.rerun.plugin.link(plugin="rkward::wilcoxon_test", settings="alternative.string=less\nconfint.state=FALSE\ncorrect.state=TRUE\nexact.string=automatic\nmu.real=0.00000000\npaired.state=TRUE\nx.available=test50x\ny.available=test50y", label="Run again")
+.rk.make.hr()
Added: trunk/rkward/tests/analysis_plugins/RKTestStandard.wilcoxon_test.rkout
===================================================================
--- trunk/rkward/tests/analysis_plugins/RKTestStandard.wilcoxon_test.rkout (rev 0)
+++ trunk/rkward/tests/analysis_plugins/RKTestStandard.wilcoxon_test.rkout 2009-08-20 16:11:39 UTC (rev 2616)
@@ -0,0 +1,31 @@
+<h1>Wilcoxon signed rank test</h1>
+<h2>Parameters</h2>
+<ul><li>Comparing: test50x</li>
+<li>H1: true location is not equal to 0</li>
+<li>Continuity correction in normal approximation for p-value: FALSE</li>
+<li>Compute exact p-value: yes</li>
+<li>Paired test: FALSE</li>
+<li>mu: 0.00000000</li>
+</ul>
+DATE<br>
+<table border="1">
+<tr><td>Variable Names</td><td>statistic</td><td>Location Shift</td><td>Hypothesis</td><td>p</td><td>confidence interval percent</td><td>confidence interval of difference</td><td>Difference in Location</td></tr>
+<tr><td>test50x</td><td>1275</td><td>0</td><td>two.sided</td><td>1.7764e-15</td><td>95</td><td>121
+<br/>130</td><td>125.5</td></tr>
+</table>
+<a href="rkward://runplugin/rkward::wilcoxon_test/alternative.string=two.sided%0aconfint.state=TRUE%0aconflevel.real=0.95000000%0acorrect.state=FALSE%0aexact.string=yes%0amu.real=0.00000000%0ax.available=test50x%0ay.available=">Run again</a><h1>Wilcoxon signed rank test with continuity correction</h1>
+<h2>Parameters</h2>
+<ul><li>Comparing: test50x against test50y</li>
+<li>H1: true location shift is less than 0</li>
+<li>Continuity correction in normal approximation for p-value: TRUE</li>
+<li>Compute exact p-value: automatic</li>
+<li>Paired test: TRUE</li>
+<li>mu: 0.00000000</li>
+</ul>
+DATE<br>
+<table border="1">
+<tr><td>Variable Names</td><td>statistic</td><td>Location Shift</td><td>Hypothesis</td><td>p</td></tr>
+<tr><td>test50x
+<br/>test50y</td><td>0</td><td>0</td><td>less</td><td>8.0007e-13</td></tr>
+</table>
+<a href="rkward://runplugin/rkward::wilcoxon_test/alternative.string=less%0aconfint.state=FALSE%0acorrect.state=TRUE%0aexact.string=automatic%0amu.real=0.00000000%0apaired.state=TRUE%0ax.available=test50x%0ay.available=test50y">Run again</a>
\ No newline at end of file
Added: trunk/rkward/tests/analysis_plugins.R
===================================================================
--- trunk/rkward/tests/analysis_plugins.R (rev 0)
+++ trunk/rkward/tests/analysis_plugins.R 2009-08-20 16:11:39 UTC (rev 2616)
@@ -0,0 +1,67 @@
+## intro
+# This should be the first line in each test suite file: Include the
+# test framework, unless already included (multiple inclusion would not
+# really do any harm either, though
+if (!isClass ("RKTestSuite")) source ("test_framework.R")
+
+## definition of the test suite
+suite <- new ("RKTestSuite", id="analysis_plugins",
+ # place here libraries that are required for *all* tests in this suite, or highly likely to be installed
+ libraries = c ("R2HTML", "datasets", "stats"),
+ # initCalls are run *before* any tests. Use this to set up the environment
+ initCalls = list (
+ function () {
+ # prepare some different files for loading
+ library ("datasets")
+ data (women)
+ data (warpbreaks)
+ data (rock)
+
+ assign ("test50x", 100+c (1:50), envir=globalenv())
+ assign ("test50y", 200+c (1:50), envir=globalenv())
+ assign ("test50z", c (1:50)*4, envir=globalenv())
+ 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())
+ }
+ ## the tests
+ ), tests = list (
+ new ("RKTest", id="basic_statistics_a", call=function () {
+ rk.call.plugin ("rkward::basic_statistics", autre.real="6.000000", constMad.real="1.46280000", customMu.state="1", customS.state="1", huber.state="1", initmu.string="median", irq.state="1", length.state="1", mad.state="1", maximum.state="1", mean.state="1", median.state="1", minimum.state="1", mu.text="3", narm.state="1", nbmaximum.real="0.000000", nbminimum.real="0.000000", nom.selection="my.data", pourcent.real="0.05000000", quartile.state="1", result.state="1", s.text="", sd.state="1", tol.real="0.070000", trim.state="1", vari.state="1", winsor.real="1.50000000", z.available="women[[\"weight\"]]\ntest50x", submit.mode="submit")
+ }, libraries=c("MASS")),
+ new ("RKTest", id="basic_statistics_b", call=function () {
+ rk.call.plugin ("rkward::basic_statistics", autre.real="0.000000", huber.state="", irq.state="0", length.state="0", mad.state="", maximum.state="0", mean.state="0", median.state="0", minimum.state="0", narm.state="1", nbmaximum.real="3.000000", nbminimum.real="2.000000", quartile.state="0", result.state="", sd.state="0", trim.state="", vari.state="0", z.available="test10x\nwomen[[\"height\"]]", submit.mode="submit")
+ }),
+ 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="pearson", use.string="pairwise", x.available="women[[\"weight\"]]\nwomen[[\"height\"]]", submit.mode="submit")
+ }),
+ new ("RKTest", id="correlation_matrix_plot", call=function () {
+ rk.call.plugin ("rkward::cor_graph", digits.real="3.000000", method.string="pearson", scale.state="TRUE", use.string="pairwise.complete.obs", x.available="rock", submit.mode="submit")
+ }),
+ new ("RKTest", id="descriptive_stats", call=function () {
+ rk.call.plugin ("rkward::descriptive", constMad.real="1.46280000", length.state="1", mad.state="1", mad_type.string="average", mean.state="1", median.state="1", prod.state="1", range.state="1", sd.state="1", sum.state="1", trim.real="0.00000000", x.available="women[[\"height\"]]\ntest10z", submit.mode="submit")
+ }),
+ new ("RKTest", id="t_test_two_vars", call=function () {
+ rk.call.plugin ("rkward::t_test_two_vars", confint.state="1", conflevel.real="0.95000000", hypothesis.string="two.sided", paired.state="0", varequal.state="0", x.available="test50x", y.available="test50y", submit.mode="submit")
+
+ rk.call.plugin ("rkward::t_test_two_vars", confint.state="1", conflevel.real="0.99000000", hypothesis.string="less", paired.state="1", x.available="test10y", y.available="test10z", submit.mode="submit")
+ }),
+ new ("RKTest", id="wilcoxon_test", call=function () {
+ rk.call.plugin ("rkward::wilcoxon_test", alternative.string="two.sided", confint.state="TRUE", conflevel.real="0.95000000", correct.state="FALSE", exact.string="yes", mu.real="0.00000000", x.available="test50x", y.available="", submit.mode="submit")
+
+ rk.call.plugin ("rkward::wilcoxon_test", alternative.string="less", confint.state="FALSE", correct.state="TRUE", exact.string="automatic", mu.real="0.00000000", paired.state="TRUE", x.available="test50x", y.available="test50y", submit.mode="submit")
+ })#,
+# new ("RKTest", id="wilcoxon_exact_test", call=function () {
+# }, libraries=c ("coin"))
+ ), postCalls = list ( # like initCalls: run after all tests to clean up.
+ function () {
+ suppressWarnings (rm (list=c ("women", "warpbreaks", "rock", "test50x", "test50y", "test50z", "test10x", "test10y", "test10z"), envir=globalenv()))
+ }
+ )
+)
+
+## always store the result in "results" and print it
+results <- rktest.runRKTestSuite (suite)
+print (results)
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