[rkward-cvs] SF.net SVN: rkward:[2725] trunk/rkward/rkward/plugins/analysis/irt/ dichotomous

m-eik at users.sourceforge.net m-eik at users.sourceforge.net
Wed Dec 9 15:34:19 UTC 2009


Revision: 2725
          http://rkward.svn.sourceforge.net/rkward/?rev=2725&view=rev
Author:   m-eik
Date:     2009-12-09 15:34:15 +0000 (Wed, 09 Dec 2009)

Log Message:
-----------
irt: working JS version of par_est_2pl

Modified Paths:
--------------
    trunk/rkward/rkward/plugins/analysis/irt/dichotomous/par_est_2pl.js
    trunk/rkward/rkward/plugins/analysis/irt/dichotomous/par_est_2pl.xml

Removed Paths:
-------------
    trunk/rkward/rkward/plugins/analysis/irt/dichotomous/par_est_2pl.php

Modified: trunk/rkward/rkward/plugins/analysis/irt/dichotomous/par_est_2pl.js
===================================================================
--- trunk/rkward/rkward/plugins/analysis/irt/dichotomous/par_est_2pl.js	2009-12-07 10:59:30 UTC (rev 2724)
+++ trunk/rkward/rkward/plugins/analysis/irt/dichotomous/par_est_2pl.js	2009-12-09 15:34:15 UTC (rev 2725)
@@ -1,94 +1,62 @@
-/* ------- This file generated by php2js from PHP code. --------
-Please check this file by hand, and remove this notice, afterwards.
-Messages:
-Note: Control statement without braces. This is bad style.
-Note: Control statement without braces. This is bad style.
-Note: Control statement without braces. This is bad style.
-Note: Control statement without braces. This is bad style.
-Note: Control statement without braces. This is bad style.
-Note: Control statement without braces. This is bad style.
-Note: Control statement without braces. This is bad style.
-
----------------------------- */
-
-// globals
-var undefined;
-
 function preprocess () {
 	// we'll need the ltm package, so in case it's not loaded...
-
-	echo ('  require(ltm)\n');
+	echo ('require(ltm)\n');
 }
 
 function calculate () {
-	var constraint = "";
-	var startval = "";
-	var startval_mtx = "";
-	var naaction = "";
-	var irtparam = "";
-	var optimeth = "";
-	var verbose = "";
-	var ghk_2pl = "";
-	var iterem = "";
-	var iterqn_2pl = "";
-	var interact = "";
-	var control = "";
-	// let's read all values into php variables for the sake of readable code
-	constraint   = getValue("constraint");
-	startval     = getValue("startval");
-	startval_mtx = getValue("startval_mtx");
-	naaction     = getValue("naaction");
-	irtparam     = getValue("irtparam");
-	optimeth     = getValue("optimeth");
-	verbose      = getValue("verbose");
+	// let's read all values into variables for the sake of readable code
+	var constraint = getValue("constraint");
+	var startval = getValue("startval");
+	var startval_mtx = getValue("startval_mtx");
+	var naaction = getValue("naaction");
+	var irtparam = getValue("irtparam");
+	var optimeth = getValue("optimeth");
+	var verbose = getValue("verbose");
 	// these are 2pl specific
-	ghk_2pl      = getValue("ghk_2pl");
-	iterem       = getValue("iterem");
-	iterqn_2pl   = getValue("iterqn_2pl");
-	interact     = getValue("interact");
+	var ghk_2pl = getValue("ghk_2pl");
+	var iterem = getValue("iterem");
+	var iterqn_2pl = getValue("iterqn_2pl");
+	var interact = getValue("interact");
 
 	///////////////////////////////////
 	// check for selected advanced control options
-	control = new Array) ;
-	if (iterem != "40")
-	control[] = "iter.em="+iterem ;
-	if (iterqn_2pl != "150")
-		control[] = "iter.qN="+iterqn_2pl ;
-		if (ghk_2pl != "15")
-			control[] = "GHk="+ghk_2pl ;
-			if (optimeth != "BFGS")
-				control[] = "method=\""+optimeth+"\"" ;
-				if (verbose == "TRUE")
-					control[] ="verbose=TRUE" ;
+	var control = new Array() ;
+	if (iterem != "40"){
+		control[control.length] = "iter.em="+iterem ; }
+	if (iterqn_2pl != "150"){
+		control[control.length] = "iter.qN="+iterqn_2pl ; }
+	if (ghk_2pl != "15"){
+		control[control.length] = "GHk="+ghk_2pl ; }
+	if (optimeth != "BFGS"){
+		control[control.length] = "method=\""+optimeth+"\"" ; }
+	if (verbose == "TRUE"){
+		control[control.length] = "verbose=TRUE" ; }
 
