[rkward-cvs] SF.net SVN: rkward: [1984] trunk/rkward/rkward/plugins/analysis/regression

tfry at users.sourceforge.net tfry at users.sourceforge.net
Mon Sep 24 11:43:31 UTC 2007


Revision: 1984
          http://rkward.svn.sourceforge.net/rkward/?rev=1984&view=rev
Author:   tfry
Date:     2007-09-24 04:43:31 -0700 (Mon, 24 Sep 2007)

Log Message:
-----------
FOR 0.4.8: Linear regression plugin:
* Add (real) help file
* Remove tabbook for now (only a single tab exists so far)
* Allow multiple predictors
* Allow exclusion of intercept
* Use rk.print() for printing, for now. This makes the code easier to read, while essentially producing the same output.
Might be revisited in the future.

Modified Paths:
--------------
    trunk/rkward/rkward/plugins/analysis/regression/linear_regression.php
    trunk/rkward/rkward/plugins/analysis/regression/linear_regression.rkh
    trunk/rkward/rkward/plugins/analysis/regression/linear_regression.xml

Modified: trunk/rkward/rkward/plugins/analysis/regression/linear_regression.php
===================================================================
--- trunk/rkward/rkward/plugins/analysis/regression/linear_regression.php	2007-09-24 05:04:00 UTC (rev 1983)
+++ trunk/rkward/rkward/plugins/analysis/regression/linear_regression.php	2007-09-24 11:43:31 UTC (rev 1984)
@@ -1,44 +1,21 @@
 <?
 function preprocess () { ?>
 require(xtable)
-<?        }
+<?
+}
 
 function calculate () {
+	$vars = str_replace ("\n", " + ", trim (getRK_val ("x")));
+	if (!getRK_val ("intercept.state.numeric")) $intercept = "0 + ";
 ?>
-# This can be used in a later fase to give the user the option to choose 
-# precision. For the moment is stable 5 (In summary.lm is 4).
-n=5
-results <- summary.lm (lm (<? getRK ("y"); ?> ~ <? getRK ("x"); ?>) )
-# Here we get the quantiles of the residuals and place them in a matrix 
-# and we name them in order to use xtable
-quarlm<-matrix(quantile(residuals(results)),nrow=1, ncol=5)
-colnames(quarlm)<-c("Min","1Q","Median","2Q","Max")
-# We extract the coefficients
-coeflm<-coef(results)
-# the Residual standard error
-siglm<-results$sigma
-# the maximum degrees of fredom
-maxdflm<-(max(results$df))
-# the r squared and the adjusted r squared
-rsq<-results$r.squared
-arsq<-results$adj.r.squared
-# the fstatistic, we put it into a matrix and we name it in order to use xtable 
-fslm<-matrix(results$fstatistic,nrow=1,ncol=3)
-colnames(fslm)<-names(results$fstatistic)
+results <- summary.lm (lm (<? getRK ("y"); ?> ~ <? echo ($intercept . $vars); ?>))
 <?
 }
 
 function printout () {
 ?>
 rk.header ("Linear Regression")
-rk.print("Residuals")
-rk.results(xtable(quarlm))
-rk.print("Coefficients")
-rk.results(xtable(coeflm))
-rk.print(c("Residual standard error: ", round(siglm,n), " on ", maxdflm, " degrees of fredom"))
-rk.print(c("Multiple R-Squared: ", round(rsq,n), ", Adjusted R-squared: ", round(arsq,n)))
-rk.print("F-statistic")
-rk.results(xtable(fslm))
+rk.print(results)
 <?
 }
 ?>

Modified: trunk/rkward/rkward/plugins/analysis/regression/linear_regression.rkh
===================================================================
--- trunk/rkward/rkward/plugins/analysis/regression/linear_regression.rkh	2007-09-24 05:04:00 UTC (rev 1983)
+++ trunk/rkward/rkward/plugins/analysis/regression/linear_regression.rkh	2007-09-24 11:43:31 UTC (rev 1984)
@@ -1,23 +1,21 @@
 <!DOCTYPE rkhelp>
 <document>
 	<summary>
-		This test performs the Ansari-Bradley two-sample test to test for a difference in scale parameters.
+		Perform a simple linear regression. Currently, this plugin provides only basic functionality. For more options refer to <link href="rkward://rhelp/lm"/>.
 	</summary>
 
 	<usage>
-		Select two data sets for the Ansari-Bradley two-sample test. For this test the samples need to be numeric vectors (see below for details).
+		Select the variable to be predicted (dependent), and one or more independent variables.
 	</usage>
 
 	<settings>
-		<caption id="tab_variables"/>
-		<setting id="x">Select the data to be computed. The vectors need to be numeric.</setting>
-		<setting id="y">Select the data to be computed. The vectors need to be numeric.</setting>
-		<caption id="tab_options"/>
+		<setting id="y">The dependent variable. This must be numeric.</setting>
+		<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>
 	</settings>
 	<related>
 		<ul>
 			<li><link href="rkward://rhelp/lm"/></li>
 		</ul>
-
 	</related>
 </document>

Modified: trunk/rkward/rkward/plugins/analysis/regression/linear_regression.xml
===================================================================
--- trunk/rkward/rkward/plugins/analysis/regression/linear_regression.xml	2007-09-24 05:04:00 UTC (rev 1983)
+++ trunk/rkward/rkward/plugins/analysis/regression/linear_regression.xml	2007-09-24 11:43:31 UTC (rev 1984)
@@ -4,20 +4,15 @@
 	<help file="linear_regression.rkh"/>
 
 	<dialog label="Fitting Linear Models">
-		<tabbook>
-			<tab label="Basic settings" id="tab_variables">
-				<row>
-					<varselector id="vars"/>
-					<column>
-						<varslot type="numeric" id="y" source="vars" required="true" label="dependent variable"/>
-						<varslot type="numeric" id="x" source="vars" required="true" label="independent variable"/>
-						<stretch/>
-					</column>
-				</row>
-			</tab>
-			<tab label="Options" id="tab_options">
-			</tab>
-		</tabbook>
+		<row>
+			<varselector id="vars"/>
+			<column>
+				<varslot type="numeric" id="y" source="vars" required="true" label="dependent variable"/>
+				<varslot type="numeric" id="x" source="vars" required="true" multi="true" label="independent variables"/>
+				<checkbox id="intercept" label="include intercept" checked="true"/>
+				<stretch/>
+			</column>
+		</row>
 	</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