[rkward-cvs] SF.net SVN: rkward:[2383] branches/release_branch_0.4.9/rkward/plugins/ plots/irt

sjar at users.sourceforge.net sjar at users.sourceforge.net
Mon Nov 17 23:23:41 UTC 2008


Revision: 2383
          http://rkward.svn.sourceforge.net/rkward/?rev=2383&view=rev
Author:   sjar
Date:     2008-11-17 23:23:41 +0000 (Mon, 17 Nov 2008)

Log Message:
-----------
* experimental software
* plot plug-ins for irt by meik michalke
* still under development, thus in own folder for easier maintenance (folder hierarchy will be flatted later)

Added Paths:
-----------
    branches/release_branch_0.4.9/rkward/plugins/plots/irt/dichotomous/
    branches/release_branch_0.4.9/rkward/plugins/plots/irt/dichotomous/plot_ltm.php
    branches/release_branch_0.4.9/rkward/plugins/plots/irt/dichotomous/plot_ltm.xml
    branches/release_branch_0.4.9/rkward/plugins/plots/irt/dichotomous/plot_rasch.php
    branches/release_branch_0.4.9/rkward/plugins/plots/irt/dichotomous/plot_rasch.xml
    branches/release_branch_0.4.9/rkward/plugins/plots/irt/dichotomous/plot_tpm.php
    branches/release_branch_0.4.9/rkward/plugins/plots/irt/dichotomous/plot_tpm.xml

Added: branches/release_branch_0.4.9/rkward/plugins/plots/irt/dichotomous/plot_ltm.php
===================================================================
--- branches/release_branch_0.4.9/rkward/plugins/plots/irt/dichotomous/plot_ltm.php	                        (rev 0)
+++ branches/release_branch_0.4.9/rkward/plugins/plots/irt/dichotomous/plot_ltm.php	2008-11-17 23:23:41 UTC (rev 2383)
@@ -0,0 +1,114 @@
+<?
+function preprocess () {
+  // we'll need the ltm package, so in case it's not loaded...
+?>
+  require(ltm)
+<?}
+
+function calculate () {
+}
+
+function printout () {
+        doPrintout (true);
+}
+
+function preview () {
+        preprocess ();
+        calculate ();
+        doPrintout (false);
+}
+
+function doPrintout ($final) {
+        // this function takes care of generating the code for the printout() section. If $final is set to true,
+        // it generates the full code, including headers. If $final is set to false, only the essentials will
+        // be generated.
+
+  // let's read all values into php variables for the sake of readable code
+  $plot_type        = getRK_val("plot_type");
+  $plot_type_item   = getRK_val("plot_type_item");
+  $inp_items        = getRK_val("inp_items");
+  $spin_from        = getRK_val("spin_from");
+  $spin_to          = getRK_val("spin_to");
+  $annotation       = getRK_val("annotation");
+
+  // in case there are generic plot options defined:
+  $plot_options     = getRK_val("plotoptions.code.printout");
+  $plot_ops_main    = getRK_val("plotoptions.main");
+  $plot_ops_type    = getRK_val("plotoptions.pointtype");
+  $plot_ops_xlab    = getRK_val("plotoptions.xlab");
+  $plot_ops_ylab    = getRK_val("plotoptions.ylab");
+
+  ///////////////////////////////////
+  // check for selected options
+  $options = array() ;
+  if($plot_type == "items" && $plot_type_item == "ICC")
+    $options[] = "type=\"ICC\"" ;
+  if($plot_type == "items" && $plot_type_item == "IIC")
+    $options[] = "type=\"IIC\"" ;
+    // plot all items?
+    if($plot_type == "items" && $inp_items) {
+      // for user convenience, we replace "-", ";" and space, split all input into an array
+      // and join it again, separated by commas:
+      $inp_items = str_replace("-",":",$inp_items);
+      $arr_items = split('[ ;]', $inp_items);
+      $options[] = "items=c(".join(",", $arr_items).")"; }
+
+  // for the test information curve, items must be set to "0":
+  if($plot_type == "TIC")
+    $options[] = "type=\"IIC\", items=0" ;
+  // there is no option for standard error curves yet, so we need some extra magic
+  // (see the "SEC" section in the plotting function below as well!)
+  if($plot_type == "SEC")
+    $options[] = "type=\"IIC\", items=0, plot=FALSE" ;
+  // the scatterplot is ltp specific:
+  if($plot_type_item == "loadings")
+    $options[] = "type=\"loadings\"" ;
+
+  // more advanced options
+  // user defined zrange? we'll round it to two digits
+  if($spin_from != "-3.8" || $spin_to != "3.8")
+    $options[] = "zrange=c(".round($spin_from,2).",".round($spin_to,2).")" ;
+  // annotate lines and show legend?
+  if($annotation == "legend")
+    $options[] = "legend=TRUE" ;
+  if($annotation == "plain")
+    $options[] = "annot=FALSE" ;
+
+        if ($final) { ?>
+rk.header("Two parameter logistic model plot")
+
+rk.graph.on()
+<?       }
+        // only the following section will be generated for $final==false
+
+        // first we'll check wheter standard error curves should be plotted,
+        // because it takes two steps to draw them:
+       if ($plot_type == "SEC") { ?>
+# two steps are needed to plot standard error curves
+# first some values are generated...
+res <- try(plot(<? getRK("x");
+              if($options) echo(", ".join(", ", $options));
+          ?>))
+
+# ... and then they're used to plot the curves:
+try(plot(res[,"z"], 1/sqrt(res[,"info"]), lwd=2<?
+              // we give come defaults, but they can be changed via the embedded plot options:
+              if(!$plot_ops_type) echo(", type=\"l\"");
+              if(!$plot_ops_xlab) echo(", xlab=\"Ability\"");
+              if(!$plot_ops_ylab) echo(", ylab=\"Standard Error\"");
+              if(!$plot_ops_main) echo(", main=\"Stadard Error of Measurement\"");
+              if($plot_options) echo($plot_options);
+  ?>))
+<? }
+        // and this will be plotted if anything else than stadard error curves are chosen:
+        else { ?>
+try(plot(<? getRK("x");
+              if($options) echo(", ".join(", ", $options));
+              if($plot_options) echo($plot_options);
+          ?>))
+<? }
+        if ($final) { ?>
+rk.graph.off()
+<? }
+}
+?>
\ No newline at end of file

