[rkward-cvs] SF.net SVN: rkward: [1723] trunk/rkward/rkward/plugins/analysis/moments

tfry at users.sourceforge.net tfry at users.sourceforge.net
Sun Mar 25 21:53:36 UTC 2007


Revision: 1723
          http://svn.sourceforge.net/rkward/?rev=1723&view=rev
Author:   tfry
Date:     2007-03-25 14:53:36 -0700 (Sun, 25 Mar 2007)

Log Message:
-----------
local() adjustments, small simplifications and length/NA option

Modified Paths:
--------------
    trunk/rkward/rkward/plugins/analysis/moments/agostino_test.php
    trunk/rkward/rkward/plugins/analysis/moments/agostino_test.rkh
    trunk/rkward/rkward/plugins/analysis/moments/agostino_test.xml
    trunk/rkward/rkward/plugins/analysis/moments/anscombe_test.php
    trunk/rkward/rkward/plugins/analysis/moments/anscombe_test.rkh
    trunk/rkward/rkward/plugins/analysis/moments/anscombe_test.xml
    trunk/rkward/rkward/plugins/analysis/moments/bonett_test.php
    trunk/rkward/rkward/plugins/analysis/moments/bonett_test.rkh
    trunk/rkward/rkward/plugins/analysis/moments/bonett_test.xml
    trunk/rkward/rkward/plugins/analysis/moments/moment.php
    trunk/rkward/rkward/plugins/analysis/moments/moment.rkh
    trunk/rkward/rkward/plugins/analysis/moments/moment.xml
    trunk/rkward/rkward/plugins/analysis/moments/skewness_kurtosis_test.php
    trunk/rkward/rkward/plugins/analysis/moments/skewness_kurtosis_test.rkh
    trunk/rkward/rkward/plugins/analysis/moments/skewness_kurtosis_test.xml

Modified: trunk/rkward/rkward/plugins/analysis/moments/agostino_test.php
===================================================================
--- trunk/rkward/rkward/plugins/analysis/moments/agostino_test.php	2007-03-25 15:13:20 UTC (rev 1722)
+++ trunk/rkward/rkward/plugins/analysis/moments/agostino_test.php	2007-03-25 21:53:36 UTC (rev 1723)
@@ -29,9 +29,7 @@
 	}, error=function (e) e$message)	# catch any errors
 <?	if (getRK_val ("length")) { ?>
 	results[i, 'Length'] <- length (var)
-<?	}
-	if (getRK_val ("nacount")) { ?>
-	results[i, 'NAs'] <- length (which(is.na(var)))
+	results[i, 'NAs'] <- sum (is.na(var))
 <? 	} ?>
 }
 if (all (is.na (results$'Error'))) results$'Error' <- NULL

Modified: trunk/rkward/rkward/plugins/analysis/moments/agostino_test.rkh
===================================================================
--- trunk/rkward/rkward/plugins/analysis/moments/agostino_test.rkh	2007-03-25 15:13:20 UTC (rev 1722)
+++ trunk/rkward/rkward/plugins/analysis/moments/agostino_test.rkh	2007-03-25 21:53:36 UTC (rev 1723)
@@ -13,8 +13,7 @@
 		<setting id="x">Select the data to be computed. The vectors need to be numeric, and can be of different length.</setting>
 		<setting id="alternative">Here you can specify the alternative hypothesis. It must be one of "two sided", "greater" or "less".</setting>
 		<caption id="tab_options"/>
-		<setting id="length">If checked, the length of the data vectors will be shown. However, this will not effect your results but is just an optional information.</setting>
-		<setting id="nacount">If checked, and in case of missing values this will show you the number of those. However, this will not effect your results but is just an optional information.</setting>
+		<setting id="length">Show the total length of the data, and the number of missing values (purely informational, does not affect the test)?</setting>
 		<setting id="show_alternative">If checked, a verbose description of the alternative hypothesis will be shown along with the results</setting>
 	</settings>
 	<related>

Modified: trunk/rkward/rkward/plugins/analysis/moments/agostino_test.xml
===================================================================
--- trunk/rkward/rkward/plugins/analysis/moments/agostino_test.xml	2007-03-25 15:13:20 UTC (rev 1722)
+++ trunk/rkward/rkward/plugins/analysis/moments/agostino_test.xml	2007-03-25 21:53:36 UTC (rev 1723)
@@ -21,8 +21,7 @@
 				</row>
 			</tab>
 			<tab id="tab_options" label="Options">
