[rkward-cvs] SF.net SVN: rkward:[2718] trunk/rkward/rkward/plugins/analysis/irt/ polytomous

m-eik at users.sourceforge.net m-eik at users.sourceforge.net
Mon Nov 30 20:49:09 UTC 2009


Revision: 2718
          http://rkward.svn.sourceforge.net/rkward/?rev=2718&view=rev
Author:   m-eik
Date:     2009-11-30 20:49:08 +0000 (Mon, 30 Nov 2009)

Log Message:
-----------
irt: should have added the new gpcm dialogs in the first place...

Added Paths:
-----------
    trunk/rkward/rkward/plugins/analysis/irt/polytomous/par_est_gpcm.php
    trunk/rkward/rkward/plugins/analysis/irt/polytomous/par_est_gpcm.rkh
    trunk/rkward/rkward/plugins/analysis/irt/polytomous/par_est_gpcm.xml

Added: trunk/rkward/rkward/plugins/analysis/irt/polytomous/par_est_gpcm.php
===================================================================
--- trunk/rkward/rkward/plugins/analysis/irt/polytomous/par_est_gpcm.php	                        (rev 0)
+++ trunk/rkward/rkward/plugins/analysis/irt/polytomous/par_est_gpcm.php	2009-11-30 20:49:08 UTC (rev 2718)
@@ -0,0 +1,84 @@
+<?
+function preprocess () {
+  // we'll need the ltm package, so in case it's not loaded...
+?>
+  require(ltm)
+<?}
+
+function calculate () {
+  // let's read all values into php variables for the sake of readable code
+  $data         = getRK_val("x");
+  $chk_select   = getRK_val("chk_select");
+  $inp_items    = getRK_val("inp_items");
+  // reformat $inp_items
+  if($inp_items)
+    $inp_items       = str_replace("\n", ", ", preg_replace("/(.+)\[\[(.+)\]\]/", "$2", $inp_items));
+
+  $constraint   = getRK_val("constraint");
+  $startval     = getRK_val("startval");
+  $startval_lst = getRK_val("startval_lst");
+  $naaction     = getRK_val("naaction");
+  $irtparam     = getRK_val("irtparam");
+  $optimeth     = getRK_val("optimeth");
+  $verbose      = getRK_val("verbose");
+  // these are gpcm specific
+  $ghk_gpcm     = getRK_val("ghk_gpcm");
+  $iterqn_gpcm  = getRK_val("iterqn_gpcm");
+  $optimizer    = getRK_val("optimizer");
+  $numrderiv    = getRK_val("numrderiv");
+  $epshess      = getRK_val("epshess");
+  // $parscale     = getRK_val("parscale"); not implemented yet...
+
+  ///////////////////////////////////
+  // check for selected advanced control options
+  $control = array() ;
+  if($iterqn_gpcm != "150")
+    $control[] = "iter.qN=".$iterqn_gpcm ;
+  if($ghk_gpcm != "21")
+    $control[] = "GHk=".$ghk_gpcm ;
+  if($optimizer != "optim")
+    $control[] = "optimizer=\"nlminb\"" ;
+  if($optimizer == "optim" && $optimeth != "BFGS")
+    $control[] = "optimMethod=\"".$optimeth."\"" ;
+  if($numrderiv != "fd")
+    $control[] = "numrDeriv=\"cd\"" ;
+  if($epshess != "1e-06")
+    $control[] = "epsHes=".$epshess ;
+  if($verbose == "TRUE")
+    $control[] = "verbose=TRUE" ;
+
+?>estimates.gpcm <- gpcm(<?
+		  if($data && $chk_select && $inp_items)
+		    echo("subset(".$data.", select=c(".$inp_items."))");
+		  else
+		    echo($data);
+                  // any additional options?
+                  if($constraint != "gpcm") echo(", constraint=\"".$constraint."\"");
+                  if($irtparam != "TRUE") echo(", IRT.param=FALSE");
+                  if($startval == "list" && $startval_lst) echo(", start.val=".$startval_lst);
+		  if($startval == "random") echo(", start.val=\"random\"");
+                  if($naaction) echo(", na.action=".$naaction);
+                  // finally check if any advanced control options must be inserted
+                  if($control) echo(", control=list(".join(", ", $control).")");
+ ?>)
+<?}
+
+function printout () {
+  // check whether parameter estimations should be kept in the global enviroment
+  $save         = getRK_val("chk_save");
+  $save_name    = getRK_val("save_name");
+?>
+rk.header ("GPCM parameter estimation")
+rk.print (paste("Call: <code>",deparse(estimates.gpcm$call, width.cutoff=500),"</code>"))
+rk.print ("<h4>Coefficients:</h4>")
+rk.print (coef(estimates.gpcm))
+rk.print (paste("Log-likelihood value at convergence:",round(estimates.gpcm$log.Lik, digits=1)))
+<?
+// check if results are to be saved:
+if ($save && $save_name) {
+?>
+# keep results in current workspace
+<? echo($save_name); ?> <<- estimates.gpcm
+<?}
+}
+?>
\ No newline at end of file

