[education/rkward] /: Add ANOVA table option to linear regression plugin

Thomas Friedrichsmeier null at kde.org
Wed May 4 20:26:52 BST 2022


Git commit 1f27adc374a9800967ef34ef942d999adf46ac22 by Thomas Friedrichsmeier.
Committed on 04/05/2022 at 19:26.
Pushed by tfry into branch 'master'.

Add ANOVA table option to linear regression plugin

M  +1    -1    ChangeLog
M  +4    -1    rkward/plugins/analysis/regression/linear_regression.js
M  +1    -0    rkward/plugins/analysis/regression/linear_regression.rkh
M  +1    -0    rkward/plugins/analysis/regression/linear_regression.xml

https://invent.kde.org/education/rkward/commit/1f27adc374a9800967ef34ef942d999adf46ac22

diff --git a/ChangeLog b/ChangeLog
index f2082c1f..a35b9684 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,12 +2,12 @@ TODOs:
 	- More tolerant handshake on Windows? Simply a matter of allowing more time?
 	- Allow vector of names in require()
 
+- Add option to show ANOVA table for linear regression
 - Add default preview() function is available to plugins, reducing the code needed to add preview functionality
 - Add preview functionality to most existing plugins that did not have it, yet
 - Better placement of messages in non-plot preview windows
 - Fixed some problems with cancelling running commands
 - Package installation uses inline widget to provide progress feedback, instead of separate dialogs
-  - TODO: Remove "Ok" button from dialog, rename "Cancel" to "Close"
   - TODO: Remove current repositories from .rk.get.package.installation.status() (no longer needed)
 - Package installation no longer uses an external process, unless required for root permissions
 - Fixed: Package installation as root would fail to find kdesu/kdesudo on recent systems
diff --git a/rkward/plugins/analysis/regression/linear_regression.js b/rkward/plugins/analysis/regression/linear_regression.js
index 36112bf6..01a5bf99 100644
--- a/rkward/plugins/analysis/regression/linear_regression.js
+++ b/rkward/plugins/analysis/regression/linear_regression.js
@@ -10,7 +10,8 @@ function calculate () {
 	var savemodel = getBoolean ("savemodel.active");
 	var savefitted = getBoolean ("savefitted.active");
 	var saveresiduals = getBoolean ("saveresiduals.active");
-	var simple_mode = !(savefitted || saveresiduals || savemodel);
+	var anova = getBoolean("anova");
+	var simple_mode = !(savefitted || saveresiduals || savemodel || anova);
 
 	model = 'lm (' + getValue ("y") + ' ~ ' + intercept + vars;
 	if (!simple_mode) model += ', na.action=na.exclude';	// default action of na.omit is a nuisance for fitted values
@@ -25,6 +26,7 @@ function calculate () {
 		if (savefitted) echo ('.GlobalEnv$' + getString ('savefitted') + ' <- fitted (model)\n');
 		if (saveresiduals) echo ('.GlobalEnv$' + getString ('saveresiduals') + ' <- residuals (model)\n');
 		echo ('results <- summary (model)\n');
+		if (anova) echo ('results_anova <- anova (model)\n');
 	}
 }
 
@@ -33,4 +35,5 @@ function printout (is_preview) {
 		echo ('rk.header (' + i18n ("Linear Regression") + ')\n');
 	}
 	echo ('rk.print(results)\n');
+	if (getBoolean("anova")) echo ('rk.print(results_anova)\n');
 }
diff --git a/rkward/plugins/analysis/regression/linear_regression.rkh b/rkward/plugins/analysis/regression/linear_regression.rkh
index db1d88b8..d52ffbbb 100644
--- a/rkward/plugins/analysis/regression/linear_regression.rkh
+++ b/rkward/plugins/analysis/regression/linear_regression.rkh
@@ -14,6 +14,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="beta">Print standardized correlation coefficients? This requires the lm.beta package.</setting>
+		<setting id="anova">Show an analysis of variance table.</setting>
 		<caption id="tab_save"/>
 		<setting id="savemodel">Save the full fitted model.</setting>
 		<setting id="savefitted">Extract and save predicted values from the model.</setting>
diff --git a/rkward/plugins/analysis/regression/linear_regression.xml b/rkward/plugins/analysis/regression/linear_regression.xml
index 652417ca..ce38d6cb 100644
--- a/rkward/plugins/analysis/regression/linear_regression.xml
+++ b/rkward/plugins/analysis/regression/linear_regression.xml
@@ -12,6 +12,7 @@
 					<varslot types="numeric" id="x" source="vars" required="true" multi="true" label="independent variables"/>
 					<checkbox id="intercept" label="Include intercept" checked="true"/>
 					<checkbox id="beta" label="Show standardized coefficients" checked="false"/>
+					<checkbox id="anova" label="Show ANOVA table" checked="false"/>
 					<stretch/>
 					<preview id="preview" mode="output"/>
 				</column>


More information about the rkward-tracker mailing list