[rkward-cvs] SF.net SVN: rkward-code:[4839] trunk/rkward/rkward/plugins

tfry at users.sf.net tfry at users.sf.net
Sat Sep 20 10:15:09 UTC 2014


Revision: 4839
          http://sourceforge.net/p/rkward/code/4839
Author:   tfry
Date:     2014-09-20 10:15:07 +0000 (Sat, 20 Sep 2014)
Log Message:
-----------
Also offer to save residuals in regression

Modified Paths:
--------------
    trunk/rkward/rkward/plugins/analysis/regression/linear_regression.js
    trunk/rkward/rkward/plugins/analysis/regression/linear_regression.rkh
    trunk/rkward/rkward/plugins/analysis/regression/linear_regression.xml
    trunk/rkward/rkward/plugins/data/recode_categorical.js

Modified: trunk/rkward/rkward/plugins/analysis/regression/linear_regression.js
===================================================================
--- trunk/rkward/rkward/plugins/analysis/regression/linear_regression.js	2014-09-19 19:15:08 UTC (rev 4838)
+++ trunk/rkward/rkward/plugins/analysis/regression/linear_regression.js	2014-09-20 10:15:07 UTC (rev 4839)
@@ -4,17 +4,19 @@
 	if (!getBoolean ("intercept")) intercept = "0 + ";
 
 	var savefitted = getBoolean ("savefitted.active");
-	var simple_mode = !savefitted;
+	var saveresiduals = getBoolean ("saveresiduals.active");
+	var simple_mode = !(savefitted || saveresiduals);
 
 	model = 'lm (' + getValue ("y") + ' ~ ' + intercept + vars;
-	if (savefitted) model += ', na.action=na.exclude';	// default action of na.omit is a nuisance for fitted values
+	if (!simple_mode) model += ', na.action=na.exclude';	// default action of na.omit is a nuisance for fitted values
 	model += ')';
 
 	if (simple_mode) {
 		echo ('results <- summary.lm (' + model + ')\n');
 	} else {
 		echo ('model <- ' + model + '\n');
-		echo ('.GlobalEnv$' + getString ('savefitted') + ' <- fitted (model)\n');
+		if (savefitted) echo ('.GlobalEnv$' + getString ('savefitted') + ' <- fitted (model)\n');
+		if (saveresiduals) echo ('.GlobalEnv$' + getString ('saveresiduals') + ' <- residuals (model)\n');
 		echo ('results <- summary.lm (model)\n');
 	}
 }

Modified: trunk/rkward/rkward/plugins/analysis/regression/linear_regression.rkh
===================================================================
--- trunk/rkward/rkward/plugins/analysis/regression/linear_regression.rkh	2014-09-19 19:15:08 UTC (rev 4838)
+++ trunk/rkward/rkward/plugins/analysis/regression/linear_regression.rkh	2014-09-20 10:15:07 UTC (rev 4839)
@@ -13,6 +13,7 @@
 		<setting id="x">One or more independent variables, each of the same length as the dependent. Note that factor variables are treated as categorial predictors, while numeric variables are treated as continuous predictors, automatically.</setting>
 		<setting id="intercept">Should an intercept term be included in the model?</setting>
 		<setting id="savefitted">Extract and save predicted values from the model.</setting>
+		<setting id="saveresiduals">Extract and save residuals from the model.</setting>
 	</settings>
 	<related>
 		<ul>

Modified: trunk/rkward/rkward/plugins/analysis/regression/linear_regression.xml
===================================================================
--- trunk/rkward/rkward/plugins/analysis/regression/linear_regression.xml	2014-09-19 19:15:08 UTC (rev 4838)
+++ trunk/rkward/rkward/plugins/analysis/regression/linear_regression.xml	2014-09-20 10:15:07 UTC (rev 4839)
@@ -12,6 +12,7 @@
 				<checkbox id="intercept" label="include intercept" checked="true"/>
 				<stretch/>
 				<saveobject id="savefitted" label="Save fitted values" initial="lm_fitted" checkable="true"/>
+				<saveobject id="saveresiduals" label="Save residuals" initial="lm_residuals" checkable="true"/>
 			</column>
 		</row>
 	</dialog>

Modified: trunk/rkward/rkward/plugins/data/recode_categorical.js
===================================================================
--- trunk/rkward/rkward/plugins/data/recode_categorical.js	2014-09-19 19:15:08 UTC (rev 4838)
+++ trunk/rkward/rkward/plugins/data/recode_categorical.js	2014-09-20 10:15:07 UTC (rev 4839)
@@ -71,6 +71,6 @@
 }
 
 function printout () {
-// TODO: Number of differences count is off when a row is NA in one vector, but not the other.
-	makeHeaderCode ('Recode categorical data', new Array ('Input variable', input, 'Output variable', output, 'Number of differences after recoding', noquote ('sum (' + input + ' != ' + output + ', na.rm=TRUE)')));
+// TODO: Number of differences always shows as 0, if storing to same object...
+	makeHeaderCode ('Recode categorical data', new Array ('Input variable', input, 'Output variable', output, 'Number of differences after recoding', noquote ('sum (' + input + ' != ' + output + ', na.rm=TRUE) + sum (is.na (' + input + ') != is.na (' + output + '))')));
 }





More information about the rkward-tracker mailing list