Added: trunk/rkward/rkward/plugins/analysis/irt/polytomous/par_est_gpcm.rkh
===================================================================
--- trunk/rkward/rkward/plugins/analysis/irt/polytomous/par_est_gpcm.rkh	                        (rev 0)
+++ trunk/rkward/rkward/plugins/analysis/irt/polytomous/par_est_gpcm.rkh	2009-11-30 20:49:08 UTC (rev 2718)
@@ -0,0 +1,73 @@
+<!DOCTYPE rkhelp>
+  <document>
+    <summary>
+      This plugin estimates parameters under Item Response Theory approach, using the <link href="rkward://rhelp/ltm-package">ltm</link> package.
+    </summary>
+
+    <usage>
+      To fit the generalized partial credit model with default settings, just the matrix of manifest variables (polytomous item responses) must be selected. Further options are described in the sections below.
+
+      The complete results can be stored as a new object in the current workspace for further use (e.g. plotting item characteristic curves).
+    </usage>
+
+    <settings>
+      <caption id="tab_data"/>
+      <setting id="x" title="Matrix of manifest variables">
+        Select the matrix of polytomous item responses from the objects shown on the left.
+      </setting>
+      <setting id="frame_items">
+	 If you only want to use a subset of items from selected object, you can specify these here.
+      </setting>
+
+      <caption id="tab_options"/>
+      <setting id="frame_constraints">
+	Choose if discrimination parameters should be computed for each item individually. Alternatively, you can estimate one discrimination parameter that is equal for all items, or fix it at 1 for all items.
+      </setting>
+      <setting id="startval">
+        By default start values for the parameters are computed automatically. Alternatively, you can force the use of random start values, or give a list of values to be used. For detailed information on the specific layout of that list please refer to the manual for the  <link href="rkward://rhelp/gpcm">gpcm()</link> function.
+      </setting>
+      <setting id="naaction">
+        Specifies how missing values are to be treated. By default all available cases are used. If checked, only complete cases will be considered.
+      </setting>
+      <setting id="irtparam">
+        If checked, the coefficients' estimates are reported under the usual Item Response Theory parameterization (which is the default).
+      </setting>
+
+      <caption id="tab_advanced_control"/>
+      <setting id="iterqn_gpcm" title="Number of quasi-Newton iterations">
+        Defaults to 150.
+      </setting>
+      <setting id="ghk_gpcm" title="Number of Gauss-Hermite quadrature points">
+        Defaults to 21.
+      </setting>
+      <setting id="optimizer" title="Used optimizer">
+        By default <link href="rkward://rhelp/optim">optim()</link> is being used for optimization. Alternatively, <link href="rkward://rhelp/nlminb">nlminb()</link> can be called.
+      </setting>
+      <setting id="optimeth" title="Optimization method">
+        The default optimization method is BFGS. It can be set to Nelder-Mead, CG, L-BFGS-B, or SANN instead. Please refer to the <link href="rkward://rhelp/optim">optim()</link> manual for details.
+      </setting>
+      <setting id="numrderiv">
+	Options are forward difference approximation (the default) and central difference approximation.
+      </setting>
+      <setting id="epshess">
+        Step size to be used in the numerical derivative. Default is 1e-06. If you use central difference approximation, change this to a larger value, e.g., 1e-03 or 1e-04.
+      </setting>
+      <setting id="verbose">
+        Pretty much speaks for itself ;-)
+      </setting>
+    </settings>
+
+   <related>
+       Please refer to the <code>ltm</code> manuals for further information and detailed command line options:
+        <ul>
+                <li><link href="rkward://rhelp/ltm-package"/></li>
+                <li><link href="rkward://rhelp/gpcm"/></li>
+        </ul>
+   </related>
+
+   <technical>
+     Todo:
+       <ul>
+         <li>The <code>parscale</code> control element is not yet implemented.</li>
+       </ul>
+   </technical>
\ No newline at end of file

