~l3on/ubuntu/precise/rkward/rebuild1

« back to all changes in this revision

Viewing changes to rkward/plugins/plots/irt/polytomous/plot_grm.php

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2009-05-11 21:58:23 UTC
  • mfrom: (1.1.11 upstream)
  • Revision ID: james.westby@ubuntu.com-20090511215823-m2f3gehcvapwrzgp
Tags: 0.5.0d-0ubuntu1
* New upstream release (LP: #375213)
* Bump Standards-Version to 3.8.1
* Drop cmake, libphon-dev from build-deps
* Update maintainer field

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?
 
2
function preprocess () {
 
3
  // we'll need the ltm package, so in case it's not loaded...
 
4
?>
 
5
  require(ltm)
 
6
<?}
 
7
 
 
8
function calculate () {
 
9
}
 
10
 
 
11
function printout () {
 
12
        doPrintout (true);
 
13
}
 
14
 
 
15
function preview () {
 
16
        preprocess ();
 
17
        calculate ();
 
18
        doPrintout (false);
 
19
}
 
20
 
 
21
function doPrintout ($final) {
 
22
        // this function takes care of generating the code for the printout() section. If $final is set to true,
 
23
        // it generates the full code, including headers. If $final is set to false, only the essentials will
 
24
        // be generated.
 
25
 
 
26
  // let's read all values into php variables for the sake of readable code
 
27
  $plot_type        = getRK_val("plot_type");
 
28
  $plot_type_item   = getRK_val("plot_type_item");
 
29
  $inp_items        = getRK_val("inp_items");
 
30
  $spin_from        = getRK_val("spin_from");
 
31
  $spin_to          = getRK_val("spin_to");
 
32
  $annotation       = getRK_val("annotation");
 
33
  $spin_categ       = getRK_val("spin_categ");
 
34
 
 
35
  // in case there are generic plot options defined:
 
36
  $plot_options     = getRK_val("plotoptions.code.printout");
 
37
  $plot_ops_main    = getRK_val("plotoptions.main");
 
38
  $plot_ops_type    = getRK_val("plotoptions.pointtype");
 
39
  $plot_ops_xlab    = getRK_val("plotoptions.xlab");
 
40
  $plot_ops_ylab    = getRK_val("plotoptions.ylab");
 
41
 
 
42
  ///////////////////////////////////
 
43
  // check for selected options
 
44
  $options = array() ;
 
45
  if($plot_type == "items" && $plot_type_item == "ICC")
 
46
    $options[] = "type=\"ICC\"" ;
 
47
  if($plot_type == "items" && $plot_type_item == "IIC")
 
48
    $options[] = "type=\"IIC\"" ;
 
49
  if($plot_type == "items" && $plot_type_item == "OCCu")
 
50
    $options[] = "type=\"OCCu\"" ;
 
51
  if($plot_type == "items" && $plot_type_item == "OCCl")
 
52
    $options[] = "type=\"OCCl\"" ;
 
53
    // plot all items?
 
54
    if($plot_type == "items" && $inp_items) {
 
55
      // for user convenience, we replace "-", ";" and space, split all input into an array
 
56
      // and join it again, separated by commas:
 
57
      $inp_items = str_replace("-",":",$inp_items);
 
58
      $arr_items = split('[ ;]', $inp_items);
 
59
      $options[] = "items=c(".join(",", $arr_items).")"; }
 
60
    // plot all categories?
 
61
    if($plot_type == "items" && $spin_categ != "0")
 
62
      $options[] = "category=$spin_categ" ;
 
63
 
 
64
  // for the test information curve, items must be set to "0":
 
65
  if($plot_type == "TIC")
 
66
    $options[] = "type=\"IIC\", items=0" ;
 
67
  // there is no option for standard error curves yet, so we need some extra magic
 
68
  // (see the "SEC" section in the plotting function below as well!)
 
69
  if($plot_type == "SEC")
 
70
    $options[] = "type=\"IIC\", items=0, plot=FALSE" ;
 
71
 
 
72
  // more advanced options
 
73
  // user defined zrange? we'll round it to two digits
 
74
  if($spin_from != "-3.8" || $spin_to != "3.8")
 
75
    $options[] = "zrange=c(".round($spin_from,2).",".round($spin_to,2).")" ;
 
76
  // annotate lines and show legend?
 
77
  if($annotation == "legend")
 
78
    $options[] = "legend=TRUE" ;
 
79
  if($annotation == "plain")
 
80
    $options[] = "annot=FALSE" ;
 
81
 
 
82
        if ($final) { ?>
 
83
rk.header("Graded response model plot")
 
84
 
 
85
rk.graph.on()
 
86
<?       }
 
87
        // only the following section will be generated for $final==false
 
88
 
 
89
        // first we'll check wheter standard error curves should be plotted,
 
90
        // because it takes two steps to draw them:
 
91
       if ($plot_type == "SEC") { ?>
 
92
# two steps are needed to plot standard error curves
 
93
# first some values are generated...
 
94
res <- try(plot(<? getRK("x");
 
95
              if($options) echo(", ".join(", ", $options));
 
96
          ?>))
 
97
 
 
98
# ... and then they're used to plot the curves:
 
99
try(plot(res[,"z"], 1/sqrt(res[,"test.info"]), lwd=2<?
 
100
              // we give come defaults, but they can be changed via the embedded plot options:
 
101
              if(!$plot_ops_type) echo(", type=\"l\"");
 
102
              if(!$plot_ops_xlab) echo(", xlab=\"Ability\"");
 
103
              if(!$plot_ops_ylab) echo(", ylab=\"Standard Error\"");
 
104
              if(!$plot_ops_main) echo(", main=\"Stadard Error of Measurement\"");
 
105
              if($plot_options) echo($plot_options);
 
106
  ?>))
 
107
<? }
 
108
        // and this will be plotted if anything else than stadard error curves are chosen:
 
109
        else { ?>
 
110
try(plot(<? getRK("x");
 
111
              if($options) echo(", ".join(", ", $options));
 
112
              if($plot_options) echo($plot_options);
 
113
          ?>))
 
114
<? }
 
115
        if ($final) { ?>
 
116
rk.graph.off()
 
117
<? }
 
118
}
 
119
?>
 
 
b'\\ No newline at end of file'