Added: branches/release_branch_0.4.9/rkward/plugins/plots/irt/dichotomous/plot_ltm.xml
===================================================================
--- branches/release_branch_0.4.9/rkward/plugins/plots/irt/dichotomous/plot_ltm.xml	                        (rev 0)
+++ branches/release_branch_0.4.9/rkward/plugins/plots/irt/dichotomous/plot_ltm.xml	2008-11-17 23:23:41 UTC (rev 2383)
@@ -0,0 +1,63 @@
+<!DOCTYPE rkplugin>
+<document>
+  <code file="plot_ltm.php" />
+  <!-- <help file="plot_ltm.rkh" /> -->
+
+  <logic>
+    <convert id="logic_items" mode="equals" sources="plot_type.string" standard="items" />
+
+    <connect client="plot_type_item.enabled" governor="logic_items" />
+    <connect client="frame_items.enabled" governor="logic_items" />
+  </logic>
+
+  <dialog label="Plotting fitted 2PL model">
+    <tabbook>
+      <tab id="tab_variables" label="Model">
+        <row id="row_vars">
+          <varselector id="vars" />
+          <column>
+            <varslot type="numeric" id="x" classes="ltm" source="vars" required="true" label="Choose fitted model to plot:"/>
+            <text>Only objects of class ltm are valid!</text>
+            <stretch />
+            <preview id="preview"/>
+          </column>
+        </row>
+      </tab>
+      <tab id="tab_type" label="Plot type">
+        <column id="col_type">
+          <radio id="plot_type" label="Type of plot">
+            <option label="Plot item(s)" value="items" checked="true" />
+            <option label="Plot test information" value="TIC" />
+            <option label="Plot standard error" value="SEC" />
+            <option label="Scatterplot of standardized loadings (2-factor model)" value="loadings" />
+          </radio>
+          <radio id="plot_type_item" label="Type of item plot">
+            <option label="Item characteristic curve" value="ICC" checked="true" />
+            <option label="Item information curve" value="IIC" />
+          </radio>
+          <frame id="frame_items" label="Optional item selection">
+            <input id="inp_items" label="List of items (plot all if empty)" />
+          </frame>
+        </column>
+      </tab>
+      <tab id="tab_options" label="Options">
+        <column id="col_options">
+          <frame label="Range of latent variable values">
+          <row>
+          <spinbox id="spin_from" label="From:" type="real" initial="-3.8" size="small" />
+          <spinbox id="spin_to" label="To:" type="real" initial="3.8" size="small" />
+          </row>
+          </frame>
+          <stretch />
+          <radio id="annotation" label="Annotation">
+            <option label="Annotate plotted lines" value="annot" checked="true" />
+            <option label="Show legend" value="legend" />
+            <option label="Plain lines, no annotation" value="plain" />
+          </radio>
+          <stretch />
+            <embed id="plotoptions" component="rkward::plot_options" as_button="true" label="Generic plot options" />
+        </column>
+      </tab>
+    </tabbook>
+  </dialog>
+</document>