Added: trunk/rkward/rkward/plugins/analysis/irt/polytomous/par_est_gpcm.xml
===================================================================
--- trunk/rkward/rkward/plugins/analysis/irt/polytomous/par_est_gpcm.xml	                        (rev 0)
+++ trunk/rkward/rkward/plugins/analysis/irt/polytomous/par_est_gpcm.xml	2009-11-30 20:49:08 UTC (rev 2718)
@@ -0,0 +1,91 @@
+<!DOCTYPE rkplugin>
+<document>
+  <code file="par_est_gpcm.php" />
+  <help file="par_est_gpcm.rkh" />
+
+  <logic>
+    <convert id="optim_used"  mode="equals" sources="optimizer.string" standard="optim" />
+    <convert id="sv_matrix" mode="equals" sources="startval.string" standard="list" />
+
+    <connect client="inp_items.enabled" governor="chk_select.state" />
+    <connect client="spin_ci.enabled" governor="chk_bsci.state" />
+    <connect client="optimeth.enabled" governor="optim_used" />
+    <connect client="startval_lst.enabled" governor="sv_matrix" />
+    <connect client="startval_lst.required" governor="sv_matrix" />
+
+    <connect client="save_name.enabled"  governor="chk_save.state" />
+    <connect client="save_name.required" governor="chk_save.state" />
+  </logic>
+
+  <dialog label="IRT parameter estimation: Generalized partial credit model">
+    <tabbook>
+      <tab id="tab_data" label="Manifest variables">
+        <row id="manifest_resp_row">
+          <varselector id="vars" />
+          <column>
+            <varslot type="numeric" id="x" classes="data.frame matrix" source="vars" required="true" label="Matrix of manifest variables:"/>
+            <frame id="frame_items" label="Item selection">
+	      <checkbox id="chk_select" label="Select a subset of items" value="select" />
+	      <varslot type="numeric" id="inp_items" source="vars" multi="true" min_vars="2" label="List of items:" />
+            </frame>
+            <stretch />
+	    <frame id="frame_save">
+	      <checkbox id="chk_save" label="Keep results in current workspace" value="save" checked="true"/>
+	      <saveobject id="save_name" initial="estimates.gpcm"/>
+	    </frame>
+          </column>
+        </row>
+      </tab>
+      <tab id="tab_options" label="Options">
+        <row id="options_row">
+          <varselector id="vars2" />
+          <column id="opt_var_col">
+            <radio label="Should parameters be fixed (constrainted)?" id="constraint">
+              <option label="Each item has its one discrimination parameter" value="gpcm" checked="true" />
+              <option label="Equal discrimination parameter across items" value="1PL" />
+              <option label="Discrimination parameter fixed at 1 across items" value="rasch" />
+            </radio>
+            <stretch />
+            <radio label="Start values" id="startval">
+              <option label="Compute automatically" value="NULL" checked="true" />
+              <option label="Use random start values" value="random" />
+              <option label="Use own list of start values" value="list" />
+            </radio>
+            <varslot type="numeric" id="startval_lst" source="vars2" label="List of start values:"/>
+            <frame label="Misc options">
+              <checkbox id="naaction" label="Use only complete cases" value="na.exclude" />
+              <checkbox id="irtparam" label="Usual IRT parameterization" checked="true" value="TRUE" />
+            </frame>
+          </column>
+        </row>
+      </tab>
+      <tab id="tab_advanced_control" label="Advanced control">
+        <row>
+        <column id="control_col">
+          <spinbox id="iterqn_gpcm" label="Number of quasi-Newton iterations:" type="integer" initial="150" size="small" />
+          <spinbox id="ghk_gpcm" label="Number of Gauss-Hermite quadrature points:" type="integer" initial="21" size="small" />
+          <dropdown id="optimizer" label="Used optimizer:">
+            <option label="optim()" value="optim" checked="true" />
+            <option label="nlminb()" value="nlminb" />
+          </dropdown>
+          <dropdown id="optimeth" label="Optimization method:">
+            <option label="BFGS" value="BFGS" checked="true" />
+            <option label="Nelder-Mead" value="Nelder-Mead" />
+            <option label="CG" value="CG" />
+            <option label="L-BFGS-B" value="L-BFGS-B" />
+            <option label="SANN" value="SANN" />
+          </dropdown>
+          <dropdown id="numrderiv" label="Numerical derivative algorithm to approximate Hessian matrix:">
+            <option label="Forward difference approximation" value="fd" checked="true" />
+            <option label="Central difference approximation" value="cd" />
+          </dropdown>
+          <spinbox id="epshess" label="Step-length for approximation" type="real" initial="1e-06" size="small" />
+          <!-- todo: parscale option -->
+          <stretch />
+          <checkbox id="verbose" label="Print verbose info about optimization" value="TRUE" />
+        </column>
+      </row>
+      </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