[rkward-cvs] SF.net SVN: rkward-code:[4873] branches/external_plugins
m-eik at users.sf.net
m-eik at users.sf.net
Sat Oct 4 22:26:37 UTC 2014
Revision: 4873
http://sourceforge.net/p/rkward/code/4873
Author: m-eik
Date: 2014-10-04 22:26:36 +0000 (Sat, 04 Oct 2014)
Log Message:
-----------
add first edition of new rk.power plugin
Added Paths:
-----------
branches/external_plugins/rk.power/
branches/external_plugins/rk.power/DESCRIPTION
branches/external_plugins/rk.power/NAMESPACE
branches/external_plugins/rk.power/R/
branches/external_plugins/rk.power/inst/
branches/external_plugins/rk.power/inst/rkward/
branches/external_plugins/rk.power/inst/rkward/plugins/
branches/external_plugins/rk.power/inst/rkward/plugins/Poweranalysis.js
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
Added: branches/external_plugins/rk.power/DESCRIPTION
===================================================================
--- branches/external_plugins/rk.power/DESCRIPTION (rev 0)
+++ branches/external_plugins/rk.power/DESCRIPTION 2014-10-04 22:26:36 UTC (rev 4873)
@@ -0,0 +1,14 @@
+Package: rk.power
+Type: Package
+Title: RKWard GUI to perform power analysis and sample size estimation.
+Version: 0.01-1
+Date: 2014-10-05
+Author: Meik Michalke <meik.michalke at hhu.de>
+Maintainer: Meik Michalke <meik.michalke at hhu.de>
+Depends: rkward (>= 0.5.6)
+Enhances: rkward
+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"))
Added: branches/external_plugins/rk.power/NAMESPACE
===================================================================
Added: branches/external_plugins/rk.power/inst/rkward/plugins/Poweranalysis.js
===================================================================
--- branches/external_plugins/rk.power/inst/rkward/plugins/Poweranalysis.js (rev 0)
+++ branches/external_plugins/rk.power/inst/rkward/plugins/Poweranalysis.js 2014-10-04 22:26:36 UTC (rev 4873)
@@ -0,0 +1,189 @@
+// this code was generated using the rkwarddev package.
+//perhaps don't make changes here, but in the rkwarddev script instead!
+
+
+
+function preprocess(){
+ // add requirements etc. here
+ echo("require(pwr)\n");
+}
+
+function calculate(){
+ // read in variables from dialog
+ var radPwrParam = getValue("rad_pwr_param");
+ var radPwrParam2samples = getValue("rad_pwr_param_2samples");
+ var radPwrParam2df = getValue("rad_pwr_param_2df");
+ var drpPwrStat = getValue("drp_pwr_stat");
+ var spnNmbrfgrp = getValue("spn_Nmbrfgrp");
+ var drpPwrType = getValue("drp_pwr_type");
+ var drpPwrProptype = getValue("drp_pwr_proptype");
+ var drpPwrHypothesis = getValue("drp_pwr_hypothesis");
+ var radEffctEta = getValue("rad_effct_eta");
+ var spnPower = getValue("spn_Power");
+ var pwrSpinDf = getValue("pwr_spin_df");
+ var pwrSpinDfu = getValue("pwr_spin_dfu");
+ var pwrSpinDfv = getValue("pwr_spin_dfv");
+ var pwrSpinSample0 = getValue("pwr_spin_sample0");
+ var pwrSpinSample1 = getValue("pwr_spin_sample1");
+ var pwrSpinSample2 = getValue("pwr_spin_sample2");
+ var spnEffectsz = getValue("spn_Effectsz");
+ var spnSgnfcncl = getValue("spn_Sgnfcncl");
+ var svbSvrsltst = getValue("svb_Svrsltst");
+
+ // the R code to be evaluated
+ echo("\tpwr.result <- ");
+ if(drpPwrStat == "pwr.t.test") {
+ if(drpPwrType == "two.sample.diff") {
+ echo("pwr.t2n.test(");
+ if(radPwrParam != "sample") {
+ echo("\n\t\tn1=" + pwrSpinSample1 + ",\n\t\tn2=" + pwrSpinSample2);
+ } else if(radPwrParam2samples == "n2") {
+ echo("\n\t\tn1=" + pwrSpinSample1 + ",");
+ } else {
+ echo("\n\t\tn2=" + pwrSpinSample2 + ",");
+ }
+ } else {
+ echo("pwr.t.test(");
+ if(radPwrParam != "sample") {
+ echo("\n\t\tn=" + pwrSpinSample0);
+ }
+ }
+ if(radPwrParam != "effect") {
+ if(radPwrParam != "sample") {
+ echo(",");
+ }
+ echo("\n\t\td=" + spnEffectsz);
+ }
+ }
+ if(drpPwrStat == "pwr.r.test") {
+ echo("pwr.r.test(");
+ if(radPwrParam != "sample") {
+ echo("\n\t\tn=" + pwrSpinSample0);
+ }
+ if(radPwrParam != "effect") {
+ if(radPwrParam != "sample") {
+ echo(",");
+ }
+ echo("\n\t\tr=" + spnEffectsz);
+ }
+ }
+ if(drpPwrStat == "pwr.anova.test") {
+ echo("pwr.anova.test(");
+ echo("\n\t\tk=" + spnNmbrfgrp);
+ if(radPwrParam != "sample") {
+ echo(",\n\t\tn=" + pwrSpinSample0);
+ }
+ if(radPwrParam != "effect") {
+ if(radEffctEta == "f") {
+ echo(",\n\t\tf=" + spnEffectsz);
+ } else {
+ echo(",\n\t\tf=sqrt(" + spnEffectsz + "/(1-" + spnEffectsz + ")) # calculate f from eta squared");
+ }
+ }
+ }
+ if(drpPwrStat == "pwr.f2.test") {
+ echo("pwr.f2.test(");
+ if(radPwrParam != "sample") {
+ echo(",\n\t\tu=" + pwrSpinDfu + ",\n\t\tv=" + pwrSpinDfv);
+ } else if(radPwrParam2df == "v") {
+ echo("\n\t\tu=" + pwrSpinDfu);
+ } else {
+ echo("\n\t\tv=" + pwrSpinDfv);
+ }
+ if(radPwrParam != "effect") {
+ echo(",\n\t\tf2=" + spnEffectsz);
+ }
+ }
+ if(drpPwrStat == "pwr.chisq.test") {
+ echo("pwr.chisq.test(");
+ if(radPwrParam != "effect") {
+ echo("\n\t\tw=" + spnEffectsz);
+ }
+ if(radPwrParam != "sample") {
+ if(radPwrParam != "effect") {
+ echo(",");
+ }
+ echo("\n\t\tN=" + pwrSpinSample0);
+ }
+ echo(",\n\t\tdf=" + pwrSpinDf);
+ }
+ if(drpPwrStat == "pwr.p.test") {
+ if(drpPwrProptype == "two.sample.same") {
+ echo("pwr.2p.test(");
+ }
+ if(drpPwrProptype == "two.sample.diff") {
+ echo("pwr.2p2n.test(");
+ }
+ if(drpPwrProptype == "one.sample") {
+ echo("pwr.p.test(");
+ }
+ if(radPwrParam != "effect") {
+ echo("\n\t\th=" + spnEffectsz);
+ }
+ if(radPwrParam != "sample") {
+ if(radPwrParam != "effect") {
+ echo(",");
+ }
+ if(drpPwrProptype != "two.sample.diff") {
+ echo("\n\t\tn=" + pwrSpinSample0);
+ } else {
+ echo("\n\t\tn1=" + pwrSpinSample1 + ",\n\t\tn2=" + pwrSpinSample2);
+ }
+ } else if(drpPwrProptype == "two.sample.diff") {
+ if(radPwrParam2samples == "n2") {
+ echo("\n\t\tn1=" + pwrSpinSample1 + ",");
+ } else {
+ echo("\n\t\tn2=" + pwrSpinSample2 + ",");
+ }
+ }
+ }
+ if(drpPwrStat == "pwr.norm.test") {
+ echo("pwr.norm.test(");
+ if(radPwrParam != "effect") {
+ echo("\n\t\td=" + spnEffectsz);
+ }
+ if(radPwrParam != "sample") {
+ if(radPwrParam != "effect") {
+ echo(",");
+ }
+ echo("\n\t\tn=" + pwrSpinSample0);
+ }
+ }
+ if(radPwrParam != "significance") {
+ if(spnSgnfcncl != 0.05) {
+ echo("\n\t\tsig.level=" + spnSgnfcncl + ",");
+ }
+ } else {
+ echo(",\n\t\tsig.level=NULL");
+ }
+ if(radPwrParam != "power") {
+ echo(",\n\t\tpower=" + spnPower);
+ }
+ if(drpPwrStat == "pwr.t.test" & drpPwrType != "two.sample.diff" & drpPwrType != "two.sample") {
+ echo(",\n\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)\n\n");
+}
+
+function printout(){
+ // printout the results
+ echo("rk.header(\"Power analysis results\")\n");
+
+ echo("rk.print(pwr.result)\n");
+ //// save result object
+ // read in saveobject variables
+ var svbSvrsltst = getValue("svb_Svrsltst");
+ var svbSvrsltstActive = getValue("svb_Svrsltst.active");
+ var svbSvrsltstParent = getValue("svb_Svrsltst.parent");
+ // assign object to chosen environment
+ if(svbSvrsltstActive) {
+ echo(".GlobalEnv$" + svbSvrsltst + " <- pwr.result\n");
+ }
+
+}
+
Added: branches/external_plugins/rk.power/inst/rkward/plugins/Poweranalysis.xml
===================================================================
--- branches/external_plugins/rk.power/inst/rkward/plugins/Poweranalysis.xml (rev 0)
+++ branches/external_plugins/rk.power/inst/rkward/plugins/Poweranalysis.xml 2014-10-04 22:26:36 UTC (rev 4873)
@@ -0,0 +1,249 @@
+<!DOCTYPE rkplugin >
+<document>
+ <!-- this code was generated using the rkwarddev package.
+ perhaps don't make changes here, but in the rkwarddev script instead! -->
+ <code file="Poweranalysis.js" />
+ <help file="Poweranalysis.rkh" />
+ <logic>
+ <convert id="pwr_lgc_power" sources="rad_pwr_param.string" mode="equals" standard="power" />
+ <convert id="pwr_lgc_sample" sources="rad_pwr_param.string" mode="equals" standard="sample" />
+ <convert id="pwr_lgc_effect" sources="rad_pwr_param.string" mode="equals" standard="effect" />
+ <convert id="pwr_lgc_signif" sources="rad_pwr_param.string" mode="equals" standard="significance" />
+ <connect governor="pwr_lgc_power.not" client="frm_spnbPP0801.enabled" />
+ <connect governor="pwr_lgc_effect.not" client="frm_sEE0311MCM.enabled" />
+ <connect governor="pwr_lgc_signif.not" client="frm_spnSS00501.enabled" />
+ <convert id="pwr_lgc_ttest" sources="drp_pwr_stat.string" mode="equals" standard="pwr.t.test" />
+ <convert id="pwr_lgc_rtest" sources="drp_pwr_stat.string" mode="equals" standard="pwr.r.test" />
+ <convert id="pwr_lgc_anova" sources="drp_pwr_stat.string" mode="equals" standard="pwr.anova.test" />
+ <convert id="pwr_lgc_f2test" sources="drp_pwr_stat.string" mode="equals" standard="pwr.f2.test" />
+ <convert id="pwr_lgc_chisq" sources="drp_pwr_stat.string" mode="equals" standard="pwr.chisq.test" />
+ <convert id="pwr_lgc_proptest" sources="drp_pwr_stat.string" mode="equals" standard="pwr.p.test" />
+ <convert id="pwr_lgc_norm" sources="drp_pwr_stat.string" mode="equals" standard="pwr.norm.test" />
+ <convert id="pwr_lgc_sample_2p_same" sources="drp_pwr_proptype.string" mode="equals" standard="two.sample.same" />
+ <convert id="pwr_lgc_sample_2p_diff" sources="drp_pwr_proptype.string" mode="equals" standard="two.sample.diff" />
+ <convert id="pwr_lgc_sample_t_diff" sources="drp_pwr_type.string" mode="equals" standard="two.sample.diff" />
+ <convert id="pwr_lgc_sample_t_pairs" sources="drp_pwr_type.string" mode="equals" standard="paired" />
+ <convert id="pwr_lgc_sample_t_nopairs" sources="drp_pwr_type.string" mode="notequals" standard="paired" />
+ <convert id="pwr_lgc_2p" sources="pwr_lgc_sample_2p_same;pwr_lgc_proptest" mode="and" />
+ <convert id="pwr_lgc_2p2n" sources="pwr_lgc_sample_2p_diff;pwr_lgc_proptest" mode="and" />
+ <convert id="pwr_lgc_tdiff" sources="pwr_lgc_sample_t_diff;pwr_lgc_ttest" mode="and" />
+ <convert id="pwr_lgc_tpaired" sources="pwr_lgc_sample_t_pairs;pwr_lgc_ttest" mode="and" />
+ <convert id="pwr_lgc_tunpaired" sources="pwr_lgc_sample_t_nopairs;pwr_lgc_ttest" mode="and" />
+ <connect governor="pwr_lgc_proptest.not" client="drp_pwr_type.visible" />
+ <connect governor="pwr_lgc_ttest" client="drp_pwr_type.enabled" />
+ <connect governor="pwr_lgc_proptest" client="drp_pwr_proptype.visible" />
+ <connect governor="pwr_lgc_proptest" client="drp_pwr_proptype.enabled" />
+ <connect governor="pwr_lgc_f2test.not" client="frm_sS0301F130.visible" />
+ <convert id="pwr_lgc_show_df" sources="pwr_lgc_f2test;pwr_lgc_chisq" mode="or" />
+ <connect governor="pwr_lgc_show_df" client="frm_sD301D301D.visible" />
+ <connect governor="pwr_lgc_chisq" client="pwr_spin_df.visible" />
+ <connect governor="pwr_lgc_f2test" client="pwr_spin_dfu.visible" />
+ <connect governor="pwr_lgc_f2test" client="pwr_spin_dfv.visible" />
+ <convert id="pwr_lgc_efct_d" sources="pwr_lgc_ttest;pwr_lgc_norm" mode="or" />
+ <connect governor="pwr_lgc_efct_d" client="pwr_txt_efct_d.visible" />
+ <connect governor="pwr_lgc_rtest" client="pwr_txt_efct_r.visible" />
+ <convert id="pwr_lgc_efct_f" sources="rad_effct_eta.string" mode="equals" standard="f" />
+ <convert id="pwr_lgc_efct_show_f" sources="pwr_lgc_anova;pwr_lgc_efct_f" mode="and" />
+ <convert id="pwr_lgc_efct_show_e2" sources="pwr_lgc_anova;pwr_lgc_efct_f.not" mode="and" />
+ <connect governor="pwr_lgc_efct_show_f" client="pwr_txt_efct_f.visible" />
+ <connect governor="pwr_lgc_efct_show_e2" client="pwr_txt_efct_e2.visible" />
+ <connect governor="pwr_lgc_f2test" client="pwr_txt_efct_f2.visible" />
+ <connect governor="pwr_lgc_chisq" client="pwr_txt_efct_w.visible" />
+ <connect governor="pwr_lgc_proptest" client="pwr_txt_efct_h.visible" />
+ <connect governor="pwr_lgc_anova" client="rad_effct_eta.visible" />
+ <connect governor="pwr_lgc_effect.not" client="rad_effct_eta.enabled" />
+ <connect governor="pwr_lgc_anova" client="spn_Nmbrfgrp.enabled" />
+ <convert id="pwr_lgc_smpl_ps" sources="pwr_lgc_tunpaired;pwr_lgc_2p" mode="or" />
+ <convert id="pwr_lgc_smpl_nondefault" sources="pwr_lgc_ttest;pwr_lgc_2p;pwr_txt_smpl_ps;pwr_lgc_anova;pwr_lgc_chisq" mode="or" />
+ <connect governor="pwr_lgc_smpl_ps" client="pwr_txt_smpl_ps.visible" />
+ <connect governor="pwr_lgc_anova" client="pwr_txt_smpl_pg.visible" />
+ <connect governor="pwr_lgc_chisq" client="pwr_txt_smpl_tt.visible" />
+ <connect governor="pwr_lgc_tpaired" client="pwr_txt_smpl_pairs.visible" />
+ <connect governor="pwr_lgc_smpl_nondefault.not" client="pwr_txt_smpl.visible" />
+ <convert id="pwr_lgc_smpl_diff" sources="pwr_lgc_tdiff;pwr_lgc_2p2n" mode="or" />
+ <connect governor="pwr_lgc_smpl_diff" client="pwr_spin_sample1.visible" />
+ <connect governor="pwr_lgc_smpl_diff" client="pwr_spin_sample2.visible" />
+ <connect governor="pwr_lgc_smpl_diff.not" client="pwr_spin_sample0.visible" />
+ <convert id="pwr_lgc_smpl_switch" sources="pwr_lgc_sample;pwr_lgc_smpl_diff" mode="and" />
+ <convert id="pwr_lgc_df_switch" sources="pwr_lgc_sample;pwr_lgc_f2test" mode="and" />
+ <convert id="pwr_lgc_enable_sample_frame" sources="pwr_lgc_sample.not;pwr_lgc_smpl_switch" mode="or" />
+ <connect governor="pwr_lgc_enable_sample_frame" client="frm_sS0301F130.enabled" />
+ <connect governor="pwr_lgc_smpl_switch" client="rad_pwr_param_2samples.visible" />
+ <connect governor="pwr_lgc_df_switch" client="rad_pwr_param_2df.visible" />
+ <convert id="pwr_lgc_smpl_n1" sources="rad_pwr_param_2samples.string" mode="equals" standard="n1" />
+ <convert id="pwr_lgc_smpl_n2" sources="rad_pwr_param_2samples.string" mode="equals" standard="n2" />
+ <convert id="pwr_lgc_df_u" sources="rad_pwr_param_2df.string" mode="equals" standard="u" />
+ <convert id="pwr_lgc_df_v" sources="rad_pwr_param_2df.string" mode="equals" standard="v" />
+ <convert id="pwr_lgc_smpl_show_n1" sources="pwr_lgc_smpl_n2;pwr_lgc_sample.not" mode="or" />
+ <convert id="pwr_lgc_smpl_show_n2" sources="pwr_lgc_smpl_n1;pwr_lgc_sample.not" mode="or" />
+ <convert id="pwr_lgc_df_show_u" sources="pwr_lgc_df_v;pwr_lgc_sample.not" mode="or" />
+ <convert id="pwr_lgc_df_show_v" sources="pwr_lgc_df_u;pwr_lgc_sample.not" mode="or" />
+ <connect governor="pwr_lgc_smpl_show_n1" client="pwr_spin_sample1.enabled" />
+ <connect governor="pwr_lgc_smpl_show_n2" client="pwr_spin_sample2.enabled" />
+ <connect governor="pwr_lgc_df_show_u" client="pwr_spin_dfu.enabled" />
+ <connect governor="pwr_lgc_df_show_v" client="pwr_spin_dfv.enabled" />
+ <convert id="pwr_lgc_noalternative" sources="pwr_lgc_anova.not;pwr_lgc_f2test.not;pwr_lgc_chisq.not" mode="and" />
+ <connect governor="pwr_lgc_noalternative" client="drp_pwr_hypothesis.enabled" />
+ <convert id="pwr_lgc_alt_less" sources="drp_pwr_hypothesis.string" mode="equals" standard="less" />
+ <convert id="pwr_lgc_alt_greater" sources="drp_pwr_hypothesis.string" mode="equals" standard="greater" />
+ <convert id="pwr_lgc_pos_effect" sources="spn_Effectsz.real" mode="range" min="0" />
+ <convert id="pwr_lgc_neg_effect" sources="spn_Effectsz.real" mode="range" max="0" />
+ <convert id="pwr_lgc_alt_warn_neg" sources="pwr_lgc_alt_less;pwr_lgc_noalternative;pwr_lgc_pos_effect" mode="and" />
+ <convert id="pwr_lgc_alt_warn_pos" sources="pwr_lgc_alt_greater;pwr_lgc_noalternative;pwr_lgc_neg_effect" mode="and" />
+ <connect governor="pwr_lgc_alt_warn_neg" client="pwr_txt_hypothesis_neg.visible" />
+ <connect governor="pwr_lgc_alt_warn_pos" client="pwr_txt_hypothesis_pos.visible" />
+ </logic>
+ <dialog label="Power analysis">
+ <row id="row_cTTPPSES2E">
+ <column id="clm_fTTPPSES2E">
+ <frame label="Target measure" id="frm_Targtmsr">
+ <radio id="rad_pwr_param" label="Parameter to determine">
+ <option label="Power of test" value="power" checked="true" />
+ <option label="Sample size" value="sample" />
+ <option label="Effect size" value="effect" />
+ <option label="Significance level" value="significance" />
+ </radio>
+ <stretch />
+ <radio id="rad_pwr_param_2samples" label="Estimate">
+ <option label="First sample" value="n1" checked="true" />
+ <option label="Second sample" value="n2" />
+ </radio>
+ <radio id="rad_pwr_param_2df" label="Estimate">
+ <option label="Numerator" value="u" checked="true" />
+ <option label="Denominator" value="v" />
+ </radio>
+ </frame>
+ </column>
+ <column id="clm_fSMSMSTCAN">
+ <frame label="Statistical Method" id="frm_SttstclM">
+ <dropdown id="drp_pwr_stat" label="Select a method">
+ <option label="t-Tests of means" value="pwr.t.test" checked="true" />
+ <option label="Correlation test" value="pwr.r.test" />
+ <option label="ANOVA (balanced one-way)" value="pwr.anova.test" />
+ <option label="General linear model" value="pwr.f2.test" />
+ <option label="Chi-squared test" value="pwr.chisq.test" />
+ <option label="Proportion tests" value="pwr.p.test" />
+ <option label="Mean of a normal distribution (known variance)" value="pwr.norm.test" />
+ </dropdown>
+ <spinbox label="Number of groups" id="spn_Nmbrfgrp" initial="2" min="1" type="integer" />
+ <dropdown id="drp_pwr_type" label="Samples">
+ <option label="Two samples (equal sizes)" value="two.sample" checked="true" />
+ <option label="Two samples (different sizes)" value="two.sample.diff" />
+ <option label="Single sample (test against constant)" value="one.sample" />
+ <option label="Paired samples" value="paired" />
+ </dropdown>
+ <dropdown id="drp_pwr_proptype" label="Samples">
+ <option label="Two samples (equal sizes)" value="two.sample.same" checked="true" />
+ <option label="Two samples (different sizes)" value="two.sample.diff" />
+ <option label="One sample" value="one.sample" />
+ </dropdown>
+ <dropdown id="drp_pwr_hypothesis" label="Using test hypothesis">
+ <option label="Two-sided" value="two.sided" checked="true" />
+ <option label="First is greater" value="greater" />
+ <option label="Second is greater" value="less" />
+ </dropdown>
+ <text id="pwr_txt_hypothesis_neg" type="warning">
+ Hypothesis probably expects a negative effect size!
+ </text>
+ <text id="pwr_txt_hypothesis_pos" type="warning">
+ Hypothesis probably expects a positive effect size!
+ </text>
+ <radio id="rad_effct_eta" label="Provided effect size">
+ <option label="Cohen's f" value="f" checked="true" />
+ <option label="Eta squared" value="e2" />
+ </radio>
+ </frame>
+ <stretch />
+ </column>
+ <column id="clm_fKKPP0801P">
+ <frame label="Known measures" id="frm_Knwnmsrs">
+ <frame id="frm_fPP0801PP0">
+ <frame id="frm_spnbPP0801">
+ <spinbox label="Power" id="spn_Power" initial="0.8" min="0" max="1" />
+ </frame>
+ <frame id="frm_sD301D301D">
+ <spinbox label="Degrees of freedom" id="pwr_spin_df" initial="30" min="1" type="integer" />
+ <spinbox label="Degrees of freedom for numerator" id="pwr_spin_dfu" initial="30" min="1" type="integer" />
+ <spinbox label="Degrees of freedom for denominator" id="pwr_spin_dfv" initial="30" min="1" type="integer" />
+ </frame>
+ <frame id="frm_sS0301F130">
+ <spinbox label="Sample size" id="pwr_spin_sample0" initial="30" min="1" type="integer" />
+ <spinbox label="First sample" id="pwr_spin_sample1" initial="30" min="1" type="integer" />
+ <spinbox label="Second sample" id="pwr_spin_sample2" initial="30" min="1" type="integer" />
+ <text id="pwr_txt_smpl">
+ Number of observations
+ </text>
+ <text id="pwr_txt_smpl_ps">
+ Number of observations <b>
+ per sample
+ </b>
+ </text>
+ <text id="pwr_txt_smpl_pg">
+ Number of observations <b>
+ per group
+ </b>
+ </text>
+ <text id="pwr_txt_smpl_tt">
+ Number of observations <b>
+ in total
+ </b>
+ </text>
+ <text id="pwr_txt_smpl_pairs">
+ Number of <b>
+ pairs
+ </b>
+ </text>
+ </frame>
+ <frame id="frm_sEE0311MCM">
+ <spinbox label="Effect size" id="spn_Effectsz" initial="0.3" min="-1" max="1" />
+ <text id="pwr_txt_efct_d">
+ Measure for selected method is <b>
+ Cohen's d
+ </b>
+ </text>
+ <text id="pwr_txt_efct_r">
+ Measure for selected method is <b>
+ Pearson's r
+ </b>
+ </text>
+ <text id="pwr_txt_efct_f">
+ Measure for selected method is <b>
+ Cohen's f
+ </b>
+ </text>
+ <text id="pwr_txt_efct_e2">
+ Measure for selected method is <b>
+ Eta <sup>
+ 2
+ </sup>
+ </b>
+ </text>
+ <text id="pwr_txt_efct_f2">
+ Measure for selected method is <b>
+ Cohen's f <sup>
+ 2
+ </sup>
+ </b>
+ </text>
+ <text id="pwr_txt_efct_w">
+ Measure for selected method is <b>
+ Cohen's w
+ </b>
+ </text>
+ <text id="pwr_txt_efct_h">
+ Measure for selected method is <b>
+ Cohen's h
+ </b>
+ </text>
+ </frame>
+ <frame id="frm_spnSS00501">
+ <spinbox label="Significance level" id="spn_Sgnfcncl" initial="0.05" min="0" max="1" />
+ </frame>
+ </frame>
+ <stretch />
+ <saveobject label="Save results to workspace" checkable="true" initial="pwr.result" id="svb_Svrsltst" />
+ </frame>
+ </column>
+ </row>
+ </dialog>
+</document>
Added: branches/external_plugins/rk.power/inst/rkward/rk.power.pluginmap
===================================================================
--- branches/external_plugins/rk.power/inst/rkward/rk.power.pluginmap (rev 0)
+++ branches/external_plugins/rk.power/inst/rkward/rk.power.pluginmap 2014-10-04 22:26:36 UTC (rev 4873)
@@ -0,0 +1,46 @@
+<!DOCTYPE rkpluginmap >
+<document
+ namespace="Poweranalysis"
+ id="Poweranalysis__rkward"
+ priority="medium"
+>
+ <!--
+ this code was generated using the rkwarddev package.
+ perhaps don't make changes here, but in the rkwarddev script instead!
+ -->
+ <dependencies rkward_min_version="0.5.6">
+ </dependencies>
+ <about
+ 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-1"
+ releasedate="2014-10-05"
+ url="http://rkward.sf.net"
+ license="GPL (>= 3)"
+ >
+ <author
+ given="Meik"
+ family="Michalke"
+ email="meik.michalke at hhu.de"
+ role="aut, cre"
+ />
+ </about>
+ <components>
+ <component
+ id="cmp_PoweranalysisPoweranalyss"
+ label="Power analysis"
+ type="standard"
+ file="plugins/Poweranalysis.xml"
+ >
+ </component>
+ </components>
+ <hierarchy>
+ <menu
+ id="analysis"
+ label.analysis="Analysis"
+ >
+ <entry component="cmp_PoweranalysisPoweranalyss" />
+ </menu>
+ </hierarchy>
+</document>
Added: branches/external_plugins/rk.power/inst/rkward/rkwarddev_power_plugin_script.R
===================================================================
--- branches/external_plugins/rk.power/inst/rkward/rkwarddev_power_plugin_script.R (rev 0)
+++ branches/external_plugins/rk.power/inst/rkward/rkwarddev_power_plugin_script.R 2014-10-04 22:26:36 UTC (rev 4873)
@@ -0,0 +1,490 @@
+# the plugin code was generated by this script
+# you should not change the plugin code directly, but this script
+# note: this script only creates objects in your workspace,
+# *EXCEPT* for the last call, see below.
+
+require(rkwarddev)
+
+local({
+# set the output directory to overwrite the actual plugin
+output.dir <- tempdir()
+overwrite <- TRUE
+# if you set guess.getters to TRUE, the resulting code willdat need RKWard >= 0.6.0
+guess.getter <- FALSE
+
+about.info <- rk.XML.about(
+ name="rk.power",
+ author=c(
+ 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-1", url="http://rkward.sf.net")
+ )
+dependencies.info <- rk.XML.dependencies(
+ dependencies=list(rkward.min=ifelse(isTRUE(guess.getter), "0.6.0", "0.5.6"),
+ package=list(c(name="pwr")))
+)
+
+
+pwr.parameter.rad <- rk.XML.radio(label="Parameter to determine", options=list(
+ "Power of test"=c(val="power", chk=TRUE),
+ "Sample size"=c(val="sample"),
+ "Effect size"=c(val="effect"),
+ "Significance level"=c(val="significance")
+ ), id.name="rad_pwr_param")
+
+pwr.parameter.twosamples.rad <- rk.XML.radio(label="Estimate", options=list(
+ "First sample"=c(val="n1", chk=TRUE),
+ "Second sample"=c(val="n2")
+ ), id.name="rad_pwr_param_2samples")
+
+pwr.parameter.twodf.rad <- rk.XML.radio(label="Estimate", options=list(
+ "Numerator"=c(val="u", chk=TRUE),
+ "Denominator"=c(val="v")
+ ), id.name="rad_pwr_param_2df")
+
+pwr.stat.drop <- rk.XML.dropdown(label="Select a method", options=list(
+ "t-Tests of means"=c(val="pwr.t.test", chk=TRUE),
+ "Correlation test"=c(val="pwr.r.test"),
+ "ANOVA (balanced one-way)"=c(val="pwr.anova.test"),
+ "General linear model"=c(val="pwr.f2.test"),
+ "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")
+
+pwr.hypothesis.drop <- rk.XML.dropdown("Using test hypothesis",
+ options=list(
+ "Two-sided"=c(val="two.sided", chk=TRUE),
+ "First is greater"=c(val="greater"),
+ "Second is greater"=c(val="less")
+ ),
+ id.name="drp_pwr_hypothesis")
+pwr.txt.hypothesis.neg <- rk.XML.text("Hypothesis probably expects a negative effect size!", id.name="pwr_txt_hypothesis_neg", type="warning")
+pwr.txt.hypothesis.pos <- rk.XML.text("Hypothesis probably expects a positive effect size!", id.name="pwr_txt_hypothesis_pos", type="warning")
+
+pwr.effect.etasq.rad <- rk.XML.radio(label="Provided effect size", options=list(
+ "Cohen's f"=c(val="f", chk=TRUE),
+ "Eta squared"=c(val="e2")
+ ), id.name="rad_effct_eta")
+
+pwr.type.drop <- rk.XML.dropdown("Samples",
+ options=list(
+ "Two samples (equal sizes)"=c(val="two.sample", chk=TRUE),
+ "Two samples (different sizes)"=c(val="two.sample.diff"), # pwr.t2n.test
+ "Single sample (test against constant)"=c(val="one.sample"),
+ "Paired samples"=c(val="paired")
+ ),
+ id.name="drp_pwr_type")
+
+pwr.proptype.drop <- rk.XML.dropdown("Samples",
+ options=list(
+ "Two samples (equal sizes)"=c(val="two.sample.same", chk=TRUE), # pwr.2p.test
+ "Two samples (different sizes)"=c(val="two.sample.diff"), # pwr.2p2n.test
+ "One sample"=c(val="one.sample") # pwr.p.test
+ ),
+ id.name="drp_pwr_proptype")
+
+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)
+
+pwr.input.sample <- rk.XML.spinbox(label="Sample size", id.name="pwr_spin_sample0", min=1, real=FALSE, initial=30)
+pwr.input.sample.n1 <- rk.XML.spinbox(label="First sample", id.name="pwr_spin_sample1", min=1, real=FALSE, initial=30)
+pwr.input.sample.n2 <- rk.XML.spinbox(label="Second sample", id.name="pwr_spin_sample2", min=1, real=FALSE, initial=30)
+pwr.txt.sample.default <- rk.XML.text("Number of observations", id.name="pwr_txt_smpl")
+pwr.txt.sample.ps <- rk.XML.text("Number of observations <b>per sample</b>", id.name="pwr_txt_smpl_ps")
+pwr.txt.sample.pg <- rk.XML.text("Number of observations <b>per group</b>", id.name="pwr_txt_smpl_pg")
+pwr.txt.sample.tt <- rk.XML.text("Number of observations <b>in total</b>", id.name="pwr_txt_smpl_tt")
+pwr.txt.sample.pairs <- rk.XML.text("Number of <b>pairs</b>", id.name="pwr_txt_smpl_pairs")
+
+pwr.input.groups <- rk.XML.spinbox(label="Number of groups", min=1, real=FALSE, initial=2)
+
+pwr.input.effect <- rk.XML.spinbox(label="Effect size", min=-1, max=1, initial=0.3)
+# effect sizes: d, r, f, f2, w, h
+pwr.txt.effect.d <- rk.XML.text("Measure for selected method is <b>Cohen's d</b>", id.name="pwr_txt_efct_d")
+pwr.txt.effect.r <- rk.XML.text("Measure for selected method is <b>Pearson's r</b>", id.name="pwr_txt_efct_r")
+pwr.txt.effect.f <- rk.XML.text("Measure for selected method is <b>Cohen's f</b>", id.name="pwr_txt_efct_f")
+pwr.txt.effect.e2 <- rk.XML.text("Measure for selected method is <b>Eta<sup>2</sup></b>", id.name="pwr_txt_efct_e2")
+# f <- sqrt(etasq / (1 - etasq))
+pwr.txt.effect.f2 <- rk.XML.text("Measure for selected method is <b>Cohen's f<sup>2</sup></b>", id.name="pwr_txt_efct_f2")
+pwr.txt.effect.w <- rk.XML.text("Measure for selected method is <b>Cohen's w</b>", id.name="pwr_txt_efct_w")
+pwr.txt.effect.h <- rk.XML.text("Measure for selected method is <b>Cohen's h</b>", id.name="pwr_txt_efct_h")
+pwr.input.signif <- rk.XML.spinbox(label="Significance level", min=0, max=1, initial=0.05)
+
+
+save.results.pwr <- rk.XML.saveobj("Save results to workspace", initial="pwr.result")
+
+tab.pwr.data <- rk.XML.row(
+ rk.XML.col(
+ rk.XML.frame(
+ pwr.parameter.rad,
+ rk.XML.stretch(),
+ pwr.parameter.twosamples.rad,
+ pwr.parameter.twodf.rad,
+ label="Target measure"
+ )
+ ),
+ rk.XML.col(
+ rk.XML.frame(
+ pwr.stat.drop,
+ pwr.input.groups,
+ pwr.type.drop,
+ pwr.proptype.drop,
+ pwr.hypothesis.drop,
+ pwr.txt.hypothesis.neg,
+ pwr.txt.hypothesis.pos,
+ pwr.effect.etasq.rad,
+ label="Statistical Method"
+ ),
+ rk.XML.stretch()
+ ),
+ rk.XML.col(
+ rk.XML.frame(
+ rk.XML.frame(
+ pwr.frame.power <- rk.XML.frame(pwr.input.power),
+ pwr.frame.df <- rk.XML.frame(
+ pwr.input.df,
+ pwr.input.dfu,
+ pwr.input.dfv
+ ),
+ pwr.frame.sample <- rk.XML.frame(
+ pwr.input.sample,
+ pwr.input.sample.n1,
+ pwr.input.sample.n2,
+ pwr.txt.sample.default,
+ pwr.txt.sample.ps,
+ pwr.txt.sample.pg,
+ pwr.txt.sample.tt,
+ pwr.txt.sample.pairs
+ ),
+ pwr.frame.effect <- rk.XML.frame(
+ pwr.input.effect,
+ pwr.txt.effect.d,
+ pwr.txt.effect.r,
+ pwr.txt.effect.f,
+ pwr.txt.effect.e2,
+ pwr.txt.effect.f2,
+ pwr.txt.effect.w,
+ pwr.txt.effect.h
+ ),
+ pwr.frame.signif <- rk.XML.frame(pwr.input.signif)
+ ),
+ rk.XML.stretch(),
+ save.results.pwr,
+ label="Known measures"
+ )
+ )
+ )
+
+pwr.full.dialog <- rk.XML.dialog(
+ tab.pwr.data,
+ label="Power analysis")
+
+## logic section
+ lgc.sect.pwr <- rk.XML.logic(
+ pwr.gov.want.power <- rk.XML.convert(sources=list(string=pwr.parameter.rad), mode=c(equals="power"), id.name="pwr_lgc_power"),
+ pwr.gov.want.sample <- rk.XML.convert(sources=list(string=pwr.parameter.rad), mode=c(equals="sample"), id.name="pwr_lgc_sample"),
+ pwr.gov.want.effect <- rk.XML.convert(sources=list(string=pwr.parameter.rad), mode=c(equals="effect"), id.name="pwr_lgc_effect"),
+ pwr.gov.want.signif <- rk.XML.convert(sources=list(string=pwr.parameter.rad), mode=c(equals="significance"), id.name="pwr_lgc_signif"),
+ rk.XML.connect(governor=pwr.gov.want.power, client=pwr.frame.power, set="enabled", not=TRUE),
+ rk.XML.connect(governor=pwr.gov.want.effect, client=pwr.frame.effect, set="enabled", not=TRUE),
+ rk.XML.connect(governor=pwr.gov.want.signif, client=pwr.frame.signif, set="enabled", not=TRUE),
+
+ pwr.gov.meth.ttest <- rk.XML.convert(sources=list(string=pwr.stat.drop), mode=c(equals="pwr.t.test"), id.name="pwr_lgc_ttest"),
+ pwr.gov.meth.rtest <- rk.XML.convert(sources=list(string=pwr.stat.drop), mode=c(equals="pwr.r.test"), id.name="pwr_lgc_rtest"),
+ pwr.gov.meth.anova <- rk.XML.convert(sources=list(string=pwr.stat.drop), mode=c(equals="pwr.anova.test"), id.name="pwr_lgc_anova"),
+ pwr.gov.meth.f2test <- rk.XML.convert(sources=list(string=pwr.stat.drop), mode=c(equals="pwr.f2.test"), id.name="pwr_lgc_f2test"),
+ pwr.gov.meth.chisq <- rk.XML.convert(sources=list(string=pwr.stat.drop), mode=c(equals="pwr.chisq.test"), id.name="pwr_lgc_chisq"),
+ pwr.gov.meth.proptest <- rk.XML.convert(sources=list(string=pwr.stat.drop), mode=c(equals="pwr.p.test"), id.name="pwr_lgc_proptest"),
+ pwr.gov.meth.norm <- rk.XML.convert(sources=list(string=pwr.stat.drop), mode=c(equals="pwr.norm.test"), id.name="pwr_lgc_norm"),
+ pwr.gov.meth.proptest.same <- rk.XML.convert(sources=list(string=pwr.proptype.drop), mode=c(equals="two.sample.same"), id.name="pwr_lgc_sample_2p_same"),
+ pwr.gov.meth.proptest.diff <- rk.XML.convert(sources=list(string=pwr.proptype.drop), mode=c(equals="two.sample.diff"), id.name="pwr_lgc_sample_2p_diff"),
+ pwr.gov.meth.ttest.2diff <- rk.XML.convert(sources=list(string=pwr.type.drop), mode=c(equals="two.sample.diff"), id.name="pwr_lgc_sample_t_diff"),
+ pwr.gov.meth.ttest.pairs <- rk.XML.convert(sources=list(string=pwr.type.drop), mode=c(equals="paired"), id.name="pwr_lgc_sample_t_pairs"),
+ pwr.gov.meth.ttest.nopairs <- rk.XML.convert(sources=list(string=pwr.type.drop), mode=c(notequals="paired"), id.name="pwr_lgc_sample_t_nopairs"),
+ pwr.gov.meth.2ptest <- rk.XML.convert(sources=list(pwr.gov.meth.proptest.same, pwr.gov.meth.proptest), mode=c(and=""), id.name="pwr_lgc_2p"),
+ pwr.gov.meth.2p2ntest <- rk.XML.convert(sources=list(pwr.gov.meth.proptest.diff, pwr.gov.meth.proptest), mode=c(and=""), id.name="pwr_lgc_2p2n"),
+ pwr.gov.meth.ttest.diff <- rk.XML.convert(sources=list(pwr.gov.meth.ttest.2diff, pwr.gov.meth.ttest), mode=c(and=""), id.name="pwr_lgc_tdiff"),
+ pwr.gov.meth.ttest.paired <- rk.XML.convert(sources=list(pwr.gov.meth.ttest.pairs, pwr.gov.meth.ttest), mode=c(and=""), id.name="pwr_lgc_tpaired"),
+ pwr.gov.meth.ttest.unpaired <- rk.XML.convert(sources=list(pwr.gov.meth.ttest.nopairs, pwr.gov.meth.ttest), mode=c(and=""),
+ id.name="pwr_lgc_tunpaired"),
+
+ rk.XML.connect(governor=pwr.gov.meth.proptest, client=pwr.type.drop, set="visible", not=TRUE),
+ rk.XML.connect(governor=pwr.gov.meth.ttest, client=pwr.type.drop, set="enabled"),
+ rk.XML.connect(governor=pwr.gov.meth.proptest, client=pwr.proptype.drop, set="visible"),
+ rk.XML.connect(governor=pwr.gov.meth.proptest, client=pwr.proptype.drop, set="enabled"),
+ rk.XML.connect(governor=pwr.gov.meth.f2test, client=pwr.frame.sample, set="visible", not=TRUE),
+ pwr.gov.meth.df <- rk.XML.convert(sources=list(pwr.gov.meth.f2test, pwr.gov.meth.chisq), mode=c(or=""), id.name="pwr_lgc_show_df"),
+ rk.XML.connect(governor=pwr.gov.meth.df, client=pwr.frame.df, set="visible"),
+ rk.XML.connect(governor=pwr.gov.meth.chisq, client=pwr.input.df, set="visible"),
+ rk.XML.connect(governor=pwr.gov.meth.f2test, client=pwr.input.dfu, set="visible"),
+ rk.XML.connect(governor=pwr.gov.meth.f2test, client=pwr.input.dfv, set="visible"),
+
+ pwr.gov.efct.d <- rk.XML.convert(sources=list(pwr.gov.meth.ttest, pwr.gov.meth.norm), mode=c(or=""), id.name="pwr_lgc_efct_d"),
+ rk.XML.connect(governor=pwr.gov.efct.d, client=pwr.txt.effect.d, set="visible"),
+ rk.XML.connect(governor=pwr.gov.meth.rtest, client=pwr.txt.effect.r, set="visible"),
+ pwr.gov.efct.f <- rk.XML.convert(sources=list(string=pwr.effect.etasq.rad), mode=c(equals="f"), id.name="pwr_lgc_efct_f"),
+ pwr.gov.efct.show.f <- rk.XML.convert(sources=list(pwr.gov.meth.anova, pwr.gov.efct.f), mode=c(and=""), id.name="pwr_lgc_efct_show_f"),
+ pwr.gov.efct.show.e2 <- rk.XML.convert(sources=list(pwr.gov.meth.anova, not=pwr.gov.efct.f), mode=c(and=""), id.name="pwr_lgc_efct_show_e2"),
+ rk.XML.connect(governor=pwr.gov.efct.show.f, client=pwr.txt.effect.f, set="visible"),
+ rk.XML.connect(governor=pwr.gov.efct.show.e2, client=pwr.txt.effect.e2, set="visible"),
+ rk.XML.connect(governor=pwr.gov.meth.f2test, client=pwr.txt.effect.f2, set="visible"),
+ rk.XML.connect(governor=pwr.gov.meth.chisq, client=pwr.txt.effect.w, set="visible"),
+ rk.XML.connect(governor=pwr.gov.meth.proptest, client=pwr.txt.effect.h, set="visible"),
+ rk.XML.connect(governor=pwr.gov.meth.anova, client=pwr.effect.etasq.rad, set="visible"),
+ rk.XML.connect(governor=pwr.gov.want.effect, client=pwr.effect.etasq.rad, set="enabled", not=TRUE),
+
+ rk.XML.connect(governor=pwr.gov.meth.anova, client=pwr.input.groups, set="enabled"),
+
+ # text for sample size
+ pwr.gov.smpl.ps <- rk.XML.convert(sources=list(pwr.gov.meth.ttest.unpaired, pwr.gov.meth.2ptest), mode=c(or=""), id.name="pwr_lgc_smpl_ps"),
+ pwr.gov.smpl.nondefault <- rk.XML.convert(sources=list(
+ pwr.gov.meth.ttest,
+ pwr.gov.meth.2ptest,
+ pwr.txt.sample.ps,
+ pwr.gov.meth.anova,
+ pwr.gov.meth.chisq), mode=c(or=""), id.name="pwr_lgc_smpl_nondefault"),
+ rk.XML.connect(governor=pwr.gov.smpl.ps, client=pwr.txt.sample.ps, set="visible"),
+ rk.XML.connect(governor=pwr.gov.meth.anova, client=pwr.txt.sample.pg, set="visible"),
+ rk.XML.connect(governor=pwr.gov.meth.chisq, client=pwr.txt.sample.tt, set="visible"),
+ rk.XML.connect(governor=pwr.gov.meth.ttest.paired, client=pwr.txt.sample.pairs, set="visible"),
+ rk.XML.connect(governor=pwr.gov.smpl.nondefault, client=pwr.txt.sample.default, set="visible", not=TRUE),
+ pwr.gov.smpl.diff <- rk.XML.convert(sources=list(pwr.gov.meth.ttest.diff, pwr.gov.meth.2p2ntest), mode=c(or=""), id.name="pwr_lgc_smpl_diff"),
+ rk.XML.connect(governor=pwr.gov.smpl.diff, client=pwr.input.sample.n1, set="visible"),
+ rk.XML.connect(governor=pwr.gov.smpl.diff, client=pwr.input.sample.n2, set="visible"),
+ rk.XML.connect(governor=pwr.gov.smpl.diff, client=pwr.input.sample, set="visible", not=TRUE),
+
+ # switch between sample estimations
+ pwr.gov.smpl.switch <- rk.XML.convert(sources=list(pwr.gov.want.sample, pwr.gov.smpl.diff), mode=c(and=""), id.name="pwr_lgc_smpl_switch"),
+ pwr.gov.df.switch <- rk.XML.convert(sources=list(pwr.gov.want.sample, pwr.gov.meth.f2test), mode=c(and=""), id.name="pwr_lgc_df_switch"),
+ pwr.gov.enable.sample.frame <- rk.XML.convert(sources=list(not=pwr.gov.want.sample, pwr.gov.smpl.switch), mode=c(or=""), id.name="pwr_lgc_enable_sample_frame"),
+ rk.XML.connect(governor=pwr.gov.enable.sample.frame, client=pwr.frame.sample, set="enabled"),
+ rk.XML.connect(governor=pwr.gov.smpl.switch, client=pwr.parameter.twosamples.rad, set="visible"),
+ rk.XML.connect(governor=pwr.gov.df.switch, client=pwr.parameter.twodf.rad, set="visible"),
+ pwr.gov.smpl.n1 <- rk.XML.convert(sources=list(string=pwr.parameter.twosamples.rad), mode=c(equals="n1"), id.name="pwr_lgc_smpl_n1"),
+ pwr.gov.smpl.n2 <- rk.XML.convert(sources=list(string=pwr.parameter.twosamples.rad), mode=c(equals="n2"), id.name="pwr_lgc_smpl_n2"),
+ pwr.gov.df.u <- rk.XML.convert(sources=list(string=pwr.parameter.twodf.rad), mode=c(equals="u"), id.name="pwr_lgc_df_u"),
+ pwr.gov.df.v <- rk.XML.convert(sources=list(string=pwr.parameter.twodf.rad), mode=c(equals="v"), id.name="pwr_lgc_df_v"),
+ pwr.gov.smpl.show.n1 <- rk.XML.convert(sources=list(pwr.gov.smpl.n2, not=pwr.gov.want.sample), mode=c(or=""), id.name="pwr_lgc_smpl_show_n1"),
+ pwr.gov.smpl.show.n2 <- rk.XML.convert(sources=list(pwr.gov.smpl.n1, not=pwr.gov.want.sample), mode=c(or=""), id.name="pwr_lgc_smpl_show_n2"),
+ pwr.gov.df.show.u <- rk.XML.convert(sources=list(pwr.gov.df.v, not=pwr.gov.want.sample), mode=c(or=""), id.name="pwr_lgc_df_show_u"),
+ pwr.gov.df.show.v <- rk.XML.convert(sources=list(pwr.gov.df.u, not=pwr.gov.want.sample), mode=c(or=""), id.name="pwr_lgc_df_show_v"),
+ rk.XML.connect(governor=pwr.gov.smpl.show.n1, client=pwr.input.sample.n1, set="enabled"),
+ rk.XML.connect(governor=pwr.gov.smpl.show.n2, client=pwr.input.sample.n2, set="enabled"),
+ rk.XML.connect(governor=pwr.gov.df.show.u, client=pwr.input.dfu, set="enabled"),
+ rk.XML.connect(governor=pwr.gov.df.show.v, client=pwr.input.dfv, set="enabled"),
+
+ # disable alterative setting
+ pwr.gov.meth.noalternative <- rk.XML.convert(sources=list(not=pwr.gov.meth.anova, not=pwr.gov.meth.f2test, not=pwr.gov.meth.chisq), mode=c(and=""), id.name="pwr_lgc_noalternative"),
+ rk.XML.connect(governor=pwr.gov.meth.noalternative, client=pwr.hypothesis.drop, set="enabled"),
+ # check if a warning regarding negative effect size is in order
+ pwr.gov.meth.alt.less <- rk.XML.convert(sources=list(string=pwr.hypothesis.drop), mode=c(equals="less"), id.name="pwr_lgc_alt_less"),
+ pwr.gov.meth.alt.greater <- rk.XML.convert(sources=list(string=pwr.hypothesis.drop), mode=c(equals="greater"), id.name="pwr_lgc_alt_greater"),
+ pwr.gov.meth.effect.positive <- rk.XML.convert(sources=list(real=pwr.input.effect), mode=c(min=0), id.name="pwr_lgc_pos_effect"),
+ pwr.gov.meth.effect.negative <- rk.XML.convert(sources=list(real=pwr.input.effect), mode=c(max=0), id.name="pwr_lgc_neg_effect"),
+ pwr.gov.meth.alt.warning.neg <- rk.XML.convert(sources=list(pwr.gov.meth.alt.less, pwr.gov.meth.noalternative, pwr.gov.meth.effect.positive), mode=c(and=""), id.name="pwr_lgc_alt_warn_neg"),
+ pwr.gov.meth.alt.warning.pos <- rk.XML.convert(sources=list(pwr.gov.meth.alt.greater, pwr.gov.meth.noalternative, pwr.gov.meth.effect.negative), mode=c(and=""), id.name="pwr_lgc_alt_warn_pos"),
+ rk.XML.connect(governor=pwr.gov.meth.alt.warning.neg, client=pwr.txt.hypothesis.neg, set="visible"),
+ rk.XML.connect(governor=pwr.gov.meth.alt.warning.pos, client=pwr.txt.hypothesis.pos, set="visible")
+ )
+
+
+
+## JavaScript
+pwr.js.calc <- rk.paste.JS(
+ echo("\tpwr.result <- "),
+ #########
+ ## t-test
+ ite(id(pwr.stat.drop, " == \"pwr.t.test\""),
+ rk.paste.JS(
+ # two samples with different sizes or not?
+ ite(id(pwr.type.drop, " == \"two.sample.diff\""),
+ rk.paste.JS(# yes
+ echo("pwr.t2n.test("),
+ ite(id(pwr.parameter.rad, " != \"sample\""),
+ echo("\n\t\tn1=", pwr.input.sample.n1, ",\n\t\tn2=", pwr.input.sample.n2),
+ ite(id(pwr.parameter.twosamples.rad, " == \"n2\""),
+ echo("\n\t\tn1=", pwr.input.sample.n1, ","),
+ echo("\n\t\tn2=", pwr.input.sample.n2, ",")
+ )
+ )
+ ),
+ rk.paste.JS(#no
+ echo("pwr.t.test("),
+ ite(id(pwr.parameter.rad, " != \"sample\""),
+ echo("\n\t\tn=", pwr.input.sample)
+ )
+ )
+ ),
+ ite(id(pwr.parameter.rad, " != \"effect\""),
+ rk.paste.JS(
+ ite(id(pwr.parameter.rad, " != \"sample\""), echo(",")),
+ echo("\n\t\td=", pwr.input.effect)
+ )
+ )
+ )
+ ),
+ ###############
+ ## correlations
+ ite(id(pwr.stat.drop, " == \"pwr.r.test\""),
+ rk.paste.JS(
+ echo("pwr.r.test("),
+ ite(id(pwr.parameter.rad, " != \"sample\""),
+ echo("\n\t\tn=", pwr.input.sample)
+ ),
+ ite(id(pwr.parameter.rad, " != \"effect\""),
+ rk.paste.JS(
+ ite(id(pwr.parameter.rad, " != \"sample\""), echo(",")),
+ echo("\n\t\tr=", pwr.input.effect)
+ )
+ )
+ )
+ ),
+ ########
+ ## ANOVA
+ ite(id(pwr.stat.drop, " == \"pwr.anova.test\""),
+ rk.paste.JS(
+ echo("pwr.anova.test("),
+ echo("\n\t\tk=", pwr.input.groups),
+ ite(id(pwr.parameter.rad, " != \"sample\""),
+ echo(",\n\t\tn=", pwr.input.sample)
+ ),
+ ite(id(pwr.parameter.rad, " != \"effect\""),
+ ite(id(pwr.effect.etasq.rad, " == \"f\""),
+ echo(",\n\t\tf=", pwr.input.effect),
+ echo(",\n\t\tf=sqrt(", pwr.input.effect,"/(1-", pwr.input.effect,")) # calculate f from eta squared")
+ )
+ )
+ )
+ ),
+ ######
+ ## GLM
+ ite(id(pwr.stat.drop, " == \"pwr.f2.test\""),
+ rk.paste.JS(
+ echo("pwr.f2.test("),
+ ite(id(pwr.parameter.rad, " != \"sample\""),
+ echo(",\n\t\tu=", pwr.input.dfu, ",\n\t\tv=", pwr.input.dfv),
+ ite(id(pwr.parameter.twodf.rad, " == \"v\""),
+ echo("\n\t\tu=", pwr.input.dfu),
+ echo("\n\t\tv=", pwr.input.dfv)
+ )
+ ),
+ ite(id(pwr.parameter.rad, " != \"effect\""),
+ rk.paste.JS(
+ echo(",\n\t\tf2=", pwr.input.effect)
+ )
+ )
+ )
+ ),
+ ##############
+ ## Chi squared
+ ite(id(pwr.stat.drop, " == \"pwr.chisq.test\""),
+ rk.paste.JS(
+ echo("pwr.chisq.test("),
+ ite(id(pwr.parameter.rad, " != \"effect\""),
+ echo("\n\t\tw=", pwr.input.effect)
+ ),
+ ite(id(pwr.parameter.rad, " != \"sample\""),
+ rk.paste.JS(
+ ite(id(pwr.parameter.rad, " != \"effect\""), echo(",")),
+ echo("\n\t\tN=", pwr.input.sample)
+ )
+ ),
+ echo(",\n\t\tdf=", pwr.input.df)
+ )
+ ),
+ ##############
+ ## proportions
+ ite(id(pwr.stat.drop, " == \"pwr.p.test\""),
+ rk.paste.JS(
+ ite(id(pwr.proptype.drop, " == \"two.sample.same\""), echo("pwr.2p.test(")),
+ ite(id(pwr.proptype.drop, " == \"two.sample.diff\""), echo("pwr.2p2n.test(")),
+ ite(id(pwr.proptype.drop, " == \"one.sample\""), echo("pwr.p.test(")),
+ ite(id(pwr.parameter.rad, " != \"effect\""),
+ echo("\n\t\th=", pwr.input.effect)
+ ),
+ ite(id(pwr.parameter.rad, " != \"sample\""),
+ rk.paste.JS(
+ ite(id(pwr.parameter.rad, " != \"effect\""), echo(",")),
+ ite(id(pwr.proptype.drop, " != \"two.sample.diff\""),
+ echo("\n\t\tn=", pwr.input.sample),
+ echo("\n\t\tn1=", pwr.input.sample.n1, ",\n\t\tn2=", pwr.input.sample.n2)
+ )
+ ),
+ ite(id(pwr.proptype.drop, " == \"two.sample.diff\""),
+ ite(id(pwr.parameter.twosamples.rad, " == \"n2\""),
+ echo("\n\t\tn1=", pwr.input.sample.n1, ","),
+ echo("\n\t\tn2=", pwr.input.sample.n2, ",")
+ )
+ )
+ )
+ )
+ ),
+ ######################
+ ## normal distribution
+ ite(id(pwr.stat.drop, " == \"pwr.norm.test\""),
+ rk.paste.JS(
+ echo("pwr.norm.test("),
+ ite(id(pwr.parameter.rad, " != \"effect\""),
+ echo("\n\t\td=", pwr.input.effect)
+ ),
+ ite(id(pwr.parameter.rad, " != \"sample\""),
+ rk.paste.JS(
+ ite(id(pwr.parameter.rad, " != \"effect\""), echo(",")),
+ echo("\n\t\tn=", pwr.input.sample)
+ )
+ )
+ )
+ ),
+ ite(id(pwr.parameter.rad, " != \"significance\""),
+ ite(id(pwr.input.signif, " != 0.05"), echo("\n\t\tsig.level=", pwr.input.signif, ",")),
+ echo(",\n\t\tsig.level=NULL")
+ ),
+ ite(id(pwr.parameter.rad, " != \"power\""),
+ echo(",\n\t\tpower=", pwr.input.power)
+ ),
+ ite(id(pwr.stat.drop, " == \"pwr.t.test\" & ", pwr.type.drop, " != \"two.sample.diff\" & ", pwr.type.drop, " != \"two.sample\""),
+ echo(",\n\t\ttype=\"", pwr.type.drop, "\"")
+ ),
+ ite(id(pwr.stat.drop, " != \"pwr.anova.test\" & ", pwr.stat.drop, " != \"pwr.f2.test\" & ", pwr.stat.drop, " != \"pwr.chisq.test\""),
+ ite(id(pwr.hypothesis.drop, " != \"two.sided\""),
+ echo(",\n\t\talternative=\"", pwr.hypothesis.drop, "\"")
+ )
+ ),
+ echo("\n\t)\n\n")
+)
+
+pwr.js.print <- rk.paste.JS(
+ echo("rk.print(pwr.result)\n")
+)
+
+
+#############
+## if you run the following function call, files will be written to tempdir!
+#############
+# this is where it get's serious, that is, here all of the above is put together into one plugin
+
+pwr.plugin.dir <<- rk.plugin.skeleton(
+ about.info,
+ path=output.dir,
+ guess.getter=guess.getter,
+ xml=list(
+ dialog=pwr.full.dialog,
+ logic=lgc.sect.pwr
+ ),
+ js=list(#results.header=FALSE,
+ require="pwr",
+ calculate=pwr.js.calc,
+ printout=pwr.js.print),
+ pluginmap=list(name="Power analysis", hierarchy=list("analysis")),
+ dependencies=dependencies.info,
+ create=c("pmap", "xml", "js", "desc"),
+ overwrite=overwrite,
+ tests=FALSE,
+# edit=TRUE,
+ load=TRUE,
+# show=TRUE,
+ hints=FALSE)
+})
More information about the rkward-tracker
mailing list