Added: branches/release_branch_0.4.9/rkward/plugins/plots/irt/dichotomous/plot_rasch.php
===================================================================
--- branches/release_branch_0.4.9/rkward/plugins/plots/irt/dichotomous/plot_rasch.php	                        (rev 0)
+++ branches/release_branch_0.4.9/rkward/plugins/plots/irt/dichotomous/plot_rasch.php	2008-11-17 23:23:41 UTC (rev 2383)
@@ -0,0 +1,111 @@
+<?
+function preprocess () {
+  // we'll need the ltm package, so in case it's not loaded...
+?>
+  require(ltm)
+<?}
+
+function calculate () {
+}
+
+function printout () {
+        doPrintout (true);
+}
+
+function preview () {
+        preprocess ();
+        calculate ();
+        doPrintout (false);
+}
+
+function doPrintout ($final) {
+        // this function takes care of generating the code for the printout() section. If $final is set to true,
+        // it generates the full code, including headers. If $final is set to false, only the essentials will
+        // be generated.
+
+  // let's read all values into php variables for the sake of readable code
+  $plot_type        = getRK_val("plot_type");
+  $plot_type_item   = getRK_val("plot_type_item");
+  $inp_items        = getRK_val("inp_items");
+  $spin_from        = getRK_val("spin_from");
+  $spin_to          = getRK_val("spin_to");
+  $annotation       = getRK_val("annotation");
+
+  // in case there are generic plot options defined:
+  $plot_options     = getRK_val("plotoptions.code.printout");
+  $plot_ops_main    = getRK_val("plotoptions.main");
+  $plot_ops_type    = getRK_val("plotoptions.pointtype");
+  $plot_ops_xlab    = getRK_val("plotoptions.xlab");
+  $plot_ops_ylab    = getRK_val("plotoptions.ylab");
+
+  ///////////////////////////////////
+  // check for selected options
+  $options = array() ;
+  if($plot_type == "items" && $plot_type_item == "ICC")
+    $options[] = "type=\"ICC\"" ;
+  if($plot_type == "items" && $plot_type_item == "IIC")
+    $options[] = "type=\"IIC\"" ;
+    // plot all items?
+    if($plot_type == "items" && $inp_items) {
+      // for user convenience, we replace "-", ";" and space, split all input into an array
+      // and join it again, separated by commas:
+      $inp_items = str_replace("-",":",$inp_items);
+      $arr_items = split('[ ;]', $inp_items);
+      $options[] = "items=c(".join(",", $arr_items).")"; }
+
+  // for the test information curve, items must be set to "0":
+  if($plot_type == "TIC")
+    $options[] = "type=\"IIC\", items=0" ;
+  // there is no option for standard error curves yet, so we need some extra magic
+  // (see the "SEC" section in the plotting function below as well!)
+  if($plot_type == "SEC")
+    $options[] = "type=\"IIC\", items=0, plot=FALSE" ;
+
+  // more advanced options
+  // user defined zrange? we'll round it to two digits
+  if($spin_from != "-3.8" || $spin_to != "3.8")
+    $options[] = "zrange=c(".round($spin_from,2).",".round($spin_to,2).")" ;
+  // annotate lines and show legend?
+  if($annotation == "legend")
+    $options[] = "legend=TRUE" ;
+  if($annotation == "plain")
+    $options[] = "annot=FALSE" ;
+
+        if ($final) { ?>
+rk.header("Rasch model plot")
+
+rk.graph.on()
+<?       }
+        // only the following section will be generated for $final==false
+
+        // first we'll check wheter standard error curves should be plotted,
+        // because it takes two steps to draw them:
+       if ($plot_type == "SEC") { ?>
+# two steps are needed to plot standard error curves
+# first some values are generated...
+res <- try(plot(<? getRK("x");
+              if($options) echo(", ".join(", ", $options));
+          ?>))
+
+# ... and then they're used to plot the curves:
+try(plot(res[,"z"], 1/sqrt(res[,"info"]), lwd=2<?
+              // we give come defaults, but they can be changed via the embedded plot options:
+              if(!$plot_ops_type) echo(", type=\"l\"");
+              if(!$plot_ops_xlab) echo(", xlab=\"Ability\"");
+              if(!$plot_ops_ylab) echo(", ylab=\"Standard Error\"");
+              if(!$plot_ops_main) echo(", main=\"Stadard Error of Measurement\"");
+              if($plot_options) echo($plot_options);
+  ?>))
+<? }
+        // and this will be plotted if anything else than stadard error curves are chosen:
+        else { ?>
+try(plot(<? getRK("x");
+              if($options) echo(", ".join(", ", $options));
+              if($plot_options) echo($plot_options);
+          ?>))
+<? }
+        if ($final) { ?>
+rk.graph.off()
+<? }
+}
+?>
\ No newline at end of file

