[rkward-cvs] SF.net SVN: rkward:[2381] branches/release_branch_0.4.9/rkward/plugins/ plots/irt
sjar at users.sourceforge.net
sjar at users.sourceforge.net
Mon Nov 17 23:21:58 UTC 2008
Revision: 2381
http://rkward.svn.sourceforge.net/rkward/?rev=2381&view=rev
Author: sjar
Date: 2008-11-17 23:21:58 +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/polytomous/
branches/release_branch_0.4.9/rkward/plugins/plots/irt/polytomous/plot_grm.php
branches/release_branch_0.4.9/rkward/plugins/plots/irt/polytomous/plot_grm.xml
branches/release_branch_0.4.9/rkward/plugins/plots/irt/polytomous/plot_pcm.php
branches/release_branch_0.4.9/rkward/plugins/plots/irt/polytomous/plot_pcm.xml
branches/release_branch_0.4.9/rkward/plugins/plots/irt/polytomous/plot_rsm.php
branches/release_branch_0.4.9/rkward/plugins/plots/irt/polytomous/plot_rsm.xml
Added: branches/release_branch_0.4.9/rkward/plugins/plots/irt/polytomous/plot_grm.php
===================================================================
--- branches/release_branch_0.4.9/rkward/plugins/plots/irt/polytomous/plot_grm.php (rev 0)
+++ branches/release_branch_0.4.9/rkward/plugins/plots/irt/polytomous/plot_grm.php 2008-11-17 23:21:58 UTC (rev 2381)
@@ -0,0 +1,119 @@
+<?
+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");
+ $spin_categ = getRK_val("spin_categ");
+
+ // 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\"" ;
+ if($plot_type == "items" && $plot_type_item == "OCCu")
+ $options[] = "type=\"OCCu\"" ;
+ if($plot_type == "items" && $plot_type_item == "OCCl")
+ $options[] = "type=\"OCCl\"" ;
+ // 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).")"; }
+ // plot all categories?
+ if($plot_type == "items" && $spin_categ != "0")
+ $options[] = "category=$spin_categ" ;
+
+ // 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("Graded response 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[,"test.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/polytomous/plot_grm.xml
===================================================================
--- branches/release_branch_0.4.9/rkward/plugins/plots/irt/polytomous/plot_grm.xml (rev 0)
+++ branches/release_branch_0.4.9/rkward/plugins/plots/irt/polytomous/plot_grm.xml 2008-11-17 23:21:58 UTC (rev 2381)
@@ -0,0 +1,65 @@
+<!DOCTYPE rkplugin>
+<document>
+ <code file="plot_grm.php" />
+ <!-- <help file="plot_grm.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 graded response model">
+ <tabbook>
+ <tab id="tab_variables" label="Model">
+ <row id="row_vars">
+ <varselector id="vars" />
+ <column>
+ <varslot type="numeric" id="x" classes="grm" source="vars" required="true" label="Choose fitted model to plot:"/>
+ <text>Only objects of class grm 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" />
+ <option label="Item operation characteristic curve" value="OCCu" />
+ <option label="Item operation characteristic curve (inverse)" value="OCCl" />
+ </radio>
+ <frame id="frame_items" label="Optional item selection">
+ <input id="inp_items" label="List of items (plot all if empty)" />
+ <spinbox id="spin_categ" label="Category (plot all if set to 0)" type="integer" initial="0" min="0" size="small" />
+ </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/polytomous/plot_pcm.php
===================================================================
--- branches/release_branch_0.4.9/rkward/plugins/plots/irt/polytomous/plot_pcm.php (rev 0)
+++ branches/release_branch_0.4.9/rkward/plugins/plots/irt/polytomous/plot_pcm.php 2008-11-17 23:21:58 UTC (rev 2381)
@@ -0,0 +1,85 @@
+<?
+function preprocess () {
+ // we'll need the eRm package, so in case it's not loaded...
+?>
+ require(eRm)
+<?}
+
+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
+ $inp_items = getRK_val("inp_items");
+ $spin_abilfrom = getRK_val("spin_abilfrom");
+ $spin_abilto = getRK_val("spin_abilto");
+ $spin_probfrom = getRK_val("spin_probfrom");
+ $spin_probto = getRK_val("spin_probto");
+ $annotation = getRK_val("annotation");
+ $chk_ask = getRK_val("chk_ask");
+ $chk_mplot = getRK_val("chk_mplot");
+
+ // 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() ;
+ // plot all items?
+ if($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[] = "item.subset=c(".join(",", $arr_items).")"; }
+ if($chk_mplot == "mplot")
+ $options[] = "mplot=TRUE" ;
+ if($chk_ask != "ask")
+ $options[] = "ask=FALSE" ;
+
+ // more advanced options
+ // user defined ranges? we'll round it to two digits
+ if(($spin_abilfrom != "-4" || $spin_abilto != "4") && $spin_abilfrom < $spin_abilto)
+ $options[] = "xlim=c(".round($spin_abilfrom,2).",".round($spin_abilto,2).")" ;
+ if(($spin_probfrom != "0" || $spin_probto != "1") && $spin_probfrom < $spin_probto)
+ $options[] = "ylim=c(".round($spin_probfrom,2).",".round($spin_probto,2).")" ;
+ // annotate lines and show legend?
+ if($annotation == "plain")
+ $options[] = "legpos=FALSE" ;
+
+ if ($final) { ?>
+rk.header("Partial credit model plot")
+
+rk.graph.on()
+<? }
+ // only the following section will be generated for $final==false
+
+ ?>
+try(plotICC(<? 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/polytomous/plot_pcm.xml
===================================================================
--- branches/release_branch_0.4.9/rkward/plugins/plots/irt/polytomous/plot_pcm.xml (rev 0)
+++ branches/release_branch_0.4.9/rkward/plugins/plots/irt/polytomous/plot_pcm.xml 2008-11-17 23:21:58 UTC (rev 2381)
@@ -0,0 +1,48 @@
+<!DOCTYPE rkplugin>
+<document>
+ <code file="plot_pcm.php" />
+ <!-- <help file="plot_pcm.rkh" /> -->
+
+ <dialog label="Plotting fitted partial credit model">
+ <tabbook>
+ <tab id="tab_variables" label="Model">
+ <row id="row_vars">
+ <varselector id="vars" />
+ <column>
+ <varslot type="numeric" id="x" classes="Rm" source="vars" required="true" label="Choose fitted model to plot:"/>
+ <text>Only objects of class Rm are valid!</text>
+ <stretch />
+ <preview id="preview"/>
+ </column>
+ </row>
+ </tab>
+ <tab id="tab_options" label="Options">
+ <column id="col_options">
+ <frame id="frame_items" label="Optional item selection">
+ <input id="inp_items" label="List of items (plot all if empty)" />
+ <checkbox id="chk_mplot" label="Plot up to 4 items in one figure" value="mplot" />
+ <checkbox id="chk_ask" label="Ask before next figure is drawn" value="ask" checked="true" />
+ </frame>
+ <frame label="Range of person parameters">
+ <row>
+ <spinbox id="spin_abilfrom" label="From:" type="real" initial="-4" size="small" />
+ <spinbox id="spin_abilto" label="To:" type="real" initial="4" size="small" />
+ </row>
+ </frame>
+ <frame label="Range of probability to solve">
+ <row>
+ <spinbox id="spin_probfrom" label="From:" type="real" initial="0" min="0" max="1" size="small" />
+ <spinbox id="spin_probto" label="To:" type="real" initial="1" min="0" max="1" size="small" />
+ </row>
+ </frame>
+ <radio id="annotation" label="Annotation">
+ <option label="Show legend" value="legend" checked="true" />
+ <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/polytomous/plot_rsm.php
===================================================================
--- branches/release_branch_0.4.9/rkward/plugins/plots/irt/polytomous/plot_rsm.php (rev 0)
+++ branches/release_branch_0.4.9/rkward/plugins/plots/irt/polytomous/plot_rsm.php 2008-11-17 23:21:58 UTC (rev 2381)
@@ -0,0 +1,85 @@
+<?
+function preprocess () {
+ // we'll need the eRm package, so in case it's not loaded...
+?>
+ require(eRm)
+<?}
+
+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
+ $inp_items = getRK_val("inp_items");
+ $spin_abilfrom = getRK_val("spin_abilfrom");
+ $spin_abilto = getRK_val("spin_abilto");
+ $spin_probfrom = getRK_val("spin_probfrom");
+ $spin_probto = getRK_val("spin_probto");
+ $annotation = getRK_val("annotation");
+ $chk_ask = getRK_val("chk_ask");
+ $chk_mplot = getRK_val("chk_mplot");
+
+ // 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() ;
+ // plot all items?
+ if($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[] = "item.subset=c(".join(",", $arr_items).")"; }
+ if($chk_mplot == "mplot")
+ $options[] = "mplot=TRUE" ;
+ if($chk_ask != "ask")
+ $options[] = "ask=FALSE" ;
+
+ // more advanced options
+ // user defined ranges? we'll round it to two digits
+ if(($spin_abilfrom != "-4" || $spin_abilto != "4") && $spin_abilfrom < $spin_abilto)
+ $options[] = "xlim=c(".round($spin_abilfrom,2).",".round($spin_abilto,2).")" ;
+ if(($spin_probfrom != "0" || $spin_probto != "1") && $spin_probfrom < $spin_probto)
+ $options[] = "ylim=c(".round($spin_probfrom,2).",".round($spin_probto,2).")" ;
+ // annotate lines and show legend?
+ if($annotation == "plain")
+ $options[] = "legpos=FALSE" ;
+
+ if ($final) { ?>
+rk.header("Rating scale model plot")
+
+rk.graph.on()
+<? }
+ // only the following section will be generated for $final==false
+
+ ?>
+try(plotICC(<? 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/polytomous/plot_rsm.xml
===================================================================
--- branches/release_branch_0.4.9/rkward/plugins/plots/irt/polytomous/plot_rsm.xml (rev 0)
+++ branches/release_branch_0.4.9/rkward/plugins/plots/irt/polytomous/plot_rsm.xml 2008-11-17 23:21:58 UTC (rev 2381)
@@ -0,0 +1,48 @@
+<!DOCTYPE rkplugin>
+<document>
+ <code file="plot_rsm.php" />
+ <!-- <help file="plot_rsm.rkh" /> -->
+
+ <dialog label="Plotting fitted rating scale model">
+ <tabbook>
+ <tab id="tab_variables" label="Model">
+ <row id="row_vars">
+ <varselector id="vars" />
+ <column>
+ <varslot type="numeric" id="x" classes="Rm" source="vars" required="true" label="Choose fitted model to plot:"/>
+ <text>Only objects of class Rm are valid!</text>
+ <stretch />
+ <preview id="preview"/>
+ </column>
+ </row>
+ </tab>
+ <tab id="tab_options" label="Options">
+ <column id="col_options">
+ <frame id="frame_items" label="Optional item selection">
+ <input id="inp_items" label="List of items (plot all if empty)" />
+ <checkbox id="chk_mplot" label="Plot up to 4 items in one figure" value="mplot" />
+ <checkbox id="chk_ask" label="Ask before next figure is drawn" value="ask" checked="true" />
+ </frame>
+ <frame label="Range of person parameters">
+ <row>
+ <spinbox id="spin_abilfrom" label="From:" type="real" initial="-4" size="small" />
+ <spinbox id="spin_abilto" label="To:" type="real" initial="4" size="small" />
+ </row>
+ </frame>
+ <frame label="Range of probability to solve">
+ <row>
+ <spinbox id="spin_probfrom" label="From:" type="real" initial="0" min="0" max="1" size="small" />
+ <spinbox id="spin_probto" label="To:" type="real" initial="1" min="0" max="1" size="small" />
+ </row>
+ </frame>
+ <radio id="annotation" label="Annotation">
+ <option label="Show legend" value="legend" checked="true" />
+ <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