-				<checkbox id="length" label="Show Length" value_unchecked="0" value="1" checked="true" />
-				<checkbox id="nacount" label="Show Missing Values" value_unchecked="0" value="1" checked="true" />
+				<checkbox id="length" label="Show Length and NAs" value_unchecked="0" value="1" checked="true" />
 				<checkbox id="show_alternative" label="Verbose alternative hypothesis" value_unchecked="0" value="1" checked="true"/>
 				<stretch/>
 			</tab>

Modified: trunk/rkward/rkward/plugins/analysis/moments/anscombe_test.php
===================================================================
--- trunk/rkward/rkward/plugins/analysis/moments/anscombe_test.php	2007-03-25 15:13:20 UTC (rev 1722)
+++ trunk/rkward/rkward/plugins/analysis/moments/anscombe_test.php	2007-03-25 21:53:36 UTC (rev 1723)
@@ -28,9 +28,7 @@
 	}, error=function (e) e$message)	# catch any errors
 <?	if (getRK_val ("length")) { ?>
 	results[i, 'Length'] <- length (var)
-<?	}
-	if (getRK_val ("nacount")) { ?>
-	results[i, 'NAs'] <- length (which(is.na(var)))
+	results[i, 'NAs'] <- sum (is.na(var))
 <? 	} ?>
 }
 if (all (is.na (results$'Error'))) results$'Error' <- NULL

Modified: trunk/rkward/rkward/plugins/analysis/moments/anscombe_test.rkh
===================================================================
--- trunk/rkward/rkward/plugins/analysis/moments/anscombe_test.rkh	2007-03-25 15:13:20 UTC (rev 1722)
+++ trunk/rkward/rkward/plugins/analysis/moments/anscombe_test.rkh	2007-03-25 21:53:36 UTC (rev 1723)
@@ -13,8 +13,7 @@
 		<setting id="x">Select the data to be computed. The vectors need to be numeric, and can be of different length.</setting>
 		<setting id="alternative">Here you can specify the alternative hypothesis. It must be one of "two sided", "greater" or "less".</setting>
 		<caption id="tab_options"/>
-		<setting id="length">If checked, the length of the data vectors will be shown. However, this will not effect your results but is just an optional information.</setting>
-		<setting id="nacount">If checked, and in case of missing values this will show you the number of those. However, this will not effect your results but is just an optional information.</setting>
+		<setting id="length">Show the total length of the data, and the number of missing values (purely informational, does not affect the test)?</setting>
 		<setting id="show_alternative">If checked, a verbose description of the alternative hypothesis will be shown along with the results</setting>
 	</settings>
 	<related>

Modified: trunk/rkward/rkward/plugins/analysis/moments/anscombe_test.xml
===================================================================
--- trunk/rkward/rkward/plugins/analysis/moments/anscombe_test.xml	2007-03-25 15:13:20 UTC (rev 1722)
+++ trunk/rkward/rkward/plugins/analysis/moments/anscombe_test.xml	2007-03-25 21:53:36 UTC (rev 1723)
@@ -21,8 +21,7 @@
 				</row>
 			</tab>
 			<tab id="tab_options" label="Options">
-				<checkbox id="length" label="Show Length" value_unchecked="0" value="1" checked="true" />
-				<checkbox id="nacount" label="Show Missing Values" value_unchecked="0" value="1" checked="true" />
+				<checkbox id="length" label="Show Length and NAs" value_unchecked="0" value="1" checked="true" />
 				<checkbox id="show_alternative" label="Verbose alternative hypothesis" value_unchecked="0" value="1" checked="true"/>
 				<stretch/>
 			</tab>

Modified: trunk/rkward/rkward/plugins/analysis/moments/bonett_test.php
===================================================================
--- trunk/rkward/rkward/plugins/analysis/moments/bonett_test.php	2007-03-25 15:13:20 UTC (rev 1722)
+++ trunk/rkward/rkward/plugins/analysis/moments/bonett_test.php	2007-03-25 21:53:36 UTC (rev 1723)
@@ -28,10 +28,8 @@
 		NA				# no error
 	}, error=function (e) e$message)	# catch any errors
 <?	if (getRK_val ("length")) { ?>
-		results[i, 'Length'] <- length (var)
-<?	}
-	if (getRK_val ("nacount")) { ?>
-		results[i, 'NAs'] <- length (which(is.na(var)))
+	results[i, 'Length'] <- length (var)
+	results[i, 'NAs'] <- length (which(is.na(var)))
 <? 	} ?>
 }
 if (all (is.na (results$'Error'))) results$'Error' <- NULL

