[rkward-cvs] SF.net SVN: rkward:[4101] trunk/rkward/rkward/plugins
m-eik at users.sourceforge.net
m-eik at users.sourceforge.net
Sun Dec 11 18:42:49 UTC 2011
Revision: 4101
http://rkward.svn.sourceforge.net/rkward/?rev=4101&view=rev
Author: m-eik
Date: 2011-12-11 18:42:48 +0000 (Sun, 11 Dec 2011)
Log Message:
-----------
broadened scope of t-test plugin: it can now also test variables agains constants. plugin tests need to be updated, but let's first see if the plugin can stay this way.
Modified Paths:
--------------
trunk/rkward/rkward/plugins/analysis.pluginmap
Added Paths:
-----------
trunk/rkward/rkward/plugins/analysis/t_test.js
trunk/rkward/rkward/plugins/analysis/t_test.rkh
trunk/rkward/rkward/plugins/analysis/t_test.xml
Removed Paths:
-------------
trunk/rkward/rkward/plugins/analysis/t_test_two_vars.js
trunk/rkward/rkward/plugins/analysis/t_test_two_vars.rkh
trunk/rkward/rkward/plugins/analysis/t_test_two_vars.xml
Added: trunk/rkward/rkward/plugins/analysis/t_test.js
===================================================================
--- trunk/rkward/rkward/plugins/analysis/t_test.js (rev 0)
+++ trunk/rkward/rkward/plugins/analysis/t_test.js 2011-12-11 18:42:48 UTC (rev 4101)
@@ -0,0 +1,73 @@
+// globals
+var x;
+var y;
+var mu;
+var testForm;
+var varequal;
+var paired;
+
+function preprocess () {
+ x = getValue ("x");
+ y = getValue ("y");
+ mu = getValue ("mu");
+ testForm = getValue ("test_form");
+
+ if (testForm == "vars") {
+ echo ('names <- rk.get.description (' + x + ", " + y + ')\n');
+ } else {
+ echo ('names <- rk.get.description (' + x + ')\n');
+ }
+}
+
+function calculate () {
+ varequal = getValue ("varequal");
+ paired = getValue ("paired");
+
+ var conflevel = getValue ("conflevel");
+ var hypothesis = getValue ("hypothesis");
+
+ var options = ", alternative=\"" + hypothesis + "\"";
+ if (testForm == "vars" && paired) options += ", paired=TRUE";
+ if (testForm == "vars" && (!paired) && varequal) options += ", var.equal=TRUE";
+ if (conflevel != "0.95") options += ", conf.level=" + conflevel;
+
+ echo('result <- t.test (x=' + x);
+ if(testForm == "vars") {
+ echo(', y=' + y);
+ } else {
+ echo(', mu=' + mu);
+ }
+ echo (options + ')\n');
+}
+
+function printout () {
+ echo ('rk.header (result$method, \n');
+ if (testForm == "vars") {
+ echo (' parameters=list ("Comparing", paste (names[1], "against", names[2]),\n');
+ } else {
+ echo (' parameters=list ("Comparing", paste (names[1], "against constant"),\n');
+ }
+ echo (' "H1", rk.describe.alternative (result)');
+ if (!paired) {
+ echo (',\n');
+ echo (' "Equal variances", "');
+ if (!varequal) echo ("not");
+ echo (' assumed"');
+ }
+ echo ('))\n');
+ echo ('\n');
+ echo ('rk.results (list (\n');
+ echo (' \'Variable Name\'=names,\n');
+ echo (' \'estimated mean\'=result$estimate,\n');
+ echo (' \'degrees of freedom\'=result$parameter,\n');
+ echo (' t=result$statistic,\n');
+ echo (' p=result$p.value');
+ if (getValue ("confint")) {
+ echo (',\n');
+ echo (' \'confidence interval percent\'=(100 * attr(result$conf.int, "conf.level")),\n');
+ echo (' \'confidence interval of difference\'=result$conf.int ');
+ }
+ echo ('))\n');
+}
+
+
Added: trunk/rkward/rkward/plugins/analysis/t_test.rkh
===================================================================
--- trunk/rkward/rkward/plugins/analysis/t_test.rkh (rev 0)
+++ trunk/rkward/rkward/plugins/analysis/t_test.rkh 2011-12-11 18:42:48 UTC (rev 4101)
@@ -0,0 +1,30 @@
+<!DOCTYPE rkhelp>
+<document>
+ <summary>
+t-Test (two variable paired or independent samples, or one variable).
+ </summary>
+
+ <usage>
+Chose two numeric vectors or one vector an a constant to compare against each other. For two samples, specify whether the variables are paired or independent samples. For details, see below.
+ </usage>
+
+ <settings>
+ <caption id="tab_variables"/>
+ <setting id="test_form">Chose if you want a two samples test, or test against a constant</setting>
+ <setting id="x">A numeric vector for the first variable</setting>
+ <setting id="y">A numeric vector for the second variable. Available for two samples tests only.</setting>
+ <setting id="mu">A numeric constant. Available for tests agains constant only.</setting>
+ <setting id="hypothesis">Alternative hypothesis (H1) of the test.</setting>
+ <setting id="paired">Whether the variables are paired (repeated measurements on the same subject) or independent samples. For a paired test, if the two vectors are not of equal length, there will be an error.</setting>
+ <caption id="tab_options"/>
+ <setting id="varequal">Whether to assume equal variances for the two samples. This option is implied for a paired test.</setting>
+ <setting id="conflevel">Confidence level to use.</setting>
+ <setting id="confint">Whether to print the confidence interval of the estimated mean.</setting>
+ </settings>
+ <related>
+ <ul>
+ <li><link href="rkward://component/F_test"/></li>
+ <li><link href="rkward://rhelp/t.test"/></li>
+ </ul>
+ </related>
+</document>
Added: trunk/rkward/rkward/plugins/analysis/t_test.xml
===================================================================
--- trunk/rkward/rkward/plugins/analysis/t_test.xml (rev 0)
+++ trunk/rkward/rkward/plugins/analysis/t_test.xml 2011-12-11 18:42:48 UTC (rev 4101)
@@ -0,0 +1,75 @@
+<!DOCTYPE rkplugin>
+<document>
+ <code file="t_test.js"/>
+ <help file="t_test.rkh"/>
+
+ <logic>
+ <convert id="two_vars" sources="test_form.string" mode="equals" standard="vars" />
+ <connect governor="two_vars" client="y.visible" />
+ <connect governor="two_vars" client="y.required" />
+ <connect governor="two_vars.not" client="mu.visible" />
+ <connect governor="two_vars" client="paired.enabled" />
+ <connect governor="two_vars" client="varequal.enabled" />
+ <convert id="notpaired" sources="paired.state" mode="equals" standard="0" />
+ <connect governor="notpaired" client="varequal.enabled" />
+ <convert id="noteqvars" sources="varequal.state" mode="equals" standard="0" />
+ <connect governor="noteqvars" client="paired.enabled" />
+ </logic>
+
+ <dialog label="t-Test">
+ <tabbook>
+ <tab label="Basic settings" id="tab_variables">
+ <row id="basic_settings_row">
+ <varselector id="vars"/>
+ <column>
+ <dropdown id="test_form" label="Test form">
+ <option label="compare two varaibles" value="vars" checked="true" />
+ <option label="compare variable against constant" value="const" />
+ </dropdown>
+ <varslot id="x" label="compare" source="vars" types="number" required="true" />
+ <varslot id="y" label="against" source="vars" types="number" />
+ <spinbox label="against" id="mu" />
+ <radio id="hypothesis" label="using test hypothesis">
+ <option value="two.sided" label="Two-sided"/>
+ <option value="greater" label="First is greater"/>
+ <option value="less" label="Second is greater"/>
+ </radio>
+ <checkbox id="paired" label="Paired sample" value="1" value_unchecked="0" />
+ </column>
+ </row>
+ </tab>
+ <tab label="Options" id="tab_options">
+ <checkbox id="varequal" label="assume equal variances" value="1" value_unchecked="0"/>
+ <frame label="Confidence Interval" id="confint_frame">
+ <spinbox type="real" id="conflevel" label="confidence level" min="0" max="1" initial="0.95"/>
+ <checkbox id="confint" label="print confidence interval" value="1" checked="true"/>
+ </frame>
+ <stretch/>
+ </tab>
+ </tabbook>
+ </dialog>
+ <wizard label="Two Variable t-Test">
+ <page>
+ <text>
+ As a first step, chose if you want to compare two variable mean or one variable mean against
+ a constant value. Then select the variables/values you want to compare against each other.
+ And specify, which one you theorize to be greater. Select two-sided, if your theory does not tell you,
+ which variable is greater.</text>
+ <copy id="basic_settings_row"/>
+ </page>
+ <page>
+ <text>
+ Below are some advanced options. It's generally safe not to assume the variables have equal variances.
+ An appropriate correction will be applied then. Chosing "assume equal variances" may increase
+ test power, however.</text>
+ <copy id="varequal"/>
+ <text>
+ Sometimes it's helpful to get an estimate of the confidence interval of the difference in means.
+ Below you can specify whether one should be shown, and which confidence-level should be applied
+ (95% corresponds to a 5% level of significance).</text>
+ <copy id="confint_frame"/>
+ <stretch/>
+ </page>
+ </wizard>
+
+</document>
Deleted: trunk/rkward/rkward/plugins/analysis/t_test_two_vars.js
===================================================================
--- trunk/rkward/rkward/plugins/analysis/t_test_two_vars.js 2011-12-11 16:37:46 UTC (rev 4100)
+++ trunk/rkward/rkward/plugins/analysis/t_test_two_vars.js 2011-12-11 18:42:48 UTC (rev 4101)
@@ -1,55 +0,0 @@
-// globals
-var x;
-var y;
-var varequal;
-var paired;
-
-function preprocess () {
- x = getValue ("x");
- y = getValue ("y");
-
- echo ('names <- rk.get.description (' + x + ", " + y + ')\n');
-}
-
-function calculate () {
- varequal = getValue ("varequal");
- paired = getValue ("paired");
-
- var conflevel = getValue ("conflevel");
- var hypothesis = getValue ("hypothesis");
-
- var options = ", alternative=\"" + hypothesis + "\"";
- if (paired) options += ", paired=TRUE";
- if ((!paired) && varequal) options += ", var.equal=TRUE";
- if (conflevel != "0.95") options += ", conf.level=" + conflevel;
-
- echo ('result <- t.test (' + x + ", " + y + options + ')\n');
-}
-
-function printout () {
- echo ('rk.header (result$method, \n');
- echo (' parameters=list ("Comparing", paste (names[1], "against", names[2]),\n');
- echo (' "H1", rk.describe.alternative (result)');
- if (!paired) {
- echo (',\n');
- echo (' "Equal variances", "');
- if (!varequal) echo ("not");
- echo (' assumed"');
- }
- echo ('))\n');
- echo ('\n');
- echo ('rk.results (list (\n');
- echo (' \'Variable Name\'=names,\n');
- echo (' \'estimated mean\'=result$estimate,\n');
- echo (' \'degrees of freedom\'=result$parameter,\n');
- echo (' t=result$statistic,\n');
- echo (' p=result$p.value');
- if (getValue ("confint")) {
- echo (',\n');
- echo (' \'confidence interval percent\'=(100 * attr(result$conf.int, "conf.level")),\n');
- echo (' \'confidence interval of difference\'=result$conf.int ');
- }
- echo ('))\n');
-}
-
-
Deleted: trunk/rkward/rkward/plugins/analysis/t_test_two_vars.rkh
===================================================================
--- trunk/rkward/rkward/plugins/analysis/t_test_two_vars.rkh 2011-12-11 16:37:46 UTC (rev 4100)
+++ trunk/rkward/rkward/plugins/analysis/t_test_two_vars.rkh 2011-12-11 18:42:48 UTC (rev 4101)
@@ -1,28 +0,0 @@
-<!DOCTYPE rkhelp>
-<document>
- <summary>
-Two variable t-test (paired or independent samples).
- </summary>
-
- <usage>
-Chose two numeric vectors to compare against each other. Specify, whether the variables are paired or independent samples. For details, see below.
- </usage>
-
- <settings>
- <caption id="tab_variables"/>
- <setting id="x">A numeric vector for the first variable</setting>
- <setting id="y">A numeric vector for the second variable</setting>
- <setting id="hypothesis">Alternative hypothesis (H1) of the test.</setting>
- <setting id="paired">Whether the variables are paired (repeated measurements on the same subject) or independent samples. For a paired test, if the two vectors are not of equal length, there will be an error.</setting>
- <caption id="tab_options"/>
- <setting id="varequal">Whether to assume equal variances for the two samples. This option is implied for a paired test.</setting>
- <setting id="conflevel">Confidence level to use.</setting>
- <setting id="confint">Whether to print the confidence interval of the estimated mean.</setting>
- </settings>
- <related>
- <ul>
- <li><link href="rkward://component/F_test"/></li>
- <li><link href="rkward://rhelp/t.test"/></li>
- </ul>
- </related>
-</document>
Deleted: trunk/rkward/rkward/plugins/analysis/t_test_two_vars.xml
===================================================================
--- trunk/rkward/rkward/plugins/analysis/t_test_two_vars.xml 2011-12-11 16:37:46 UTC (rev 4100)
+++ trunk/rkward/rkward/plugins/analysis/t_test_two_vars.xml 2011-12-11 18:42:48 UTC (rev 4101)
@@ -1,52 +0,0 @@
-<!DOCTYPE rkplugin>
-<document>
- <code file="t_test_two_vars.js"/>
- <help file="t_test_two_vars.rkh"/>
-
- <logic>
- <convert id="notpaired" mode="equals" sources="paired.state" standard="0"/>
- <connect client="varequal.enabled" governor="notpaired"/>
- </logic>
-
- <dialog label="Two Variable t-Test">
- <tabbook>
- <tab label="Basic settings" id="tab_variables">
- <row id="basic_settings_row">
- <varselector id="vars"/>
- <column>
- <varslot type="numeric" id="x" source="vars" required="true" label="compare"/>
- <varslot type="numeric" id="y" source="vars" required="true" label="against"/>
- <radio id="hypothesis" label="using test hypothesis">
- <option value="two.sided" label="Two-sided"/>
- <option value="greater" label="First is greater"/>
- <option value="less" label="Second is greater"/>
- </radio>
- <checkbox id="paired" label="Paired sample" value="1" value_unchecked="0" />
- </column>
- </row>
- </tab>
- <tab label="Options" id="tab_options">
- <checkbox id="varequal" label="assume equal variances" value="1" value_unchecked="0"/>
- <frame label="Confidence Interval" id="confint_frame">
- <spinbox type="real" id="conflevel" label="confidence level" min="0" max="1" initial="0.95"/>
- <checkbox id="confint" label="print confidence interval" value="1" checked="true"/>
- </frame>
- <stretch/>
- </tab>
- </tabbook>
- </dialog>
- <wizard label="Two Variable t-Test">
- <page>
- <text>As a first step, select the two variables you want to compare against each other. And specify, which one you theorize to be greater. Select two-sided, if your theory does not tell you, which variable is greater.</text>
- <copy id="basic_settings_row"/>
- </page>
- <page>
- <text>Below are some advanced options. It's generally safe not to assume the variables have equal variances. An appropriate correction will be applied then. Chosing "assume equal variances" may increase test-strength, however.</text>
- <copy id="varequal"/>
- <text>Sometimes it's helpful to get an estimate of the confidence interval of the difference in means. Below you can specify whether one should be shown, and which confidence-level should be applied (95% corresponds to a 5% level of significance).</text>
- <copy id="confint_frame"/>
- <stretch/>
- </page>
- </wizard>
-
-</document>
Modified: trunk/rkward/rkward/plugins/analysis.pluginmap
===================================================================
--- trunk/rkward/rkward/plugins/analysis.pluginmap 2011-12-11 16:37:46 UTC (rev 4100)
+++ trunk/rkward/rkward/plugins/analysis.pluginmap 2011-12-11 18:42:48 UTC (rev 4101)
@@ -6,7 +6,7 @@
<component type="standard" id="corr_matrix" file="analysis/corr_matrix.xml" label="Correlation Matrix" />
<component type="standard" id="cor_graph" file="plots/cor_graph.xml" label="Correlation Matrix Plot" />
<component type="standard" id="descriptive" file="descriptive/descriptive_statistics.xml" label="Descriptive Statistics" />
- <component type="standard" id="t_test_two_vars" file="analysis/t_test_two_vars.xml" label="Two Variable t-Test" />
+ <component type="standard" id="t_test" file="analysis/t_test.xml" label="t-Test" />
<component type="standard" id="wilcoxon_test" file="analysis/wilcoxon/wilcoxon_test.xml" label="Wilcoxon Test" />
<component type="standard" id="wilcoxon_exact_test" file="analysis/wilcoxon/wilcoxon_exact_test.xml" label="Wilcoxon Exact Test" />
@@ -60,7 +60,7 @@
<entry component="descriptive" index="3"/>
<menu id="means" label="Means" index="4">
<menu id="ttests" label="t-Tests" index="0">
- <entry component="t_test_two_vars" />
+ <entry component="t_test" />
</menu>
</menu>
<menu id="moments" label="Moments" index="6">
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