~ubuntu-branches/debian/jessie/rkward/jessie

« back to all changes in this revision

Viewing changes to rkward/plugins/analysis/t_test_two_vars.js

  • Committer: Package Import Robot
  • Author(s): Thomas Friedrichsmeier
  • Date: 2012-10-24 15:30:00 UTC
  • mfrom: (1.1.19)
  • Revision ID: package-import@ubuntu.com-20121024153000-tbipm23vx4j8mzzr
Tags: 0.6.0-1
* new upstream release
* remove support for building on Ubuntu hardy
* more accurate copyright file
  closes: #689982
* bump standards version to 3.9.4 (no changes needed)
* Add Vcs-Browser and Vcs-Svn fields

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// globals
2
 
var x;
3
 
var y;
4
 
var varequal;
5
 
var paired;
6
 
 
7
 
function preprocess () {
8
 
        x = getValue ("x");
9
 
        y = getValue ("y");
10
 
 
11
 
        echo ('names <- rk.get.description (' + x + ", " + y + ')\n');
12
 
}
13
 
 
14
 
function calculate () {
15
 
        varequal = getValue ("varequal");
16
 
        paired = getValue ("paired");
17
 
 
18
 
        var conflevel = getValue ("conflevel");
19
 
        var hypothesis = getValue ("hypothesis");
20
 
 
21
 
        var options = ", alternative=\"" + hypothesis + "\"";
22
 
        if (paired) options += ", paired=TRUE";
23
 
        if ((!paired) && varequal) options += ", var.equal=TRUE";
24
 
        if (conflevel != "0.95") options += ", conf.level=" + conflevel;
25
 
 
26
 
        echo ('result <- t.test (' + x + ", " + y + options + ')\n');
27
 
}
28
 
 
29
 
function printout () {
30
 
        echo ('rk.header (result$method, \n');
31
 
        echo (' parameters=list ("Comparing", paste (names[1], "against", names[2]),\n');
32
 
        echo (' "H1", rk.describe.alternative (result)');
33
 
        if (!paired) {
34
 
                echo (',\n');
35
 
                echo (' "Equal variances", "');
36
 
                if (!varequal) echo ("not");
37
 
                echo (' assumed"');
38
 
        }
39
 
        echo ('))\n');
40
 
        echo ('\n');
41
 
        echo ('rk.results (list (\n');
42
 
        echo (' \'Variable Name\'=names,\n');
43
 
        echo (' \'estimated mean\'=result$estimate,\n');
44
 
        echo (' \'degrees of freedom\'=result$parameter,\n');
45
 
        echo (' t=result$statistic,\n');
46
 
        echo (' p=result$p.value');
47
 
        if (getValue ("confint")) {
48
 
                echo (',\n');
49
 
                echo (' \'confidence interval percent\'=(100 * attr(result$conf.int, "conf.level")),\n');
50
 
                echo (' \'confidence interval of difference\'=result$conf.int ');
51
 
        }
52
 
        echo ('))\n');
53
 
}
54
 
 
55