Modified: trunk/rkward/rkward/plugins/analysis/moments/bonett_test.rkh
===================================================================
--- trunk/rkward/rkward/plugins/analysis/moments/bonett_test.rkh	2007-03-25 15:13:20 UTC (rev 1722)
+++ trunk/rkward/rkward/plugins/analysis/moments/bonett_test.rkh	2007-03-25 21:53:36 UTC (rev 1723)
@@ -13,8 +13,7 @@
 		<setting id="x">Select the data to be computed. The vectors need to be numeric, and can be of different length.</setting>
 		<setting id="alternative">Here you can specify the alternative hypothesis. It must be one of "two sided", "greater" or "less".</setting>
 		<caption id="tab_options"/>
-		<setting id="length">If checked, the length of the data vectors will be shown. However, this will not effect your results but is just an optional information.</setting>
-		<setting id="nacount">If checked, and in case of missing values this will show you the number of those. However, this will not effect your results but is just an optional information.</setting>
+		<setting id="length">Show the total length of the data, and the number of missing values (purely informational, does not affect the test)?</setting>
 		<setting id="show_alternative">If checked, a verbose description of the alternative hypothesis will be shown along with the results</setting>
 	</settings>
 	<related>

Modified: trunk/rkward/rkward/plugins/analysis/moments/bonett_test.xml
===================================================================
--- trunk/rkward/rkward/plugins/analysis/moments/bonett_test.xml	2007-03-25 15:13:20 UTC (rev 1722)
+++ trunk/rkward/rkward/plugins/analysis/moments/bonett_test.xml	2007-03-25 21:53:36 UTC (rev 1723)
@@ -21,8 +21,7 @@
 				</row>
 			</tab>
 			<tab label="Options" id="tab_options">
-				<checkbox id="length" label="Show Length" value_unchecked="0" value="1" checked="true" />
-				<checkbox id="nacount" label="Show Missing Values" value_unchecked="0" value="1" checked="true" />
+				<checkbox id="length" label="Show Length and NAs" value_unchecked="0" value="1" checked="true" />
 				<checkbox id="show_alternative" label="Verbose alternative hypothesis" value_unchecked="0" value="1" checked="true"/>
 				<stretch/>
 			</tab>

Modified: trunk/rkward/rkward/plugins/analysis/moments/moment.php
===================================================================
--- trunk/rkward/rkward/plugins/analysis/moments/moment.php	2007-03-25 15:13:20 UTC (rev 1722)
+++ trunk/rkward/rkward/plugins/analysis/moments/moment.php	2007-03-25 21:53:36 UTC (rev 1723)
@@ -1,43 +1,35 @@
 <?
-	function preprocess () {
-	}
+function preprocess () { ?>
+require(moments)
+<?
+}
 
-	function calculate () {
+function calculate () {
 	$vars = "substitute (" . str_replace ("\n", "), substitute (", trim (getRK_val ("x"))) . ")";
 
 ?>
-require(moments)
 
-rk.temp.objects <- list (<? echo ($vars); ?>)
-rk.temp.results <- data.frame ('Variable Name'=rep (NA, length (rk.temp.objects)), check.names=FALSE)
-local({
-	i=0;
-	for (var in rk.temp.objects) {
-		i = i+1
-		rk.temp.results$'Variable Name'[i] <<- rk.get.description (var, is.substitute=TRUE)
-		try (rk.temp.results$'Moment'[i] <<- moment (eval (var), central = <? getRK ("central"); ?>, absolute = <? getRK ("absolute"); ?>, na.rm = <? getRK ("narm"); ?>))
-		<? if (getRK_val ("length")) { ?>
-		try (rk.temp.results$'Length'[i] <<- length (eval (var)))
-		<? }
-		if (getRK_val ("nacount")) { ?>
-		try (rk.temp.results$'NAs'[i] <<- length (which(is.na(eval (var)))))
-		<? } ?>
-	}
-})
+objects <- list (<? echo ($vars); ?>)
+results <- data.frame ('Variable Name'=rep (NA, length (objects)), check.names=FALSE)
+for (i in 1:length (objects)) {
+	var <- eval (objects[[i]], envir=globalenv ())
+	results[i, 'Variable Name'] <- rk.get.description (objects[[i]], is.substitute=TRUE)
+
+	try (results[i, 'Moment'] <- moment (var, central = <? getRK ("central"); ?>, absolute = <? getRK ("absolute"); ?>, na.rm = <? getRK ("narm"); ?>))
+<?	if (getRK_val ("length")) { ?>
+
+	results[i, 'Length'] <- length (var)
+	results[i, 'NAs'] <- sum (is.na(var))
+<?	} ?>
+}
 <?
-        }
+}
 
 function printout () {
 ?>
 rk.header ("Statistical Moment",
 	parameters=list ("Compute central moments", "<? getRK ("central"); ?>","Compute absolute moments", "<? getRK ("absolute"); ?>", "Remove missing values", "<? getRK ("narm"); ?>"))
-rk.results (rk.temp.results)
+rk.results (results)
 <?
 }