Added: branches/release_branch_0.4.9/rkward/plugins/plots/irt/dichotomous/plot_rasch.xml
===================================================================
--- branches/release_branch_0.4.9/rkward/plugins/plots/irt/dichotomous/plot_rasch.xml	                        (rev 0)
+++ branches/release_branch_0.4.9/rkward/plugins/plots/irt/dichotomous/plot_rasch.xml	2008-11-17 23:23:41 UTC (rev 2383)
@@ -0,0 +1,62 @@
+<!DOCTYPE rkplugin>
+<document>
+  <code file="plot_rasch.php" />
+  <!-- <help file="plot_rasch.rkh" /> -->
+
+  <logic>
+    <convert id="logic_items" mode="equals" sources="plot_type.string" standard="items" />
+
+    <connect client="plot_type_item.enabled" governor="logic_items" />
+    <connect client="frame_items.enabled" governor="logic_items" />
+  </logic>
+
+  <dialog label="Plotting fitted Rasch model">
+    <tabbook>
+      <tab id="tab_variables" label="Model">
+        <row id="row_vars">
+          <varselector id="vars" />
+          <column>
+            <varslot type="numeric" id="x" classes="rasch" source="vars" required="true" label="Choose fitted model to plot:"/>
+            <text>Only objects of class rasch are valid!</text>
+            <stretch />
+            <preview id="preview"/>
+          </column>
+        </row>
+      </tab>
+      <tab id="tab_type" label="Plot type">
+        <column id="col_type">
+          <radio id="plot_type" label="Type of plot">
+            <option label="Plot item(s)" value="items" checked="true" />
+            <option label="Plot test information" value="TIC" />
+            <option label="Plot standard error" value="SEC" />
+          </radio>
+          <radio id="plot_type_item" label="Type of item plot">
+            <option label="Item characteristic curve" value="ICC" checked="true" />
+            <option label="Item information curve" value="IIC" />
+          </radio>
+          <frame id="frame_items" label="Optional item selection">
+            <input id="inp_items" label="List of items (plot all if empty)" />
+          </frame>
+        </column>
+      </tab>
+      <tab id="tab_options" label="Options">
+        <column id="col_options">
+          <frame label="Range of latent variable values">
+          <row>
+          <spinbox id="spin_from" label="From:" type="real" initial="-3.8" size="small" />
+          <spinbox id="spin_to" label="To:" type="real" initial="3.8" size="small" />
+          </row>
+          </frame>
+          <stretch />
+          <radio id="annotation" label="Annotation">
+            <option label="Annotate plotted lines" value="annot" checked="true" />
+            <option label="Show legend" value="legend" />
+            <option label="Plain lines, no annotation" value="plain" />
+          </radio>
+          <stretch />
+            <embed id="plotoptions" component="rkward::plot_options" as_button="true" label="Generic plot options" />
+        </column>
+      </tab>
+    </tabbook>
+  </dialog>
+</document>