-					echo ('estimates.2pl <- ltm(' + getValue("x") + ' ~ z1');
-						// any additional options?
-						if (interact == "TRUE") echo(" * z2");
-						if (constraint) echo(", constraint="+constraint);
-							if (irtparam != "TRUE") echo(", IRT.param=FALSE");
-								if (startval == "random") echo(", start.val=\"random\"");
-									if (startval == "matrix") echo(", start.val="+startval_mtx);
-										if (naaction) echo(", na.action="+naaction);
-											// finally check if any advanced control options must be inserted
-											if (control) echo(", control=list("+join(", ", control)+")");
-													echo (')\n');
-												}
+		echo ('estimates.2pl <- ltm(' + getValue("x") + ' ~ z1');
+			// any additional options?
+			if (interact == "TRUE") echo(" * z2");
+			if (constraint) echo(", constraint="+constraint);
+			if (irtparam != "TRUE") echo(", IRT.param=FALSE");
+			if (startval == "random") echo(", start.val=\"random\"");
+			if (startval == "matrix") echo(", start.val="+startval_mtx);
+			if (naaction) echo(", na.action="+naaction);
+			// finally check if any advanced control options must be inserted
+			if (control.length > 0) echo(", control=list("+control.join(", ")+")");
+				echo (')\n');
+			}
 
 function printout () {
-	var save = "";
-	var save_name = "";
 	// check whether parameter estimations should be kept in the global enviroment
-	save         = getValue("chk_save");
-	save_name    = getValue("save_name");
+	var save         = getValue("chk_save");
+	var save_name    = getValue("save_name");
 
 	echo ('rk.header ("2PL parameter estimation")\n');
 	echo ('rk.print (paste("Call: <code>",deparse(estimates.2pl$call, width.cutoff=500),"</code>"))\n');
 	echo ('rk.print ("<h4>Coefficients:</h4>")\n');
 	echo ('rk.print (coef(estimates.2pl))\n');
 	echo ('rk.print (paste("Log-likelihood value at convergence:",round(estimates.2pl$log.Lik, digits=1)))\n');
-// check if results are to be saved:
+	// check if results are to be saved:
 	if (save && save_name) {
-
 		echo ('# keep results in current workspace\n');
 		echo (save_name + ' <<- estimates.2pl\n');
 	}

Deleted: trunk/rkward/rkward/plugins/analysis/irt/dichotomous/par_est_2pl.php
===================================================================
--- trunk/rkward/rkward/plugins/analysis/irt/dichotomous/par_est_2pl.php	2009-12-07 10:59:30 UTC (rev 2724)
+++ trunk/rkward/rkward/plugins/analysis/irt/dichotomous/par_est_2pl.php	2009-12-09 15:34:15 UTC (rev 2725)
@@ -1,68 +0,0 @@
-<?
-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
-  $constraint   = getRK_val("constraint");
-  $startval     = getRK_val("startval");
-  $startval_mtx = getRK_val("startval_mtx");
-  $naaction     = getRK_val("naaction");
-  $irtparam     = getRK_val("irtparam");
-  $optimeth     = getRK_val("optimeth");
-  $verbose      = getRK_val("verbose");
-  // these are 2pl specific
-  $ghk_2pl      = getRK_val("ghk_2pl");
-  $iterem       = getRK_val("iterem");
-  $iterqn_2pl   = getRK_val("iterqn_2pl");
-  $interact     = getRK_val("interact");
-
-  ///////////////////////////////////
-  // check for selected advanced control options
-  $control = array() ;
-  if($iterem != "40")
-    $control[] = "iter.em=".$iterem ;
-  if($iterqn_2pl != "150")
-    $control[] = "iter.qN=".$iterqn_2pl ;
-  if($ghk_2pl != "15")
-    $control[] = "GHk=".$ghk_2pl ;
-  if($optimeth != "BFGS")
-    $control[] = "method=\"".$optimeth."\"" ;
-  if($verbose == "TRUE")
-    $control[] ="verbose=TRUE" ;
-
-?>estimates.2pl <- ltm(<? getRK("x"); ?> ~ z1<?
-                  // any additional options?
-                  if($interact == "TRUE") echo(" * z2");
-                  if($constraint) echo(", constraint=".$constraint);
-                  if($irtparam != "TRUE") echo(", IRT.param=FALSE");
-                  if($startval == "random") echo(", start.val=\"random\"");
-                  if($startval == "matrix") echo(", start.val=".$startval_mtx);
-                  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 ("2PL parameter estimation")
-rk.print (paste("Call: <code>",deparse(estimates.2pl$call, width.cutoff=500),"</code>"))
-rk.print ("<h4>Coefficients:</h4>")
-rk.print (coef(estimates.2pl))
-rk.print (paste("Log-likelihood value at convergence:",round(estimates.2pl$log.Lik, digits=1)))
-<?
-// check if results are to be saved:
-if ($save && $save_name) {
-?>
-# keep results in current workspace
-<? echo($save_name); ?> <<- estimates.2pl
-<?}
-}
-?>
\ No newline at end of file

Modified: trunk/rkward/rkward/plugins/analysis/irt/dichotomous/par_est_2pl.xml
===================================================================
--- trunk/rkward/rkward/plugins/analysis/irt/dichotomous/par_est_2pl.xml	2009-12-07 10:59:30 UTC (rev 2724)
+++ trunk/rkward/rkward/plugins/analysis/irt/dichotomous/par_est_2pl.xml	2009-12-09 15:34:15 UTC (rev 2725)
@@ -1,6 +1,6 @@
 <!DOCTYPE rkplugin>
 <document>
-  <code file="par_est_2pl.php" />
+  <code file="par_est_2pl.js" />
   <help file="par_est_2pl.rkh" />
 
   <logic>


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