[rkward-cvs] [rkward] tests: Extend and activate automated test for power plugin.
Thomas Friedrichsmeier
thomas.friedrichsmeier at ruhr-uni-bochum.de
Thu Jan 15 19:27:44 UTC 2015
Git commit 460d987194b2fbd7ccf727f8e8ab8153c281a40c by Thomas Friedrichsmeier.
Committed on 15/01/2015 at 19:26.
Pushed by tfry into branch 'master'.
Extend and activate automated test for power plugin.
(This may be somewhat excessive, but in fact, playing with many settings while creating this test revealed one syntax bug (fixed in previous commit)).
M +10 -4 tests/analysis_plugins.R
M +243 -4 tests/analysis_plugins/power_analysis.rkcommands.R
M +119 -0 tests/analysis_plugins/power_analysis.rkout
http://commits.kde.org/rkward/460d987194b2fbd7ccf727f8e8ab8153c281a40c
diff --git a/tests/analysis_plugins.R b/tests/analysis_plugins.R
index 696b771..f6757aa 100644
--- a/tests/analysis_plugins.R
+++ b/tests/analysis_plugins.R
@@ -145,10 +145,16 @@ 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")
-# })
+ }),
+ 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")
+ 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.diff", pwr_spin_sample1.real="27.00", pwr_spin_sample2.real="33.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")
+ rk.call.plugin ("rkward::power_analysis", drp_pwr_hypothesis.string="two.sided", drp_pwr_stat.string="pwr.r.test", rad_pwr_param.string="Sample size", spn_Effectsz.real="0.30", spn_Power.real="0.81", spn_Sgnfcncl.real="0.05", svb_Svrsltst.active="0", svb_Svrsltst.objectname="pwr.result", svb_Svrsltst.parent=".GlobalEnv", submit.mode="submit")
+ rk.call.plugin ("rkward::power_analysis", drp_pwr_stat.string="pwr.chisq.test", pwr_spin_df.real="32.00", pwr_spin_sample0.real="30.00", rad_pwr_param.string="Significance level", spn_Effectsz.real="0.30", spn_Power.real="0.81", svb_Svrsltst.active="0", svb_Svrsltst.objectname="pwr.result", svb_Svrsltst.parent=".GlobalEnv", submit.mode="submit")
+ rk.call.plugin ("rkward::power_analysis", drp_pwr_hypothesis.string="greater", drp_pwr_proptype.string="two.sample.same", drp_pwr_stat.string="pwr.p.test", pwr_spin_sample0.real="30.00", rad_pwr_param.string="Significance level", spn_Effectsz.real="0.30", spn_Power.real="0.81", svb_Svrsltst.active="0", svb_Svrsltst.objectname="pwr.result", svb_Svrsltst.parent=".GlobalEnv", submit.mode="submit")
+ rk.call.plugin ("rkward::power_analysis", drp_pwr_hypothesis.string="two.sided", drp_pwr_stat.string="pwr.norm.test", pwr_spin_sample0.real="30.00", rad_pwr_param.string="Significance level", spn_Effectsz.real="0.30", spn_Power.real="0.80", svb_Svrsltst.active="0", svb_Svrsltst.objectname="pwr.result", svb_Svrsltst.parent=".GlobalEnv", submit.mode="submit")
+ rk.call.plugin ("rkward::power_analysis", drp_pwr_stat.string="pwr.f2.test", pwr_spin_dfv.real="30.00", pwr_spin_sample0.real="30.00", rad_pwr_param.string="Parameter count", spn_Effectsz.real="0.30", spn_Power.real="0.80", spn_Sgnfcncl.real="0.10", 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
index a1a6a3f..38c6113 100644
--- a/tests/analysis_plugins/power_analysis.rkcommands.R
+++ b/tests/analysis_plugins/power_analysis.rkcommands.R
@@ -1,7 +1,7 @@
local({
-## Vorbereiten
+## Prepare
require(pwr)
-## Berechne
+## Compute
pwr.result <- try(
pwr.t.test(
n=30,
@@ -9,10 +9,10 @@ require(pwr)
)
)
-## Drucke Ergebnisse
+## Print result
# Catch errors due to unsuitable data
if(class(pwr.result) == "try-error"){
- rk.print("Power anaylsis not possible with the data you provided")
+ rk.print("Power analysis not possible with the data you provided")
return()
}
@@ -36,3 +36,242 @@ require(pwr)
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))
})
+local({
+## Prepare
+require(pwr)
+## Compute
+ pwr.result <- try(
+ pwr.t2n.test(
+ n1=27,
+ n2=33,
+ d=0.30
+ )
+ )
+
+## Print result
+ # Catch errors due to unsuitable data
+ if(class(pwr.result) == "try-error"){
+ rk.print("Power analysis 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))
+})
+local({
+## Prepare
+require(pwr)
+## Compute
+ pwr.result <- try(
+ pwr.r.test(
+ r=0.30,
+ power=0.81
+ )
+ )
+
+## Print result
+ # Catch errors due to unsuitable data
+ if(class(pwr.result) == "try-error"){
+ rk.print("Power analysis not possible with the data you provided")
+ return()
+ }
+
+ # Prepare printout
+ note <- pwr.result[["note"]]
+ parameters <- list("Target measure"="Sample size")
+ 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>r</strong> (according to Cohen):")
+ rk.results(data.frame(small=0.1, medium=0.3, large=0.5))
+})
+local({
+## Prepare
+require(pwr)
+## Compute
+ pwr.result <- try(
+ pwr.chisq.test(
+ w=0.30,
+ N=30,
+ df=32,
+ sig.level=NULL,
+ power=0.81
+ )
+ )
+
+## Print result
+ # Catch errors due to unsuitable data
+ if(class(pwr.result) == "try-error"){
+ rk.print("Power analysis not possible with the data you provided")
+ return()
+ }
+
+ # Prepare printout
+ note <- pwr.result[["note"]]
+ parameters <- list("Target measure"="Significance level")
+ 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>w</strong> (according to Cohen):")
+ rk.results(data.frame(small=0.1, medium=0.3, large=0.5))
+})
+local({
+## Prepare
+require(pwr)
+## Compute
+ pwr.result <- try(
+ pwr.2p.test(
+ h=0.30,
+ n=30,
+ sig.level=NULL,
+ power=0.81,
+ alternative="greater"
+ )
+ )
+
+## Print result
+ # Catch errors due to unsuitable data
+ if(class(pwr.result) == "try-error"){
+ rk.print("Power analysis not possible with the data you provided")
+ return()
+ }
+
+ # Prepare printout
+ note <- pwr.result[["note"]]
+ parameters <- list("Target measure"="Significance level")
+ 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>h</strong> (according to Cohen):")
+ rk.results(data.frame(small=0.2, medium=0.5, large=0.8))
+})
+local({
+## Prepare
+require(pwr)
+## Compute
+ pwr.result <- try(
+ pwr.norm.test(
+ d=0.30,
+ n=30,
+ sig.level=NULL,
+ power=0.80
+ )
+ )
+
+## Print result
+ # Catch errors due to unsuitable data
+ if(class(pwr.result) == "try-error"){
+ rk.print("Power analysis not possible with the data you provided")
+ return()
+ }
+
+ # Prepare printout
+ note <- pwr.result[["note"]]
+ parameters <- list("Target measure"="Significance level")
+ 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))
+})
+local({
+## Prepare
+require(pwr)
+## Compute
+ pwr.result <- try(
+ pwr.f2.test(
+ v=30,
+ f2=0.30,
+ sig.level=0.10,
+ power=0.80
+ )
+ )
+
+## Print result
+ # Catch errors due to unsuitable data
+ if(class(pwr.result) == "try-error"){
+ rk.print("Power analysis not possible with the data you provided")
+ return()
+ }
+
+ # Prepare printout
+ note <- pwr.result[["note"]]
+ parameters <- list("Target measure"="Parameter count")
+ 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>f<sup>2</sup></strong> (according to Cohen):")
+ rk.results(data.frame(small=0.02, medium=0.15, large=0.35))
+})
diff --git a/tests/analysis_plugins/power_analysis.rkout b/tests/analysis_plugins/power_analysis.rkout
index d111750..8dd4c62 100644
--- a/tests/analysis_plugins/power_analysis.rkout
+++ b/tests/analysis_plugins/power_analysis.rkout
@@ -19,3 +19,122 @@ DATE<br />
<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>
+<h1>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>n1</td><td>27</td></tr>
+<tr><td>n2</td><td>33</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.20624</td></tr>
+</table>
+
+<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>
+<h1>approximate correlation power calculation (arctangh transformation)</h1>
+<h2>Parameters</h2>
+<ul><li>Target measure: Sample size</li>
+<li>alternative: two.sided</li>
+</ul>
+DATE<br />
+<table border="1">
+<tr><td></td><td>Parameters</td></tr>
+<tr><td>n</td><td>86.875</td></tr>
+<tr><td>r</td><td>0.3</td></tr>
+<tr><td>sig.level</td><td>0.05</td></tr>
+<tr><td>power</td><td>0.81</td></tr>
+</table>
+
+<p class='character'>Interpretation of effect size <strong>r</strong> (according to Cohen):</p>
+<table border="1">
+<tr><td>small</td><td>medium</td><td>large</td></tr>
+<tr><td>0.1</td><td>0.3</td><td>0.5</td></tr>
+</table>
+<h1>Chi squared power calculation</h1>
+<h2>Parameters</h2>
+<ul><li>Target measure: Significance level</li>
+</ul>
+DATE<br />
+<table border="1">
+<tr><td></td><td>Parameters</td></tr>
+<tr><td>w</td><td>0.3</td></tr>
+<tr><td>N</td><td>30</td></tr>
+<tr><td>df</td><td>32</td></tr>
+<tr><td>sig.level</td><td>0.71662</td></tr>
+<tr><td>power</td><td>0.81</td></tr>
+</table>
+
+<p class='character'><strong>Note:</strong> N is the number of observations</p>
+
+<p class='character'>Interpretation of effect size <strong>w</strong> (according to Cohen):</p>
+<table border="1">
+<tr><td>small</td><td>medium</td><td>large</td></tr>
+<tr><td>0.1</td><td>0.3</td><td>0.5</td></tr>
+</table>
+<h1>Difference of proportion power calculation for binomial distribution (arcsine transformation)</h1>
+<h2>Parameters</h2>
+<ul><li>Target measure: Significance level</li>
+<li>alternative: greater</li>
+</ul>
+DATE<br />
+<table border="1">
+<tr><td></td><td>Parameters</td></tr>
+<tr><td>h</td><td>0.3</td></tr>
+<tr><td>n</td><td>30</td></tr>
+<tr><td>sig.level</td><td>0.38821</td></tr>
+<tr><td>power</td><td>0.81</td></tr>
+</table>
+
+<p class='character'><strong>Note:</strong> same sample sizes</p>
+
+<p class='character'>Interpretation of effect size <strong>h</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>
+<h1>Mean power calculation for normal distribution with known variance</h1>
+<h2>Parameters</h2>
+<ul><li>Target measure: Significance level</li>
+<li>alternative: two.sided</li>
+</ul>
+DATE<br />
+<table border="1">
+<tr><td></td><td>Parameters</td></tr>
+<tr><td>d</td><td>0.3</td></tr>
+<tr><td>n</td><td>30</td></tr>
+<tr><td>sig.level</td><td>0.40906</td></tr>
+<tr><td>power</td><td>0.8</td></tr>
+</table>
+
+<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>
+<h1>Multiple regression power calculation</h1>
+<h2>Parameters</h2>
+<ul><li>Target measure: Parameter count</li>
+</ul>
+DATE<br />
+<table border="1">
+<tr><td></td><td>Parameters</td></tr>
+<tr><td>u</td><td>3.4454</td></tr>
+<tr><td>v</td><td>30</td></tr>
+<tr><td>f2</td><td>0.3</td></tr>
+<tr><td>sig.level</td><td>0.1</td></tr>
+<tr><td>power</td><td>0.8</td></tr>
+</table>
+
+<p class='character'>Interpretation of effect size <strong>f<sup>2</sup></strong> (according to Cohen):</p>
+<table border="1">
+<tr><td>small</td><td>medium</td><td>large</td></tr>
+<tr><td>0.02</td><td>0.15</td><td>0.35</td></tr>
+</table>
------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
rkward-cvs mailing list
rkward-cvs at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rkward-cvs
More information about the rkward-tracker
mailing list