~l3on/ubuntu/precise/rkward/rebuild1

« back to all changes in this revision

Viewing changes to rkward/plugins/plots/irt/dichotomous/plot_rasch.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
 
 
34
  // in case there are generic plot options defined:
 
35
  $plot_options     = getRK_val("plotoptions.code.printout");
 
36
  $plot_ops_main    = getRK_val("plotoptions.main");
 
37
  $plot_ops_type    = getRK_val("plotoptions.pointtype");
 
38
  $plot_ops_xlab    = getRK_val("plotoptions.xlab");
 
39
  $plot_ops_ylab    = getRK_val("plotoptions.ylab");
 
40
 
 
41
  ///////////////////////////////////
 
42
  // check for selected options
 
43
  $options = array() ;
 
44
  if($plot_type == "items" && $plot_type_item == "ICC")
 
45
    $options[] = "type=\"ICC\"" ;
 
46
  if($plot_type == "items" && $plot_type_item == "IIC")
 
47
    $options[] = "type=\"IIC\"" ;
 
48
    // plot all items?
 
49
    if($plot_type == "items" && $inp_items) {
 
50
      // for user convenience, we replace "-", ";" and space, split all input into an array
 
51
      // and join it again, separated by commas:
 
52
      $inp_items = str_replace("-",":",$inp_items);
 
53
      $arr_items = split('[ ;]', $inp_items);
 
54
      $options[] = "items=c(".join(",", $arr_items).")"; }
 
55
 
 
56
  // for the test information curve, items must be set to "0":
 
57
  if($plot_type == "TIC")
 
58
    $options[] = "type=\"IIC\", items=0" ;
 
59
  // there is no option for standard error curves yet, so we need some extra magic
 
60
  // (see the "SEC" section in the plotting function below as well!)
 
61
  if($plot_type == "SEC")
 
62
    $options[] = "type=\"IIC\", items=0, plot=FALSE" ;
 
63
 
 
64
  // more advanced options
 
65
  // user defined zrange? we'll round it to two digits
 
66
  if($spin_from != "-3.8" || $spin_to != "3.8")
 
67
    $options[] = "zrange=c(".round($spin_from,2).",".round($spin_to,2).")" ;
 
68
  // annotate lines and show legend?
 
69
  if($annotation == "legend")
 
70
    $options[] = "legend=TRUE" ;
 
71
  if($annotation == "plain")
 
72
    $options[] = "annot=FALSE" ;
 
73
 
 
74
        if ($final) { ?>
 
75
rk.header("Rasch model plot")
 
76
 
 
77
rk.graph.on()
 
78
<?       }
 
79
        // only the following section will be generated for $final==false
 
80
 
 
81
        // first we'll check wheter standard error curves should be plotted,
 
82
        // because it takes two steps to draw them:
 
83
       if ($plot_type == "SEC") { ?>
 
84
# two steps are needed to plot standard error curves
 
85
# first some values are generated...
 
86
res <- try(plot(<? getRK("x");
 
87
              if($options) echo(", ".join(", ", $options));
 
88
          ?>))
 
89
 
 
90
# ... and then they're used to plot the curves:
 
91
try(plot(res[,"z"], 1/sqrt(res[,"info"]), lwd=2<?
 
92
              // we give come defaults, but they can be changed via the embedded plot options:
 
93
              if(!$plot_ops_type) echo(", type=\"l\"");
 
94
              if(!$plot_ops_xlab) echo(", xlab=\"Ability\"");
 
95
              if(!$plot_ops_ylab) echo(", ylab=\"Standard Error\"");
 
96
              if(!$plot_ops_main) echo(", main=\"Stadard Error of Measurement\"");
 
97
              if($plot_options) echo($plot_options);
 
98
  ?>))
 
99
<? }
 
100
        // and this will be plotted if anything else than stadard error curves are chosen:
 
101
        else { ?>
 
102
try(plot(<? getRK("x");
 
103
              if($options) echo(", ".join(", ", $options));
 
104
              if($plot_options) echo($plot_options);
 
105
          ?>))
 
106
<? }
 
107
        if ($final) { ?>
 
108
rk.graph.off()
 
109
<? }
 
110
}
 
111
?>
 
 
b'\\ No newline at end of file'