-
-function cleanup () {
 ?>
-rm (list=grep ("^rk.temp", ls (), value=TRUE))
-<?
-}
-?>

Modified: trunk/rkward/rkward/plugins/analysis/moments/moment.rkh
===================================================================
--- trunk/rkward/rkward/plugins/analysis/moments/moment.rkh	2007-03-25 15:13:20 UTC (rev 1722)
+++ trunk/rkward/rkward/plugins/analysis/moments/moment.rkh	2007-03-25 21:53:36 UTC (rev 1723)
@@ -15,8 +15,7 @@
 		<setting id="central">If checked,  central moments are computed.</setting>
 		<setting id="absolute">If checked, absolute moments are computed.</setting>
 		<setting id="narm">If checked, missing values will be excluded from calculation (default setting in RKWard).</setting>
-		<setting id="length">If checked, the length of the data vectors will be shown. However, this will not effect your results but is just an optional information.</setting>
-		<setting id="nacount">If checked, and in case of missing values this will show you the number of those. However, this will not effect your results but is just an optional information.</setting>
+		<setting id="length">Show the total length of the data, and the number of missing values (purely informational, does not affect the test)?</setting>
 	</settings>
 	<related>
 		<ul>

Modified: trunk/rkward/rkward/plugins/analysis/moments/moment.xml
===================================================================
--- trunk/rkward/rkward/plugins/analysis/moments/moment.xml	2007-03-25 15:13:20 UTC (rev 1722)
+++ trunk/rkward/rkward/plugins/analysis/moments/moment.xml	2007-03-25 21:53:36 UTC (rev 1723)
@@ -23,8 +23,7 @@
 					<checkbox id="narm" label="remove missing values" checked="true" value="TRUE" value_unchecked="FALSE" />
 				</frame>
 				<frame label="additional settings">
-					<checkbox id="length" label="Show Length" value_unchecked="0" value="1" checked="false" />
-					<checkbox id="nacount" label="Show Missing Values" value_unchecked="0" value="1" checked="false" />
+					<checkbox id="length" label="Show Length and NAs" value_unchecked="0" value="1" checked="false" />
 				</frame>
 			</tab>
 		</tabbook>

Modified: trunk/rkward/rkward/plugins/analysis/moments/skewness_kurtosis_test.php
===================================================================
--- trunk/rkward/rkward/plugins/analysis/moments/skewness_kurtosis_test.php	2007-03-25 15:13:20 UTC (rev 1722)
+++ trunk/rkward/rkward/plugins/analysis/moments/skewness_kurtosis_test.php	2007-03-25 21:53:36 UTC (rev 1723)
@@ -10,46 +10,37 @@
 	else $narm = ", na.rm=FALSE"
 
 ?>
