[rkward-cvs] [rkward] tests: adding plugin test for power analysis -- expecting it will make it to the next release. currently commented out.

m.eik michalke meik.michalke at uni-duesseldorf.de
Thu Dec 4 15:07:53 UTC 2014


Git commit ec6bb04a8ad44ce1aa9751b52cbba15a1aced303 by m.eik michalke.
Committed on 04/12/2014 at 15:03.
Pushed by meikm into branch 'master'.

adding plugin test for power analysis -- expecting it will make it to the next release. currently commented out.

M  +4    -1    tests/analysis_plugins.R
A  +38   -0    tests/analysis_plugins/power_analysis.rkcommands.R
A  +21   -0    tests/analysis_plugins/power_analysis.rkout

http://commits.kde.org/rkward/ec6bb04a8ad44ce1aa9751b52cbba15a1aced303

diff --git a/tests/analysis_plugins.R b/tests/analysis_plugins.R
index 81656a4..696b771 100644
--- a/tests/analysis_plugins.R
+++ b/tests/analysis_plugins.R
@@ -145,7 +145,10 @@ suite <- new ("RKTestSuite", id="analysis_plugins",
 		}),
 		new ("RKTest", id="linear_regression", call=function () {
 			rk.call.plugin ("rkward::linear_regression", intercept.state="1", x.available="warpbreaks[[\"tension\"]]\nwarpbreaks[[\"wool\"]]", y.available="warpbreaks[[\"breaks\"]]", submit.mode="submit")
-		})
+		})#,
+#     new ("RKTest", id="power_analysis", call=function () {
+#       rk.call.plugin ("rkward::power_analysis", drp_pwr_hypothesis.string="two.sided", drp_pwr_stat.string="pwr.t.test", drp_pwr_type.string="two.sample", pwr_spin_sample0.real="30.00", rad_pwr_param.string="Power", spn_Effectsz.real="0.30", spn_Sgnfcncl.real="0.05", svb_Svrsltst.active="0", svb_Svrsltst.objectname="pwr.result", svb_Svrsltst.parent=".GlobalEnv", submit.mode="submit")
+#     })
 	), postCalls = list (	# like initCalls: run after all tests to clean up.
 		function () {
 			suppressWarnings (rm (list=c ("women", "warpbreaks", "rock", "co2", "test50x", "test50y", "test50z", "test10x", "test10y", "test10z", "test_table", "hptrend", "hpcycle"), envir=globalenv()))
diff --git a/tests/analysis_plugins/power_analysis.rkcommands.R b/tests/analysis_plugins/power_analysis.rkcommands.R
new file mode 100644
index 0000000..a1a6a3f
--- /dev/null
+++ b/tests/analysis_plugins/power_analysis.rkcommands.R
@@ -0,0 +1,38 @@
+local({
+## Vorbereiten
+require(pwr)
+## Berechne
+	pwr.result <- try(
+		pwr.t.test(
+			n=30,
+			d=0.30
+		)
+	)
+
+## Drucke Ergebnisse
+	# Catch errors due to unsuitable data
+	if(class(pwr.result) == "try-error"){
+		rk.print("Power anaylsis not possible with the data you provided")
+		return()
+	}
+
+	# Prepare printout
+	note <- pwr.result[["note"]]
+	parameters <- list("Target measure"="Power")
+	if(!is.null(pwr.result[["alternative"]])){
+		parameters[["alternative"]] <- pwr.result[["alternative"]]
+	}
+
+	rk.header(pwr.result[["method"]], parameters=parameters)
+	pwr.result[c("method", "note", "alternative")] <- NULL
+	pwr.result <- as.data.frame(unlist(pwr.result))
+	colnames(pwr.result) <- "Parameters"
+
+	rk.results(pwr.result)
+	if(!is.null(note)){
+		rk.print(paste("<strong>Note:</strong> ", note))
+	}
+
+	rk.print("Interpretation of effect size <strong>d</strong> (according to Cohen):")
+	rk.results(data.frame(small=0.2, medium=0.5, large=0.8))
+})
diff --git a/tests/analysis_plugins/power_analysis.rkout b/tests/analysis_plugins/power_analysis.rkout
new file mode 100644
index 0000000..d111750
--- /dev/null
+++ b/tests/analysis_plugins/power_analysis.rkout
@@ -0,0 +1,21 @@
+<h1>Two-sample t test power calculation</h1>
+<h2>Parameters</h2>
+<ul><li>Target measure: Power</li>
+<li>alternative: two.sided</li>
+</ul>
+DATE<br />
+<table border="1">
+<tr><td></td><td>Parameters</td></tr>
+<tr><td>n</td><td>30</td></tr>
+<tr><td>d</td><td>0.3</td></tr>
+<tr><td>sig.level</td><td>0.05</td></tr>
+<tr><td>power</td><td>0.20785</td></tr>
+</table>
+
+<p class='character'><strong>Note:</strong>  n is number in *each* group</p>
+
+<p class='character'>Interpretation of effect size <strong>d</strong> (according to Cohen):</p>
+<table border="1">
+<tr><td>small</td><td>medium</td><td>large</td></tr>
+<tr><td>0.2</td><td>0.5</td><td>0.8</td></tr>
+</table>





More information about the rkward-tracker mailing list