Added: branches/release_branch_0.4.9/rkward/plugins/plots/irt/dichotomous/plot_tpm.php
===================================================================
--- branches/release_branch_0.4.9/rkward/plugins/plots/irt/dichotomous/plot_tpm.php	                        (rev 0)
+++ branches/release_branch_0.4.9/rkward/plugins/plots/irt/dichotomous/plot_tpm.php	2008-11-17 23:23:41 UTC (rev 2383)
@@ -0,0 +1,111 @@
+<?
+function preprocess () {
+  // we'll need the ltm package, so in case it's not loaded...
+?>
+  require(ltm)
+<?}
+
+function calculate () {
+}
+
+function printout () {
+        doPrintout (true);
+}
+
+function preview () {
+        preprocess ();
+        calculate ();
+        doPrintout (false);
+}
+
+function doPrintout ($final) {
+        // this function takes care of generating the code for the printout() section. If $final is set to true,
+        // it generates the full code, including headers. If $final is set to false, only the essentials will
+        // be generated.
+
+  // let's read all values into php variables for the sake of readable code
+  $plot_type        = getRK_val("plot_type");
+  $plot_type_item   = getRK_val("plot_type_item");
+  $inp_items        = getRK_val("inp_items");
+  $spin_from        = getRK_val("spin_from");
+  $spin_to          = getRK_val("spin_to");
+  $annotation       = getRK_val("annotation");
+
+  // in case there are generic plot options defined:
+  $plot_options     = getRK_val("plotoptions.code.printout");
+  $plot_ops_main    = getRK_val("plotoptions.main");
+  $plot_ops_type    = getRK_val("plotoptions.pointtype");
+  $plot_ops_xlab    = getRK_val("plotoptions.xlab");
+  $plot_ops_ylab    = getRK_val("plotoptions.ylab");
+
+  ///////////////////////////////////
+  // check for selected options
+  $options = array() ;
+  if($plot_type == "items" && $plot_type_item == "ICC")
+    $options[] = "type=\"ICC\"" ;
+  if($plot_type == "items" && $plot_type_item == "IIC")
+    $options[] = "type=\"IIC\"" ;
+    // plot all items?
+    if($plot_type == "items" && $inp_items) {
+      // for user convenience, we replace "-", ";" and space, split all input into an array
+      // and join it again, separated by commas:
+      $inp_items = str_replace("-",":",$inp_items);
+      $arr_items = split('[ ;]', $inp_items);
+      $options[] = "items=c(".join(",", $arr_items).")"; }
+
+  // for the test information curve, items must be set to "0":
+  if($plot_type == "TIC")
+    $options[] = "type=\"IIC\", items=0" ;
+  // there is no option for standard error curves yet, so we need some extra magic
+  // (see the "SEC" section in the plotting function below as well!)
+  if($plot_type == "SEC")
+    $options[] = "type=\"IIC\", items=0, plot=FALSE" ;
+
+  // more advanced options
+  // user defined zrange? we'll round it to two digits
+  if($spin_from != "-3.8" || $spin_to != "3.8")
+    $options[] = "zrange=c(".round($spin_from,2).",".round($spin_to,2).")" ;
+  // annotate lines and show legend?
+  if($annotation == "legend")
+    $options[] = "legend=TRUE" ;
+  if($annotation == "plain")
+    $options[] = "annot=FALSE" ;
+
+        if ($final) { ?>
+rk.header("Birnbaum three parameter model plot")
+
+rk.graph.on()
+<?       }
+        // only the following section will be generated for $final==false
+
+        // first we'll check wheter standard error curves should be plotted,
+        // because it takes two steps to draw them:
+       if ($plot_type == "SEC") { ?>
+# two steps are needed to plot standard error curves
+# first some values are generated...
+res <- try(plot(<? getRK("x");
+              if($options) echo(", ".join(", ", $options));
+          ?>))
+
+# ... and then they're used to plot the curves:
+try(plot(res[,"z"], 1/sqrt(res[,"info"]), lwd=2<?
+              // we give come defaults, but they can be changed via the embedded plot options:
+              if(!$plot_ops_type) echo(", type=\"l\"");
+              if(!$plot_ops_xlab) echo(", xlab=\"Ability\"");
+              if(!$plot_ops_ylab) echo(", ylab=\"Standard Error\"");
+              if(!$plot_ops_main) echo(", main=\"Stadard Error of Measurement\"");
+              if($plot_options) echo($plot_options);
+  ?>))
+<? }
+        // and this will be plotted if anything else than stadard error curves are chosen:
+        else { ?>
+try(plot(<? getRK("x");
+              if($options) echo(", ".join(", ", $options));
+              if($plot_options) echo($plot_options);
+          ?>))
+<? }
+        if ($final) { ?>
+rk.graph.off()
+<? }
+}
+?>
\ No newline at end of file