-rk.temp.objects <- list (<? echo ($vars); ?>)
-rk.temp.results <- data.frame ('Variable Name'=rep (NA, length (rk.temp.objects)), check.names=FALSE)
-local({
-	i=0;
-	for (var in rk.temp.objects) {
-		i = i+1
-		rk.temp.results$'Variable Name'[i] <<- rk.get.description (var, is.substitute=TRUE)
-	<?
-		if (getRK_val ("skewness")) { ?>
-		try (rk.temp.results$'Skewness'[i] <<- skewness (eval (var)<? echo ($narm); ?>))
-	<?	}
-		if (getRK_val ("kurtosis")) { ?>
-		try ({
-		rk.temp.results$'Kurtosis'[i] <<- kurtosis (eval (var)<? echo ($narm); ?>)
-		rk.temp.results$'Excess Kurtosis'[i] <<- rk.temp.results$'Kurtosis'[i] - 3
-		})
-	<?	}
-		if (getRK_val ("geary")) { ?>
-		try (rk.temp.results$'Geary Kurtosis'[i] <<- geary (eval (var)<? echo ($narm); ?>))
-	<?	}
-		if (getRK_val ("length")) { ?>
-		try (rk.temp.results$'Length'[i] <<- length (eval (var)))
-	<?	}
-		if (getRK_val ("nacount")) { ?>
-		try (rk.temp.results$'NAs'[i] <<- length (which(is.na(eval (var)))))
-	<?	} ?>
-	}
-})
+objects <- list (<? echo ($vars); ?>)
+results <- data.frame ('Variable Name'=rep (NA, length (objects)), check.names=FALSE)
+for (i in 1:length (objects)) {
+	var <- eval (objects[[i]], envir=globalenv ())
+	results[i, 'Variable Name'] <- rk.get.description (objects[[i]], is.substitute=TRUE)
+
+	try ({
 <?
+	if (getRK_val ("skewness")) { ?>
+		results[i, 'Skewness'] <- skewness (var<? echo ($narm); ?>)
+<?	}
+	if (getRK_val ("kurtosis")) { ?>
+		results[i, 'Kurtosis'] <- kurtosis (var<? echo ($narm); ?>)
+		results[i, 'Excess Kurtosis'] <- results[i, 'Kurtosis'] - 3
+<?	}
+	if (getRK_val ("geary")) { ?>
+		results[i, 'Geary Kurtosis'] <- geary (var<? echo ($narm); ?>)
+<?	} ?>
+	})
+<?	if (getRK_val ("length")) { ?>
+
+	results[i, 'Length'] <- length (var)
+	results[i, 'NAs'] <- sum (is.na(var))
+<?	} ?>
 }
+<?
+}
 function printout () {
 ?>
 rk.header ("Skewness and Kurtosis")
-rk.results (rk.temp.results)
+rk.results (results)
 <?
 }
-
-function cleanup () {
 ?>
-rm (list=grep ("^rk.temp", ls (), value=TRUE))
-<?
-       }
-?>
\ No newline at end of file

Modified: trunk/rkward/rkward/plugins/analysis/moments/skewness_kurtosis_test.rkh
===================================================================
--- trunk/rkward/rkward/plugins/analysis/moments/skewness_kurtosis_test.rkh	2007-03-25 15:13:20 UTC (rev 1722)
+++ trunk/rkward/rkward/plugins/analysis/moments/skewness_kurtosis_test.rkh	2007-03-25 21:53:36 UTC (rev 1723)
@@ -16,8 +16,7 @@
 		<setting id="kurtosis">If this option is chosen, Pearson's kurtosis will be computed.</setting>
 		<setting id="geary">If this option is chosen, Geary's kurtosis will be computed.</setting>
 		<setting id="narm">If checked, missing values will be excluded from calculation of skewness and kurtosis.</setting>
-		<setting id="length">If checked, the length of the data vectors will be shown. However, this will not effect your results but is just an optional information.</setting>
-		<setting id="nacount">If checked, and in case of missing values this will show you the number of those. However, this will not effect your results but is just an optional information.</setting>
+		<setting id="length">Show the total length of the data, and the number of missing values (purely informational, does not affect the test)?</setting>
 	</settings>
 	<related>
 		<ul>

Modified: trunk/rkward/rkward/plugins/analysis/moments/skewness_kurtosis_test.xml
===================================================================
--- trunk/rkward/rkward/plugins/analysis/moments/skewness_kurtosis_test.xml	2007-03-25 15:13:20 UTC (rev 1722)
+++ trunk/rkward/rkward/plugins/analysis/moments/skewness_kurtosis_test.xml	2007-03-25 21:53:36 UTC (rev 1723)
@@ -32,7 +32,6 @@
 					<checkbox id="geary" label="Geary's kurtosis" value_unchecked="0" value="1" checked="false" />
 				</frame>
 				<checkbox id="length" label="Show Length" value_unchecked="0" value="1" checked="false" />
-				<checkbox id="nacount" label="Show Missing Values" value_unchecked="0" value="1" checked="false" />
 			</tab>
 		</tabbook>
 	</dialog>


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