[rkward-cvs] SF.net SVN: rkward-code:[4887] branches/external_plugins/rk.power
m-eik at users.sf.net
m-eik at users.sf.net
Wed Oct 8 13:17:37 UTC 2014
Revision: 4887
http://sourceforge.net/p/rkward/code/4887
Author: m-eik
Date: 2014-10-08 13:17:36 +0000 (Wed, 08 Oct 2014)
Log Message:
-----------
rk.power: begin including documentation
Modified Paths:
--------------
branches/external_plugins/rk.power/DESCRIPTION
branches/external_plugins/rk.power/inst/rkward/plugins/Poweranalysis.js
branches/external_plugins/rk.power/inst/rkward/plugins/Poweranalysis.rkh
branches/external_plugins/rk.power/inst/rkward/plugins/Poweranalysis.xml
branches/external_plugins/rk.power/inst/rkward/rk.power.pluginmap
branches/external_plugins/rk.power/inst/rkward/rkwarddev_power_plugin_script.R
Modified: branches/external_plugins/rk.power/DESCRIPTION
===================================================================
--- branches/external_plugins/rk.power/DESCRIPTION 2014-10-07 21:06:57 UTC (rev 4886)
+++ branches/external_plugins/rk.power/DESCRIPTION 2014-10-08 13:17:36 UTC (rev 4887)
@@ -1,16 +1,16 @@
Package: rk.power
Type: Package
Title: RKWard GUI to perform power analysis and sample size estimation.
-Version: 0.01-2
-Date: 2014-10-05
+Version: 0.01-3
+Date: 2014-10-08
Author: Meik Michalke <meik.michalke at hhu.de>
Maintainer: Meik Michalke <meik.michalke at hhu.de>
-Depends:
- rkward (>= 0.5.6)
+Depends: rkward (>= 0.5.6)
Enhances: rkward
-Description: RKWard GUI to perform power analysis and sample size estimation.
+Description: RKWard GUI to perform power analysis and sample size
+ estimation.
License: GPL (>= 3)
LazyLoad: yes
URL: http://rkward.sf.net
Authors at R: person(given="Meik", family="Michalke",
- email="meik.michalke at hhu.de", role=c("aut", "cre"))
+ email="meik.michalke at hhu.de", role=c("aut", "cre"))
Modified: branches/external_plugins/rk.power/inst/rkward/plugins/Poweranalysis.js
===================================================================
--- branches/external_plugins/rk.power/inst/rkward/plugins/Poweranalysis.js 2014-10-07 21:06:57 UTC (rev 4886)
+++ branches/external_plugins/rk.power/inst/rkward/plugins/Poweranalysis.js 2014-10-08 13:17:36 UTC (rev 4887)
@@ -31,81 +31,81 @@
var svbSvrsltst = getValue("svb_Svrsltst");
// the R code to be evaluated
- echo("\tpwr.result <- ");
+ echo("\tpwr.result <- try(\n\t\t");
if(drpPwrStat == "pwr.t.test") {
if(drpPwrType == "two.sample.diff") {
echo("pwr.t2n.test(");
if(radPwrParam != "Sample size") {
- echo("\n\t\tn1=" + pwrSpinSample1 + ",\n\t\tn2=" + pwrSpinSample2);
+ echo("\n\t\t\tn1=" + pwrSpinSample1 + ",\n\t\t\tn2=" + pwrSpinSample2);
} else if(radPwrParam2samples == "n2") {
- echo("\n\t\tn1=" + pwrSpinSample1 + ",");
+ echo("\n\t\t\tn1=" + pwrSpinSample1 + ",");
} else {
- echo("\n\t\tn2=" + pwrSpinSample2 + ",");
+ echo("\n\t\t\tn2=" + pwrSpinSample2 + ",");
}
} else {
echo("pwr.t.test(");
if(radPwrParam != "Sample size") {
- echo("\n\t\tn=" + pwrSpinSample0);
+ echo("\n\t\t\tn=" + pwrSpinSample0);
}
}
if(radPwrParam != "Effect size") {
if(radPwrParam != "Sample size") {
echo(",");
}
- echo("\n\t\td=" + spnEffectsz);
+ echo("\n\t\t\td=" + spnEffectsz);
}
}
if(drpPwrStat == "pwr.r.test") {
echo("pwr.r.test(");
if(radPwrParam != "Sample size") {
- echo("\n\t\tn=" + pwrSpinSample0);
+ echo("\n\t\t\tn=" + pwrSpinSample0);
}
if(radPwrParam != "Effect size") {
if(radPwrParam != "Sample size") {
echo(",");
}
- echo("\n\t\tr=" + spnEffectsz);
+ echo("\n\t\t\tr=" + spnEffectsz);
}
}
if(drpPwrStat == "pwr.anova.test") {
echo("pwr.anova.test(");
- echo("\n\t\tk=" + spnNmbrfgrp);
+ echo("\n\t\t\tk=" + spnNmbrfgrp);
if(radPwrParam != "Sample size") {
- echo(",\n\t\tn=" + pwrSpinSample0);
+ echo(",\n\t\t\tn=" + pwrSpinSample0);
}
if(radPwrParam != "Effect size") {
if(radEffctEta == "f") {
- echo(",\n\t\tf=" + spnEffectsz);
+ echo(",\n\t\t\tf=" + spnEffectsz);
} else {
- echo(",\n\t\tf=sqrt(" + spnEffectsz + "/(1-" + spnEffectsz + ")) # calculate f from eta squared");
+ echo(",\n\t\t\tf=sqrt(" + spnEffectsz + "/(1-" + spnEffectsz + ")) # calculate f from eta squared");
}
}
}
if(drpPwrStat == "pwr.f2.test") {
echo("pwr.f2.test(");
if(radPwrParam != "Sample size") {
- echo(",\n\t\tu=" + pwrSpinDfu + ",\n\t\tv=" + pwrSpinDfv);
+ echo(",\n\t\t\tu=" + pwrSpinDfu + ",\n\t\t\tv=" + pwrSpinDfv);
} else if(radPwrParam2df == "v") {
- echo("\n\t\tu=" + pwrSpinDfu);
+ echo("\n\t\t\tu=" + pwrSpinDfu);
} else {
- echo("\n\t\tv=" + pwrSpinDfv);
+ echo("\n\t\t\tv=" + pwrSpinDfv);
}
if(radPwrParam != "Effect size") {
- echo(",\n\t\tf2=" + spnEffectsz);
+ echo(",\n\t\t\tf2=" + spnEffectsz);
}
}
if(drpPwrStat == "pwr.chisq.test") {
echo("pwr.chisq.test(");
if(radPwrParam != "Effect size") {
- echo("\n\t\tw=" + spnEffectsz);
+ echo("\n\t\t\tw=" + spnEffectsz);
}
if(radPwrParam != "Sample size") {
if(radPwrParam != "Effect size") {
echo(",");
}
- echo("\n\t\tN=" + pwrSpinSample0);
+ echo("\n\t\t\tN=" + pwrSpinSample0);
}
- echo(",\n\t\tdf=" + pwrSpinDf);
+ echo(",\n\t\t\tdf=" + pwrSpinDf);
}
if(drpPwrStat == "pwr.p.test") {
if(drpPwrProptype == "two.sample.same") {
@@ -118,56 +118,56 @@
echo("pwr.p.test(");
}
if(radPwrParam != "Effect size") {
- echo("\n\t\th=" + spnEffectsz);
+ echo("\n\t\t\th=" + spnEffectsz);
}
if(radPwrParam != "Sample size") {
if(radPwrParam != "Effect size") {
echo(",");
}
if(drpPwrProptype != "two.sample.diff") {
- echo("\n\t\tn=" + pwrSpinSample0);
+ echo("\n\t\t\tn=" + pwrSpinSample0);
} else {
- echo("\n\t\tn1=" + pwrSpinSample1 + ",\n\t\tn2=" + pwrSpinSample2);
+ echo("\n\t\t\tn1=" + pwrSpinSample1 + ",\n\t\t\tn2=" + pwrSpinSample2);
}
} else if(drpPwrProptype == "two.sample.diff") {
if(radPwrParam2samples == "n2") {
- echo("\n\t\tn1=" + pwrSpinSample1 + ",");
+ echo(",\n\t\t\tn1=" + pwrSpinSample1);
} else {
- echo("\n\t\tn2=" + pwrSpinSample2 + ",");
+ echo(",\n\t\t\tn2=" + pwrSpinSample2);
}
}
}
if(drpPwrStat == "pwr.norm.test") {
echo("pwr.norm.test(");
if(radPwrParam != "Effect size") {
- echo("\n\t\td=" + spnEffectsz);
+ echo("\n\t\t\td=" + spnEffectsz);
}
if(radPwrParam != "Sample size") {
if(radPwrParam != "Effect size") {
echo(",");
}
- echo("\n\t\tn=" + pwrSpinSample0);
+ echo("\n\t\t\tn=" + pwrSpinSample0);
}
}
if(radPwrParam != "Significance level") {
if(spnSgnfcncl != 0.05) {
- echo("\n\t\tsig.level=" + spnSgnfcncl + ",");
+ echo("\n\t\t\tsig.level=" + spnSgnfcncl + ",");
}
} else {
- echo(",\n\t\tsig.level=NULL");
+ echo(",\n\t\t\tsig.level=NULL");
}
if(radPwrParam != "Power") {
- echo(",\n\t\tpower=" + spnPower);
+ echo(",\n\t\t\tpower=" + spnPower);
}
if(drpPwrStat == "pwr.t.test" & drpPwrType != "two.sample.diff" & drpPwrType != "two.sample") {
- echo(",\n\t\ttype=\"" + drpPwrType + "\"");
+ echo(",\n\t\t\ttype=\"" + drpPwrType + "\"");
}
if(drpPwrStat != "pwr.anova.test" & drpPwrStat != "pwr.f2.test" & drpPwrStat != "pwr.chisq.test") {
if(drpPwrHypothesis != "two.sided") {
- echo(",\n\t\talternative=\"" + drpPwrHypothesis + "\"");
+ echo(",\n\t\t\talternative=\"" + drpPwrHypothesis + "\"");
}
}
- echo("\n\t)\n\n");
+ echo("\n\t\t)\n\t)\n\n");
}
function printout(){
@@ -176,7 +176,7 @@
var drpPwrStat = getValue("drp_pwr_stat");
var radPwrParam = getValue("rad_pwr_param");
- echo("\t# Prepare printout\n" + "\tmethod <- pwr.result[[\"method\"]]\n" + "\tnote <- pwr.result[[\"note\"]]\n" + "\tparameters <- list(\"Target measure\"=\"" + radPwrParam + "\")\n" + "\tif(!is.null(pwr.result[[\"alternative\"]])){\n\t\tparameters[[\"alternative\"]] <- pwr.result[[\"alternative\"]]\n\t}\n\n" + "\tpwr.result[c(\"method\", \"note\", \"alternative\")] <- NULL\n" + "\tpwr.result <- as.data.frame(unlist(pwr.result))\n" + "\tcolnames(pwr.result) <- \"Parameters\"\n\n" + "\trk.header(method, parameters=parameters)\n" + "\trk.results(pwr.result)\n" + "\tif(!is.null(note)){\n\t\trk.print(paste(\"<strong>Note:</strong> \", note))\n\t}\n\n");
+ echo("\t# Catch errors due to unsuitable data\n" + "\tif(class(pwr.result) == \"try-error\"){\n" + "\t\trk.print(\"Power anaylsis not possible with the data you provided\")\n" + "\t\treturn()\n\t}\n\n" + "\t# Prepare printout\n" + "\tnote <- pwr.result[[\"note\"]]\n" + "\tparameters <- list(\"Target measure\"=\"" + radPwrParam + "\")\n" + "\tif(!is.null(pwr.result[[\"alternative\"]])){\n\t\tparameters[[\"alternative\"]] <- pwr.result[[\"alternative\"]]\n\t}\n\n" + "\trk.header(pwr.result[[\"method\"]], parameters=parameters)\n" + "\tpwr.result[c(\"method\", \"note\", \"alternative\")] <- NULL\n" + "\tpwr.result <- as.data.frame(unlist(pwr.result))\n" + "\tcolnames(pwr.result) <- \"Parameters\"\n\n" + "\trk.results(pwr.result)\n" + "\tif(!is.null(note)){\n\t\trk.print(paste(\"<strong>Note:</strong> \", note))\n\t}\n\n");
if(drpPwrStat == "pwr.t.test" | drpPwrStat == "pwr.norm.test") {
echo("\trk.print(\"Interpretation of effect size <strong>d</strong> (according to Cohen):\")\n" + "\trk.results(data.frame(small=0.2, medium=0.5, large=0.8))\n");
}
Modified: branches/external_plugins/rk.power/inst/rkward/plugins/Poweranalysis.rkh
===================================================================
--- branches/external_plugins/rk.power/inst/rkward/plugins/Poweranalysis.rkh 2014-10-07 21:06:57 UTC (rev 4886)
+++ branches/external_plugins/rk.power/inst/rkward/plugins/Poweranalysis.rkh 2014-10-08 13:17:36 UTC (rev 4887)
@@ -2,9 +2,20 @@
<document>
<!-- this code was generated using the rkwarddev package.
perhaps don't make changes here, but in the rkwarddev script instead! -->
+ <title>
+ Power analysis
+ </title>
<summary>
+ Perform power anaylsis for a variety of statistcal methods.
</summary>
<usage>
+ Given three of the parameters 'power of test',
+ 'sample size', 'effect size', and 'significance level', this plugin will
+ estimate the fourth, i.e. for example the test power of a t.test at a given
+ sample size, effect size, and level of significance. On the left hand control,
+ select which of the parameters to estimate. In the middle, specify the
+ statistical method, on the right hand side, enter the values of the given
+ parameters.
</usage>
<!-- <section id="sct_EDITORDE" title="EDIT OR DELETE ME">
EDIT OR DELETE ME
@@ -12,50 +23,36 @@
<settings>
<caption id="frm_Targtmsr" />
<setting id="rad_pwr_param">
+ Parameter to estimate, given the others.
</setting>
<setting id="rad_pwr_param_2samples">
+ Only shown when applicable: For estimating the required sample sizes for a test with two
+ differently sized samples, specify which should be estimated, and which is
+ given.
</setting>
- <setting id="rad_pwr_param_2df">
- </setting>
+ <setting id="rad_pwr_param_2df" />
<caption id="frm_SttstclM" />
- <setting id="drp_pwr_stat">
- </setting>
- <setting id="spn_Nmbrfgrp">
- </setting>
- <setting id="drp_pwr_type">
- </setting>
- <setting id="drp_pwr_proptype">
- </setting>
- <setting id="drp_pwr_hypothesis">
- </setting>
- <setting id="rad_effct_eta">
- </setting>
+ <setting id="drp_pwr_stat" />
+ <setting id="spn_Nmbrfgrp" />
+ <setting id="drp_pwr_type" />
+ <setting id="drp_pwr_proptype" />
+ <setting id="drp_pwr_hypothesis" />
+ <setting id="rad_effct_eta" />
<caption id="frm_Knwnmsrs" />
<caption id="frm_spnbPP0801" />
- <setting id="spn_Power">
- </setting>
+ <setting id="spn_Power" />
<caption id="frm_sD301D301D" />
- <setting id="pwr_spin_df">
- </setting>
- <setting id="pwr_spin_dfu">
- </setting>
- <setting id="pwr_spin_dfv">
- </setting>
+ <setting id="pwr_spin_df" />
+ <setting id="pwr_spin_dfu" />
+ <setting id="pwr_spin_dfv" />
<caption id="frm_sS0301F130" />
- <setting id="pwr_spin_sample0">
- </setting>
- <setting id="pwr_spin_sample1">
- </setting>
- <setting id="pwr_spin_sample2">
- </setting>
+ <setting id="pwr_spin_sample0" />
+ <setting id="pwr_spin_sample1" />
+ <setting id="pwr_spin_sample2" />
<caption id="frm_sEE0311MCM" />
- <setting id="spn_Effectsz">
- </setting>
+ <setting id="spn_Effectsz" />
<caption id="frm_spnSS00501" />
- <setting id="spn_Sgnfcncl">
- </setting>
- <setting id="svb_Svrsltst">
- </setting>
+ <setting id="spn_Sgnfcncl" />
</settings>
<!-- <related>
<ul>
Modified: branches/external_plugins/rk.power/inst/rkward/plugins/Poweranalysis.xml
===================================================================
--- branches/external_plugins/rk.power/inst/rkward/plugins/Poweranalysis.xml 2014-10-07 21:06:57 UTC (rev 4886)
+++ branches/external_plugins/rk.power/inst/rkward/plugins/Poweranalysis.xml 2014-10-08 13:17:36 UTC (rev 4887)
@@ -107,8 +107,8 @@
</radio>
<stretch />
<radio id="rad_pwr_param_2samples" label="Estimate">
- <option label="First sample" value="n1" checked="true" />
- <option label="Second sample" value="n2" />
+ <option label="First sample" value="n1" />
+ <option label="Second sample" value="n2" checked="true" />
</radio>
<radio id="rad_pwr_param_2df" label="Estimate">
<option label="Numerator" value="u" checked="true" />
Modified: branches/external_plugins/rk.power/inst/rkward/rk.power.pluginmap
===================================================================
--- branches/external_plugins/rk.power/inst/rkward/rk.power.pluginmap 2014-10-07 21:06:57 UTC (rev 4886)
+++ branches/external_plugins/rk.power/inst/rkward/rk.power.pluginmap 2014-10-08 13:17:36 UTC (rev 4887)
@@ -14,8 +14,8 @@
name="rk.power"
shortinfo="RKWard GUI to perform power analysis and sample size estimation."
longinfo="RKWard GUI to perform power analysis and sample size estimation."
- version="0.01-2"
- releasedate="2014-10-05"
+ version="0.01-3"
+ releasedate="2014-10-08"
url="http://rkward.sf.net"
license="GPL (>= 3)"
>
Modified: branches/external_plugins/rk.power/inst/rkward/rkwarddev_power_plugin_script.R
===================================================================
--- branches/external_plugins/rk.power/inst/rkward/rkwarddev_power_plugin_script.R 2014-10-07 21:06:57 UTC (rev 4886)
+++ branches/external_plugins/rk.power/inst/rkward/rkwarddev_power_plugin_script.R 2014-10-08 13:17:36 UTC (rev 4887)
@@ -18,7 +18,7 @@
person(given="Meik", family="Michalke",
email="meik.michalke at hhu.de", role=c("aut","cre"))),
about=list(desc="RKWard GUI to perform power analysis and sample size estimation.",
- version="0.01-2", url="http://rkward.sf.net")
+ version="0.01-3", url="http://rkward.sf.net")
)
dependencies.info <- rk.XML.dependencies(
dependencies=list(rkward.min=ifelse(isTRUE(guess.getter), "0.6.0", "0.5.6"),
@@ -33,12 +33,15 @@
"Effect size"=c(val="Effect size"),
"Significance level"=c(val="Significance level")
), id.name="rad_pwr_param",
- help="foo")
+ help="Parameter to estimate, given the others.")
pwr.parameter.twosamples.rad <- rk.XML.radio(label="Estimate", options=list(
"First sample"=c(val="n1"),
"Second sample"=c(val="n2", chk=TRUE)
- ), id.name="rad_pwr_param_2samples")
+ ), id.name="rad_pwr_param_2samples",
+ help="Only shown when applicable: For estimating the required sample sizes for a test with two
+ differently sized samples, specify which should be estimated, and which is
+ given.")
pwr.parameter.twodf.rad <- rk.XML.radio(label="Estimate", options=list(
"Numerator"=c(val="u", chk=TRUE),
@@ -53,8 +56,7 @@
"Chi-squared test"=c(val="pwr.chisq.test"),
"Proportion tests"=c(val="pwr.p.test"),
"Mean of a normal distribution (known variance)"=c(val="pwr.norm.test")
- ), id.name="drp_pwr_stat",
- help="bar")
+ ), id.name="drp_pwr_stat")
pwr.hypothesis.drop <- rk.XML.dropdown("Using test hypothesis",
options=list(
@@ -88,8 +90,7 @@
),
id.name="drp_pwr_proptype")
-pwr.input.power <- rk.XML.spinbox(label="Power", min=0, max=1, initial=0.8,
- help="baz")
+pwr.input.power <- rk.XML.spinbox(label="Power", min=0, max=1, initial=0.8)
pwr.input.df <- rk.XML.spinbox(label="Degrees of freedom", id.name="pwr_spin_df", min=1, real=FALSE, initial=30)
pwr.input.dfu <- rk.XML.spinbox(label="Degrees of freedom for numerator", id.name="pwr_spin_dfu", min=1, real=FALSE, initial=30)
pwr.input.dfv <- rk.XML.spinbox(label="Degrees of freedom for denominator", id.name="pwr_spin_dfv", min=1, real=FALSE, initial=30)
@@ -506,6 +507,20 @@
)
)
+############
+## help file
+
+pwr.rkh.summary <- rk.rkh.summary("Perform power anaylsis for a variety of statistcal methods.")
+
+pwr.rkh.usage <- rk.rkh.usage("Given three of the parameters 'power of test',
+ 'sample size', 'effect size', and 'significance level', this plugin will
+ estimate the fourth, i.e. for example the test power of a t.test at a given
+ sample size, effect size, and level of significance. On the left hand control,
+ select which of the parameters to estimate. In the middle, specify the
+ statistical method, on the right hand side, enter the values of the given
+ parameters.")
+
+
#############
## if you run the following function call, files will be written to tempdir!
#############
@@ -524,8 +539,8 @@
calculate=pwr.js.calc,
printout=pwr.js.print),
rkh=list(
- summary=rk.rkh.summary("Perform power analysis and sample size estimation, using the pwr package."),
- usage=rk.rkh.usage("See blow.")
+ summary=pwr.rkh.summary,
+ usage=pwr.rkh.usage
),
pluginmap=list(name="Power analysis", hierarchy=list("analysis")),
dependencies=dependencies.info,
More information about the rkward-tracker
mailing list