Added: branches/release_branch_0.4.9/rkward/plugins/plots/irt/dichotomous/plot_tpm.xml
===================================================================
--- branches/release_branch_0.4.9/rkward/plugins/plots/irt/dichotomous/plot_tpm.xml	                        (rev 0)
+++ branches/release_branch_0.4.9/rkward/plugins/plots/irt/dichotomous/plot_tpm.xml	2008-11-17 23:23:41 UTC (rev 2383)
@@ -0,0 +1,62 @@
+<!DOCTYPE rkplugin>
+<document>
+  <code file="plot_tpm.php" />
+  <!-- <help file="plot_tpm.rkh" /> -->
+
+  <logic>
+    <convert id="logic_items" mode="equals" sources="plot_type.string" standard="items" />
+
+    <connect client="plot_type_item.enabled" governor="logic_items" />
+    <connect client="frame_items.enabled" governor="logic_items" />
+  </logic>
+
+  <dialog label="Plotting fitted 3PL model">
+    <tabbook>
+      <tab id="tab_variables" label="Model">
+        <row id="row_vars">
+          <varselector id="vars" />
+          <column>
+            <varslot type="numeric" id="x" classes="tpm" source="vars" required="true" label="Choose fitted model to plot:"/>
+            <text>Only objects of class tpm are valid!</text>
+            <stretch />
+            <preview id="preview"/>
+          </column>
+        </row>
+      </tab>
+      <tab id="tab_type" label="Plot type">
+        <column id="col_type">
+          <radio id="plot_type" label="Type of plot">
+            <option label="Plot item(s)" value="items" checked="true" />
+            <option label="Plot test information" value="TIC" />
+            <option label="Plot standard error" value="SEC" />
+          </radio>
+          <radio id="plot_type_item" label="Type of item plot">
+            <option label="Item characteristic curve" value="ICC" checked="true" />
+            <option label="Item information curve" value="IIC" />
+          </radio>
+          <frame id="frame_items" label="Optional item selection">
+            <input id="inp_items" label="List of items (plot all if empty)" />
+          </frame>
+        </column>
+      </tab>
+      <tab id="tab_options" label="Options">
+        <column id="col_options">
+          <frame label="Range of latent variable values">
+          <row>
+          <spinbox id="spin_from" label="From:" type="real" initial="-3.8" size="small" />
+          <spinbox id="spin_to" label="To:" type="real" initial="3.8" size="small" />
+          </row>
+          </frame>
+          <stretch />
+          <radio id="annotation" label="Annotation">
+            <option label="Annotate plotted lines" value="annot" checked="true" />
+            <option label="Show legend" value="legend" />
+            <option label="Plain lines, no annotation" value="plain" />
+          </radio>
+          <stretch />
+            <embed id="plotoptions" component="rkward::plot_options" as_button="true" label="Generic plot options" />
+        </column>
+      </tab>
+    </tabbook>
+  </dialog>
+</document>


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