[rkward-cvs] SF.net SVN: rkward:[2655] trunk/rkward/tests

tfry at users.sourceforge.net tfry at users.sourceforge.net
Wed Sep 23 15:35:35 UTC 2009


Revision: 2655
          http://rkward.svn.sourceforge.net/rkward/?rev=2655&view=rev
Author:   tfry
Date:     2009-09-23 15:35:35 +0000 (Wed, 23 Sep 2009)

Log Message:
-----------
Add a first bunch of tests for the distribution plugins

Added Paths:
-----------
    trunk/rkward/tests/distributions/
    trunk/rkward/tests/distributions/RKTestStandard.ad_test.rkcommands.R
    trunk/rkward/tests/distributions/RKTestStandard.ad_test.rkout
    trunk/rkward/tests/distributions/RKTestStandard.beta_clt.rkcommands.R
    trunk/rkward/tests/distributions/RKTestStandard.beta_clt.rkout
    trunk/rkward/tests/distributions/RKTestStandard.beta_probabilities.rkcommands.R
    trunk/rkward/tests/distributions/RKTestStandard.beta_probabilities.rkout
    trunk/rkward/tests/distributions/RKTestStandard.beta_quantiles.rkcommands.R
    trunk/rkward/tests/distributions/RKTestStandard.beta_quantiles.rkout
    trunk/rkward/tests/distributions/RKTestStandard.cvm_test.rkcommands.R
    trunk/rkward/tests/distributions/RKTestStandard.cvm_test.rkout
    trunk/rkward/tests/distributions/RKTestStandard.jb_test.rkcommands.R
    trunk/rkward/tests/distributions/RKTestStandard.jb_test.rkout
    trunk/rkward/tests/distributions/RKTestStandard.lillie_test.rkcommands.R
    trunk/rkward/tests/distributions/RKTestStandard.lillie_test.rkout
    trunk/rkward/tests/distributions/RKTestStandard.pearson_test.rkcommands.R
    trunk/rkward/tests/distributions/RKTestStandard.pearson_test.rkout
    trunk/rkward/tests/distributions/RKTestStandard.plot_beta_distribution.rkcommands.R
    trunk/rkward/tests/distributions/RKTestStandard.plot_beta_distribution.rkout
    trunk/rkward/tests/distributions/RKTestStandard.sf_test.rkcommands.R
    trunk/rkward/tests/distributions/RKTestStandard.sf_test.rkout
    trunk/rkward/tests/distributions/RKTestStandard.shapiro_wilk_test.rkcommands.R
    trunk/rkward/tests/distributions/RKTestStandard.shapiro_wilk_test.rkout
    trunk/rkward/tests/distributions.R

Added: trunk/rkward/tests/distributions/RKTestStandard.ad_test.rkcommands.R
===================================================================
--- trunk/rkward/tests/distributions/RKTestStandard.ad_test.rkcommands.R	                        (rev 0)
+++ trunk/rkward/tests/distributions/RKTestStandard.ad_test.rkcommands.R	2009-09-23 15:35:35 UTC (rev 2655)
@@ -0,0 +1,24 @@
+local({
+## Prepare
+require(nortest)
+## Compute
+vars <- list (substitute (rock[["shape"]]), substitute (rock[["perm"]]))
+results <- data.frame ('Variable Name'=rep (NA, length (vars)), check.names=FALSE)
+for (i in 1:length (vars)) {
+	results[i, 'Variable Name'] <- rk.get.description (vars[[i]], is.substitute=TRUE)
+	var <- eval (vars[[i]], envir=globalenv ())
+	results[i, 'Length'] <- length (var)
+	results[i, 'NAs'] <- sum (is.na(var))
+	try ({
+		test <- ad.test (var)
+		results[i, 'Statistic'] <- paste (names (test$statistic), test$statistic, sep=" = ")
+		results[i, 'p-value'] <- test$p.value
+	})
+}
+## Print result
+rk.header ("Anderson-Darling Normality Test")
+
+rk.results (results)
+})
+.rk.rerun.plugin.link(plugin="rkward::ad_test", settings="length.state=1\nx.available=rock[[\\\"shape\\\"]]\\nrock[[\\\"perm\\\"]]", label="Run again")
+.rk.make.hr()

Added: trunk/rkward/tests/distributions/RKTestStandard.ad_test.rkout
===================================================================
--- trunk/rkward/tests/distributions/RKTestStandard.ad_test.rkout	                        (rev 0)
+++ trunk/rkward/tests/distributions/RKTestStandard.ad_test.rkout	2009-09-23 15:35:35 UTC (rev 2655)
@@ -0,0 +1,7 @@
+<h1>Anderson-Darling Normality Test</h1>
+DATE<br>
+<table border="1">
+<tr><td>Variable Name</td><td>Length</td><td>NAs</td><td>Statistic</td><td>p-value</td></tr>
+<tr><td>shape</td><td>48</td><td>0</td><td>A = 1.41372513181145</td><td>0.0010355</td></tr>
+<tr><td>perm</td><td>48</td><td>0</td><td>A = 3.99184371555789</td><td>4.2977e-10</td></tr>
+</table>

Added: trunk/rkward/tests/distributions/RKTestStandard.beta_clt.rkcommands.R
===================================================================
--- trunk/rkward/tests/distributions/RKTestStandard.beta_clt.rkcommands.R	                        (rev 0)
+++ trunk/rkward/tests/distributions/RKTestStandard.beta_clt.rkcommands.R	2009-09-23 15:35:35 UTC (rev 2655)
@@ -0,0 +1,28 @@
+local({
+## Prepare
+## Compute
+## Print result
+# parameters:
+shape1 <- 2.00000000; shape2 <- 2.00000000;
+# mean and variances of the distribution of sample averages:
+avg.exp <- shape1/(shape1 + shape2);
+avg.var <- (shape1*shape2/((shape1+shape2)^2*(shape1+shape2+1)))/10;
+# generate the entire data:
+data <- matrix(rbeta(n=10000, shape1=shape1, shape2=shape2), nrow=10);
+# get the sample averages:
+avg <- colMeans(data);
+# generate random normal samples:
+normX <- seq(from=min(avg), to=max(avg), length=1000);
+normY <- dnorm (normX, mean = avg.exp, sd = sqrt(avg.var));
+dist.hist <- hist(avg, plot=FALSE, breaks="Sturges");
+# calculate the ylims appropriately:
+ylim <- c(0,max(c(dist.hist$density, normY)));
+rk.graph.on ()
+try ({
+	plot(dist.hist, ylim=ylim, freq=FALSE, labels=TRUE, lty="solid", density=-1, col="azure", xlab="Sample Averages", main="Beta")
+	lines (x=normX, y=normY, type="l", col="red")
+})
+rk.graph.off ()
+})
+.rk.rerun.plugin.link(plugin="rkward::plot_beta_clt", settings="a.real=2.00000000\nb.real=2.00000000\ndrawnorm.state=1\nfunction.string=hist\nhistogram_opt.addtoplot.state=\nhistogram_opt.barlabels.state=1\nhistogram_opt.density.real=-1.000000\nhistogram_opt.doborder.state=1\nhistogram_opt.freq.state=0\nhistogram_opt.histbordercol.color.string=\nhistogram_opt.histbreaksFunction.string=Sturges\nhistogram_opt.histfillcol.color.string=azure\nhistogram_opt.histlinetype.string=solid\nhistogram_opt.rightclosed.state=1\nhistogram_opt.usefillcol.state=1\nnAvg.real=10.000000\nnDist.real=1000.000000\nnormlinecol.color.string=red\nnormpointtype.string=l\nplotoptions.add_grid.state=0\nplotoptions.asp.real=0.00000000\nplotoptions.main.text=\nplotoptions.pointcolor.color.string=\nplotoptions.pointtype.string=\nplotoptions.sub.text=\nplotoptions.xaxt.state=\nplotoptions.xlab.text=\nplotoptions.xlog.state=\nplotoptions.xmaxvalue.text=\nplotoptions.xminvalue.text=\nplotoptions.yaxt.state=\nplotoptions.ylab.text=\nplotoptions.ylog.state=\nplotoptions.ymaxvalue.text=\nplotoptions.yminvalue.text=\nscalenorm.state=0", label="Run again")
+.rk.make.hr()

Added: trunk/rkward/tests/distributions/RKTestStandard.beta_clt.rkout
===================================================================
--- trunk/rkward/tests/distributions/RKTestStandard.beta_clt.rkout	                        (rev 0)
+++ trunk/rkward/tests/distributions/RKTestStandard.beta_clt.rkout	2009-09-23 15:35:35 UTC (rev 2655)
@@ -0,0 +1 @@
+<img src="graph.png" width="480" height="480"><br>

Added: trunk/rkward/tests/distributions/RKTestStandard.beta_probabilities.rkcommands.R
===================================================================
--- trunk/rkward/tests/distributions/RKTestStandard.beta_probabilities.rkcommands.R	                        (rev 0)
+++ trunk/rkward/tests/distributions/RKTestStandard.beta_probabilities.rkcommands.R	2009-09-23 15:35:35 UTC (rev 2655)
@@ -0,0 +1,20 @@
+local({
+## Prepare
+## Compute
+result <- (pbeta (q = c (0.95), shape1 = 1.00000000, shape2 = 1.00000000, ncp = 0.00000000, lower.tail=TRUE, log.p = FALSE))
+## Print result
+rk.header ("Beta probability", list ("Vector of quantiles", "c (0.95)", "Shape 1", "1.00000000", "Shape 2", "1.00000000", "non-centrality parameter (ncp)", "0.00000000", "Tail", "lower.tail=TRUE", "Probabilities p are given as", "log.p = FALSE"));
+rk.results (result, titles="Beta probability")
+})
+.rk.rerun.plugin.link(plugin="rkward::beta_probabilities", settings="logp.string=log.p = FALSE\nncp.real=0.00000000\nq.text=0.95\nshape1.real=1.00000000\nshape2.real=1.00000000\ntail.string=lower.tail=TRUE", label="Run again")
+.rk.make.hr()
+local({
+## Prepare
+## Compute
+result <- (pbeta (q = c (0.96), shape1 = 1.01000000, shape2 = 1.01000000, ncp = 0.02000000, lower.tail=FALSE, log.p = TRUE))
+## Print result
+rk.header ("Beta probability", list ("Vector of quantiles", "c (0.96)", "Shape 1", "1.01000000", "Shape 2", "1.01000000", "non-centrality parameter (ncp)", "0.02000000", "Tail", "lower.tail=FALSE", "Probabilities p are given as", "log.p = TRUE"));
+rk.results (result, titles="Beta probability")
+})
+.rk.rerun.plugin.link(plugin="rkward::beta_probabilities", settings="logp.string=log.p = TRUE\nncp.real=0.02000000\nq.text=0.96\nshape1.real=1.01000000\nshape2.real=1.01000000\ntail.string=lower.tail=FALSE", label="Run again")
+.rk.make.hr()

Added: trunk/rkward/tests/distributions/RKTestStandard.beta_probabilities.rkout
===================================================================
--- trunk/rkward/tests/distributions/RKTestStandard.beta_probabilities.rkout	                        (rev 0)
+++ trunk/rkward/tests/distributions/RKTestStandard.beta_probabilities.rkout	2009-09-23 15:35:35 UTC (rev 2655)
@@ -0,0 +1,21 @@
+<h1>Beta probability</h1>
+<h2>Parameters</h2>
+<ul><li>Vector of quantiles: c (0.95)</li>
+<li>Shape 1: 1.00000000</li>
+<li>Shape 2: 1.00000000</li>
+<li>non-centrality parameter (ncp): 0.00000000</li>
+<li>Tail: lower.tail=TRUE</li>
+<li>Probabilities p are given as: log.p = FALSE</li>
+</ul>
+DATE<br>
+<h3>Beta probability: 0.95</h3><h1>Beta probability</h1>
+<h2>Parameters</h2>
+<ul><li>Vector of quantiles: c (0.96)</li>
+<li>Shape 1: 1.01000000</li>
+<li>Shape 2: 1.01000000</li>
+<li>non-centrality parameter (ncp): 0.02000000</li>
+<li>Tail: lower.tail=FALSE</li>
+<li>Probabilities p are given as: log.p = TRUE</li>
+</ul>
+DATE<br>
+<h3>Beta probability: -3.2317</h3>
\ No newline at end of file

Added: trunk/rkward/tests/distributions/RKTestStandard.beta_quantiles.rkcommands.R
===================================================================
--- trunk/rkward/tests/distributions/RKTestStandard.beta_quantiles.rkcommands.R	                        (rev 0)
+++ trunk/rkward/tests/distributions/RKTestStandard.beta_quantiles.rkcommands.R	2009-09-23 15:35:35 UTC (rev 2655)
@@ -0,0 +1,20 @@
+local({
+## Prepare
+## Compute
+result <- (qbeta (p = c (0.95), shape1 = 1.00000000, shape2 = 1.00000000, ncp = 0.00000000, lower.tail=TRUE, log.p = FALSE))
+## Print result
+rk.header ("Beta quantiles", list ("Vector of probabilities", "c (0.95)", "Shape 1", "1.00000000", "Shape 2", "1.00000000", "non-centrality parameter (ncp)", "0.00000000", "Tail", "lower.tail=TRUE", "Probabilities p are given as", "log.p = FALSE"));
+rk.results (result, titles="Beta quantiles")
+})
+.rk.rerun.plugin.link(plugin="rkward::beta_quantiles", settings="logp.string=log.p = FALSE\nncp.real=0.00000000\np.text=0.95\nshape1.real=1.00000000\nshape2.real=1.00000000\ntail.string=lower.tail=TRUE", label="Run again")
+.rk.make.hr()
+local({
+## Prepare
+## Compute
+result <- (qbeta (p = c (-1), shape1 = 1.04000000, shape2 = 1.03000000, ncp = 0.08000000, lower.tail=FALSE, log.p = TRUE))
+## Print result
+rk.header ("Beta quantiles", list ("Vector of probabilities", "c (-1)", "Shape 1", "1.04000000", "Shape 2", "1.03000000", "non-centrality parameter (ncp)", "0.08000000", "Tail", "lower.tail=FALSE", "Probabilities p are given as", "log.p = TRUE"));
+rk.results (result, titles="Beta quantiles")
+})
+.rk.rerun.plugin.link(plugin="rkward::beta_quantiles", settings="logp.string=log.p = TRUE\nncp.real=0.08000000\np.text=-1\nshape1.real=1.04000000\nshape2.real=1.03000000\ntail.string=lower.tail=FALSE", label="Run again")
+.rk.make.hr()

Added: trunk/rkward/tests/distributions/RKTestStandard.beta_quantiles.rkout
===================================================================
--- trunk/rkward/tests/distributions/RKTestStandard.beta_quantiles.rkout	                        (rev 0)
+++ trunk/rkward/tests/distributions/RKTestStandard.beta_quantiles.rkout	2009-09-23 15:35:35 UTC (rev 2655)
@@ -0,0 +1,21 @@
+<h1>Beta quantiles</h1>
+<h2>Parameters</h2>
+<ul><li>Vector of probabilities: c (0.95)</li>
+<li>Shape 1: 1.00000000</li>
+<li>Shape 2: 1.00000000</li>
+<li>non-centrality parameter (ncp): 0.00000000</li>
+<li>Tail: lower.tail=TRUE</li>
+<li>Probabilities p are given as: log.p = FALSE</li>
+</ul>
+DATE<br>
+<h3>Beta quantiles: 0.95</h3><h1>Beta quantiles</h1>
+<h2>Parameters</h2>
+<ul><li>Vector of probabilities: c (-1)</li>
+<li>Shape 1: 1.04000000</li>
+<li>Shape 2: 1.03000000</li>
+<li>non-centrality parameter (ncp): 0.08000000</li>
+<li>Tail: lower.tail=FALSE</li>
+<li>Probabilities p are given as: log.p = TRUE</li>
+</ul>
+DATE<br>
+<h3>Beta quantiles: 0.6414</h3>
\ No newline at end of file

Added: trunk/rkward/tests/distributions/RKTestStandard.cvm_test.rkcommands.R
===================================================================
--- trunk/rkward/tests/distributions/RKTestStandard.cvm_test.rkcommands.R	                        (rev 0)
+++ trunk/rkward/tests/distributions/RKTestStandard.cvm_test.rkcommands.R	2009-09-23 15:35:35 UTC (rev 2655)
@@ -0,0 +1,23 @@
+local({
+## Prepare
+require(nortest)
+## Compute
+vars <- list (substitute (rock[["shape"]]), substitute (rock[["perm"]]))
+results <- data.frame ('Variable Name'=rep (NA, length (vars)), check.names=FALSE)
+for (i in 1:length (vars)) {
+	results[i, 'Variable Name'] <- rk.get.description (vars[[i]], is.substitute=TRUE)
+	var <- eval (vars[[i]], envir=globalenv ())
+	results[i, 'Length'] <- length (var)
+	results[i, 'NAs'] <- sum (is.na(var))
+	try ({
+		test <- cvm.test (var)
+		results[i, 'Statistic'] <- paste (names (test$statistic), test$statistic, sep=" = ")
+		results[i, 'p-value'] <- test$p.value
+	})
+}
+## Print result
+rk.header ("Cramer-von Mises Normality Test")
+rk.results (results)
+})
+.rk.rerun.plugin.link(plugin="rkward::cvm_test", settings="length.state=1\nx.available=rock[[\\\"shape\\\"]]\\nrock[[\\\"perm\\\"]]", label="Run again")
+.rk.make.hr()

Added: trunk/rkward/tests/distributions/RKTestStandard.cvm_test.rkout
===================================================================
--- trunk/rkward/tests/distributions/RKTestStandard.cvm_test.rkout	                        (rev 0)
+++ trunk/rkward/tests/distributions/RKTestStandard.cvm_test.rkout	2009-09-23 15:35:35 UTC (rev 2655)
@@ -0,0 +1,7 @@
+<h1>Cramer-von Mises Normality Test</h1>
+DATE<br>
+<table border="1">
+<tr><td>Variable Name</td><td>Length</td><td>NAs</td><td>Statistic</td><td>p-value</td></tr>
+<tr><td>shape</td><td>48</td><td>0</td><td>W = 0.232643041678355</td><td>0.0019712</td></tr>
+<tr><td>perm</td><td>48</td><td>0</td><td>W = 0.72561839750325</td><td>3.7586e-08</td></tr>
+</table>

Added: trunk/rkward/tests/distributions/RKTestStandard.jb_test.rkcommands.R
===================================================================
--- trunk/rkward/tests/distributions/RKTestStandard.jb_test.rkcommands.R	                        (rev 0)
+++ trunk/rkward/tests/distributions/RKTestStandard.jb_test.rkcommands.R	2009-09-23 15:35:35 UTC (rev 2655)
@@ -0,0 +1,25 @@
+local({
+## Prepare
+require(tseries)
+## Compute
+vars <- list (substitute (rock[["shape"]]), substitute (rock[["perm"]]))
+results <- data.frame ('Variable Name'=rep (NA, length (vars)), check.names=FALSE)
+for (i in 1:length (vars)) {
+	results[i, 'Variable Name'] <- rk.get.description (vars[[i]], is.substitute=TRUE)
+	var <- eval (vars[[i]], envir=globalenv ())
+	results[i, 'Length'] <- length (var)
+	results[i, 'NAs'] <- sum (is.na(var))
+	var <- na.omit (var)
+	try ({
+		test <- jarque.bera.test (var)
+		results[i, 'Statistic'] <- paste (names (test$statistic), test$statistic, sep=" = ")
+		results[i, 'df'] <- test$parameter
+		results[i, 'p-value'] <- test$p.value
+	})
+}
+## Print result
+rk.header ("Jarque-Bera Normality Test", parameters=list ("Exclude NAs", "YES"))
+rk.results (results)
+})
+.rk.rerun.plugin.link(plugin="rkward::jb_test", settings="excludenas.state=1\nlength.state=1\nx.available=rock[[\\\"shape\\\"]]\\nrock[[\\\"perm\\\"]]", label="Run again")
+.rk.make.hr()

Added: trunk/rkward/tests/distributions/RKTestStandard.jb_test.rkout
===================================================================
--- trunk/rkward/tests/distributions/RKTestStandard.jb_test.rkout	                        (rev 0)
+++ trunk/rkward/tests/distributions/RKTestStandard.jb_test.rkout	2009-09-23 15:35:35 UTC (rev 2655)
@@ -0,0 +1,10 @@
+<h1>Jarque-Bera Normality Test</h1>
+<h2>Parameters</h2>
+<ul><li>Exclude NAs: YES</li>
+</ul>
+DATE<br>
+<table border="1">
+<tr><td>Variable Name</td><td>Length</td><td>NAs</td><td>Statistic</td><td>df</td><td>p-value</td></tr>
+<tr><td>shape</td><td>48</td><td>0</td><td>X-squared = 13.4020992267589</td><td>2</td><td>0.0012296</td></tr>
+<tr><td>perm</td><td>48</td><td>0</td><td>X-squared = 5.95075906694729</td><td>2</td><td>0.051028</td></tr>
+</table>

Added: trunk/rkward/tests/distributions/RKTestStandard.lillie_test.rkcommands.R
===================================================================
--- trunk/rkward/tests/distributions/RKTestStandard.lillie_test.rkcommands.R	                        (rev 0)
+++ trunk/rkward/tests/distributions/RKTestStandard.lillie_test.rkcommands.R	2009-09-23 15:35:35 UTC (rev 2655)
@@ -0,0 +1,23 @@
+local({
+## Prepare
+require (nortest)
+## Compute
+vars <- list (substitute (rock[["shape"]]), substitute (rock[["perm"]]))
+results <- data.frame ('Variable Name'=rep (NA, length (vars)), check.names=FALSE)
+for (i in 1:length (vars)) {
+	results[i, 'Variable Name'] <- rk.get.description (vars[[i]], is.substitute=TRUE)
+	var <- eval (vars[[i]], envir=globalenv())
+	results[i, 'Length'] <- length (var)
+	results[i, 'NAs'] <- sum (is.na(var))
+	try ({
+		test <- lillie.test (var)
+		results[i, 'Statistic'] <- paste (names (test$statistic), test$statistic, sep=" = ")
+		results[i, 'p-value'] <- test$p.value
+	})
+}
+## Print result
+rk.header ("Lilliefors (Kolmogorov-Smirnov) Normality test")
+rk.results (results)
+})
+.rk.rerun.plugin.link(plugin="rkward::lillie_test", settings="length.state=1\nx.available=rock[[\\\"shape\\\"]]\\nrock[[\\\"perm\\\"]]", label="Run again")
+.rk.make.hr()

Added: trunk/rkward/tests/distributions/RKTestStandard.lillie_test.rkout
===================================================================
--- trunk/rkward/tests/distributions/RKTestStandard.lillie_test.rkout	                        (rev 0)
+++ trunk/rkward/tests/distributions/RKTestStandard.lillie_test.rkout	2009-09-23 15:35:35 UTC (rev 2655)
@@ -0,0 +1,7 @@
+<h1>Lilliefors (Kolmogorov-Smirnov) Normality test</h1>
+DATE<br>
+<table border="1">
+<tr><td>Variable Name</td><td>Length</td><td>NAs</td><td>Statistic</td><td>p-value</td></tr>
+<tr><td>shape</td><td>48</td><td>0</td><td>D = 0.169786656172250</td><td>0.0013779</td></tr>
+<tr><td>perm</td><td>48</td><td>0</td><td>D = 0.317208078488319</td><td>2.5296e-13</td></tr>
+</table>

Added: trunk/rkward/tests/distributions/RKTestStandard.pearson_test.rkcommands.R
===================================================================
--- trunk/rkward/tests/distributions/RKTestStandard.pearson_test.rkcommands.R	                        (rev 0)
+++ trunk/rkward/tests/distributions/RKTestStandard.pearson_test.rkcommands.R	2009-09-23 15:35:35 UTC (rev 2655)
@@ -0,0 +1,52 @@
+local({
+## Prepare
+require(nortest)
+## Compute
+vars <- list (substitute (rock[["shape"]]), substitute (rock[["perm"]]))
+results <- data.frame ('Variable Name'=rep (NA, length (vars)), check.names=FALSE)
+for (i in 1:length (vars)) {
+	results[i, 'Variable Name'] <- rk.get.description (vars[[i]], is.substitute=TRUE)
+	var <- eval (vars[[i]], envir=globalenv ())
+	results[i, 'Length'] <- length (var)
+	results[i, 'NAs'] <- sum (is.na(var))
+	try ({
+		test <- pearson.test (var, adjust = TRUE)
+		results[i, 'Statistic'] <- paste (names (test$statistic), test$statistic, sep=" = ")
+		results[i, 'p-value'] <- test$p.value
+		results[i, 'number of classes'] <- test$n.classes
+		results[i, 'degrees of freedom'] <- test$df
+	})
+}
+## Print result
+rk.header ("Pearson chi-square Normality Test",
+	parameters=list ("chi-square distribution with n.classes-3 df (TRUE) or chi-square distribution with n.classes-1 df (FALSE)", "adjust = TRUE"))
+rk.results (results)
+})
+.rk.rerun.plugin.link(plugin="rkward::pearson_test", settings="adjust.string=adjust = TRUE\nlength.state=1\nx.available=rock[[\\\"shape\\\"]]\\nrock[[\\\"perm\\\"]]", label="Run again")
+.rk.make.hr()
+local({
+## Prepare
+require(nortest)
+## Compute
+vars <- list (substitute (rock[["shape"]]), substitute (rock[["perm"]]))
+results <- data.frame ('Variable Name'=rep (NA, length (vars)), check.names=FALSE)
+for (i in 1:length (vars)) {
+	results[i, 'Variable Name'] <- rk.get.description (vars[[i]], is.substitute=TRUE)
+	var <- eval (vars[[i]], envir=globalenv ())
+	results[i, 'Length'] <- length (var)
+	results[i, 'NAs'] <- sum (is.na(var))
+	try ({
+		test <- pearson.test (var, adjust = FALSE)
+		results[i, 'Statistic'] <- paste (names (test$statistic), test$statistic, sep=" = ")
+		results[i, 'p-value'] <- test$p.value
+		results[i, 'number of classes'] <- test$n.classes
+		results[i, 'degrees of freedom'] <- test$df
+	})
+}
+## Print result
+rk.header ("Pearson chi-square Normality Test",
+	parameters=list ("chi-square distribution with n.classes-3 df (TRUE) or chi-square distribution with n.classes-1 df (FALSE)", "adjust = FALSE"))
+rk.results (results)
+})
+.rk.rerun.plugin.link(plugin="rkward::pearson_test", settings="adjust.string=adjust = FALSE\nlength.state=1\nx.available=rock[[\\\"shape\\\"]]\\nrock[[\\\"perm\\\"]]", label="Run again")
+.rk.make.hr()

Added: trunk/rkward/tests/distributions/RKTestStandard.pearson_test.rkout
===================================================================
--- trunk/rkward/tests/distributions/RKTestStandard.pearson_test.rkout	                        (rev 0)
+++ trunk/rkward/tests/distributions/RKTestStandard.pearson_test.rkout	2009-09-23 15:35:35 UTC (rev 2655)
@@ -0,0 +1,20 @@
+<h1>Pearson chi-square Normality Test</h1>
+<h2>Parameters</h2>
+<ul><li>chi-square distribution with n.classes-3 df (TRUE) or chi-square distribution with n.classes-1 df (FALSE): adjust = TRUE</li>
+</ul>
+DATE<br>
+<table border="1">
+<tr><td>Variable Name</td><td>Length</td><td>NAs</td><td>Statistic</td><td>p-value</td><td>number of classes</td><td>degrees of freedom</td></tr>
+<tr><td>shape</td><td>48</td><td>0</td><td>P = 15.3333333333333</td><td>0.031956</td><td>10</td><td>7</td></tr>
+<tr><td>perm</td><td>48</td><td>0</td><td>P = 72</td><td>5.82e-13</td><td>10</td><td>7</td></tr>
+</table>
+<h1>Pearson chi-square Normality Test</h1>
+<h2>Parameters</h2>
+<ul><li>chi-square distribution with n.classes-3 df (TRUE) or chi-square distribution with n.classes-1 df (FALSE): adjust = FALSE</li>
+</ul>
+DATE<br>
+<table border="1">
+<tr><td>Variable Name</td><td>Length</td><td>NAs</td><td>Statistic</td><td>p-value</td><td>number of classes</td><td>degrees of freedom</td></tr>
+<tr><td>shape</td><td>48</td><td>0</td><td>P = 15.3333333333333</td><td>0.082177</td><td>10</td><td>9</td></tr>
+<tr><td>perm</td><td>48</td><td>0</td><td>P = 72</td><td>6.1643e-12</td><td>10</td><td>9</td></tr>
+</table>

Added: trunk/rkward/tests/distributions/RKTestStandard.plot_beta_distribution.rkcommands.R
===================================================================
--- trunk/rkward/tests/distributions/RKTestStandard.plot_beta_distribution.rkcommands.R	                        (rev 0)
+++ trunk/rkward/tests/distributions/RKTestStandard.plot_beta_distribution.rkcommands.R	2009-09-23 15:35:35 UTC (rev 2655)
@@ -0,0 +1,14 @@
+local({
+## Prepare
+## Compute
+## Print result
+rk.header ("Beta distribution function", list ("Number of Observations", "100", "Lower quantile", "0.00000000", "Upper quantile", "1.00000000", "Shape1", "2.00000000", "Shape2", "2.00000000", "Non-centrality parameter", "0.00000000", "Scale", "logarithmic", "Tail","Lower", "Function", "pbeta"));
+
+rk.graph.on ()
+try ({
+	curve (pbeta(x, shape1=2.00000000, shape2=2.00000000, ncp=0.00000000, log.p=TRUE, lower.tail = TRUE), from=0.00000000, to=1.00000000, n=100)
+})
+rk.graph.off ()
+})
+.rk.rerun.plugin.link(plugin="rkward::plot_beta_distribution", settings="a.real=2.00000000\nb.real=2.00000000\nfunction.string=p\nlog.state=1\nlower.state=1\nmax.real=1.00000000\nmin.real=0.00000000\nn.real=100.000000\nncp.real=0.00000000\nplotoptions.add_grid.state=0\nplotoptions.asp.real=0.00000000\nplotoptions.main.text=\nplotoptions.pointcolor.color.string=\nplotoptions.pointtype.string=\nplotoptions.sub.text=\nplotoptions.xaxt.state=\nplotoptions.xlab.text=\nplotoptions.xlog.state=\nplotoptions.xmaxvalue.text=\nplotoptions.xminvalue.text=\nplotoptions.yaxt.state=\nplotoptions.ylab.text=\nplotoptions.ylog.state=\nplotoptions.ymaxvalue.text=\nplotoptions.yminvalue.text=", label="Run again")
+.rk.make.hr()

Added: trunk/rkward/tests/distributions/RKTestStandard.plot_beta_distribution.rkout
===================================================================
--- trunk/rkward/tests/distributions/RKTestStandard.plot_beta_distribution.rkout	                        (rev 0)
+++ trunk/rkward/tests/distributions/RKTestStandard.plot_beta_distribution.rkout	2009-09-23 15:35:35 UTC (rev 2655)
@@ -0,0 +1,14 @@
+<h1>Beta distribution function</h1>
+<h2>Parameters</h2>
+<ul><li>Number of Observations: 100</li>
+<li>Lower quantile: 0.00000000</li>
+<li>Upper quantile: 1.00000000</li>
+<li>Shape1: 2.00000000</li>
+<li>Shape2: 2.00000000</li>
+<li>Non-centrality parameter: 0.00000000</li>
+<li>Scale: logarithmic</li>
+<li>Tail: Lower</li>
+<li>Function: pbeta</li>
+</ul>
+DATE<br>
+<img src="graph.png" width="480" height="480"><br>

Added: trunk/rkward/tests/distributions/RKTestStandard.sf_test.rkcommands.R
===================================================================
--- trunk/rkward/tests/distributions/RKTestStandard.sf_test.rkcommands.R	                        (rev 0)
+++ trunk/rkward/tests/distributions/RKTestStandard.sf_test.rkcommands.R	2009-09-23 15:35:35 UTC (rev 2655)
@@ -0,0 +1,24 @@
+local({
+## Prepare
+require(nortest)
+## Compute
+vars <- list (substitute (rock[["shape"]]), substitute (rock[["perm"]]))
+results <- data.frame ('Variable Name'=rep (NA, length (vars)), check.names=FALSE)
+for (i in 1:length (vars)) {
+	results[i, 'Variable Name'] <- rk.get.description (vars[[i]], is.substitute=TRUE)
+	var <- eval (vars[[i]], envir=globalenv())
+	results[i, 'Length'] <- length (var)
+	results[i, 'NAs'] <- sum (is.na(var))
+	try ({
+		test <- sf.test (var)
+		results[i, 'Statistic'] <- paste (names (test$statistic), test$statistic, sep=" = ")
+		results[i, 'p-value'] <- test$p.value
+	})
+}
+## Print result
+	
+rk.header ("Shapiro-Francia Normality Test")
+rk.results (results)
+})
+.rk.rerun.plugin.link(plugin="rkward::sf_test", settings="length.state=1\nx.available=rock[[\\\"shape\\\"]]\\nrock[[\\\"perm\\\"]]", label="Run again")
+.rk.make.hr()

Added: trunk/rkward/tests/distributions/RKTestStandard.sf_test.rkout
===================================================================
--- trunk/rkward/tests/distributions/RKTestStandard.sf_test.rkout	                        (rev 0)
+++ trunk/rkward/tests/distributions/RKTestStandard.sf_test.rkout	2009-09-23 15:35:35 UTC (rev 2655)
@@ -0,0 +1,7 @@
+<h1>Shapiro-Francia Normality Test</h1>
+DATE<br>
+<table border="1">
+<tr><td>Variable Name</td><td>Length</td><td>NAs</td><td>Statistic</td><td>p-value</td></tr>
+<tr><td>shape</td><td>48</td><td>0</td><td>W = 0.903716033135835</td><td>0.0014382</td></tr>
+<tr><td>perm</td><td>48</td><td>0</td><td>W = 0.814665259804222</td><td>1.2468e-05</td></tr>
+</table>

Added: trunk/rkward/tests/distributions/RKTestStandard.shapiro_wilk_test.rkcommands.R
===================================================================
--- trunk/rkward/tests/distributions/RKTestStandard.shapiro_wilk_test.rkcommands.R	                        (rev 0)
+++ trunk/rkward/tests/distributions/RKTestStandard.shapiro_wilk_test.rkcommands.R	2009-09-23 15:35:35 UTC (rev 2655)
@@ -0,0 +1,22 @@
+local({
+## Prepare
+## Compute
+vars <- list (substitute (rock[["shape"]]), substitute (rock[["perm"]]))
+results <- data.frame ('Variable Name'=rep (NA, length (vars)), check.names=FALSE)
+for (i in 1:length (vars)) {
+	results[i, 'Variable Name'] <- rk.get.description (vars[[i]], is.substitute=TRUE)
+	var <- eval (vars[[i]], envir=globalenv())
+	results[i, 'Length'] <- length (var)
+	results[i, 'NAs'] <- sum (is.na(var))
+	try ({
+		test <- shapiro.test (var)
+		results[i, 'Statistic'] <- paste (names (test$statistic), test$statistic, sep=" = ")
+		results[i, 'p-value'] <- test$p.value
+	})
+}
+## Print result
+rk.header ("Shapiro-Wilk Normality Test")
+rk.results (results)
+})
+.rk.rerun.plugin.link(plugin="rkward::shapiro_test", settings="length.state=1\nx.available=rock[[\\\"shape\\\"]]\\nrock[[\\\"perm\\\"]]", label="Run again")
+.rk.make.hr()

Added: trunk/rkward/tests/distributions/RKTestStandard.shapiro_wilk_test.rkout
===================================================================
--- trunk/rkward/tests/distributions/RKTestStandard.shapiro_wilk_test.rkout	                        (rev 0)
+++ trunk/rkward/tests/distributions/RKTestStandard.shapiro_wilk_test.rkout	2009-09-23 15:35:35 UTC (rev 2655)
@@ -0,0 +1,7 @@
+<h1>Shapiro-Wilk Normality Test</h1>
+DATE<br>
+<table border="1">
+<tr><td>Variable Name</td><td>Length</td><td>NAs</td><td>Statistic</td><td>p-value</td></tr>
+<tr><td>shape</td><td>48</td><td>0</td><td>W = 0.904069181319154</td><td>0.00085307</td></tr>
+<tr><td>perm</td><td>48</td><td>0</td><td>W = 0.803262753495175</td><td>1.5417e-06</td></tr>
+</table>

Added: trunk/rkward/tests/distributions.R
===================================================================
--- trunk/rkward/tests/distributions.R	                        (rev 0)
+++ trunk/rkward/tests/distributions.R	2009-09-23 15:35:35 UTC (rev 2655)
@@ -0,0 +1,66 @@
+## intro
+# This should be the first line in each test suite file: Include the
+# test framework, unless already included (multiple inclusion would not
+# really do any harm either, though
+if (!isClass ("RKTestSuite")) source ("test_framework.R")
+
+## definition of the test suite
+suite <- new ("RKTestSuite", id="distributions",
+	# place here libraries that are required for *all* tests in this suite, or highly likely to be installed
+	libraries = c ("R2HTML", "datasets", "stats"),
+	# initCalls are run *before* any tests. Use this to set up the environment
+	initCalls = list (
+		function () {
+			data (rock)
+		}
+	## the tests
+	), tests = list (
+		new ("RKTest", id="shapiro_wilk_test", call=function () {
+			rk.call.plugin ("rkward::shapiro_test", length.state="1", x.available="rock[[\"shape\"]]\nrock[[\"perm\"]]", submit.mode="submit")
+		}),
+		new ("RKTest", id="ad_test", call=function () {
+			rk.call.plugin ("rkward::ad_test", length.state="1", x.available="rock[[\"shape\"]]\nrock[[\"perm\"]]", submit.mode="submit")
+		}, libraries=c("nortest")),
+		new ("RKTest", id="cvm_test", call=function () {
+			rk.call.plugin ("rkward::cvm_test", length.state="1", x.available="rock[[\"shape\"]]\nrock[[\"perm\"]]", submit.mode="submit")
+		}, libraries=c("nortest")),
+		new ("RKTest", id="pearson_test", call=function () {
+			rk.call.plugin ("rkward::pearson_test", adjust.string="adjust = TRUE", length.state="1", x.available="rock[[\"shape\"]]\nrock[[\"perm\"]]", submit.mode="submit")
+
+			rk.call.plugin ("rkward::pearson_test", adjust.string="adjust = FALSE", length.state="1", x.available="rock[[\"shape\"]]\nrock[[\"perm\"]]", submit.mode="submit")
+		}, libraries=c("nortest")),
+		new ("RKTest", id="sf_test", call=function () {
+			rk.call.plugin ("rkward::sf_test", length.state="1", x.available="rock[[\"shape\"]]\nrock[[\"perm\"]]", submit.mode="submit")
+		}, libraries=c("nortest")),
+		new ("RKTest", id="lillie_test", call=function () {
+			rk.call.plugin ("rkward::lillie_test", length.state="1", x.available="rock[[\"shape\"]]\nrock[[\"perm\"]]", submit.mode="submit")
+		}, libraries=c("nortest")),
+		new ("RKTest", id="jb_test", call=function () {
+			rk.call.plugin ("rkward::jb_test", excludenas.state="1", length.state="1", x.available="rock[[\"shape\"]]\nrock[[\"perm\"]]", submit.mode="submit")
+		}, libraries=c("tseries")),
+		new ("RKTest", id="beta_probabilities", call=function () {
+			rk.call.plugin ("rkward::beta_probabilities", logp.string="log.p = FALSE", ncp.real="0.00000000", q.text="0.95", shape1.real="1.00000000", shape2.real="1.00000000", tail.string="lower.tail=TRUE", submit.mode="submit")
+
+			rk.call.plugin ("rkward::beta_probabilities", logp.string="log.p = TRUE", ncp.real="0.02000000", q.text="0.96", shape1.real="1.01000000", shape2.real="1.01000000", tail.string="lower.tail=FALSE", submit.mode="submit")
+		}),
+		new ("RKTest", id="beta_quantiles", call=function () {
+			rk.call.plugin ("rkward::beta_quantiles", logp.string="log.p = FALSE", ncp.real="0.00000000", p.text="0.95", shape1.real="1.00000000", shape2.real="1.00000000", tail.string="lower.tail=TRUE", submit.mode="submit")
+
+			rk.call.plugin ("rkward::beta_quantiles", logp.string="log.p = TRUE", ncp.real="0.08000000", p.text="-1", shape1.real="1.04000000", shape2.real="1.03000000", tail.string="lower.tail=FALSE", submit.mode="submit")
+		}),
+		new ("RKTest", id="beta_clt", call=function () {
+			rk.call.plugin ("rkward::plot_beta_clt", a.real="2.00000000", b.real="2.00000000", drawnorm.state="1", function.string="hist", histogram_opt.addtoplot.state="", histogram_opt.barlabels.state="1", histogram_opt.density.real="-1.000000", histogram_opt.doborder.state="1", histogram_opt.freq.state="0", histogram_opt.histbordercol.color.string="", histogram_opt.histbreaksFunction.string="Sturges", histogram_opt.histfillcol.color.string="azure", histogram_opt.histlinetype.string="solid", histogram_opt.rightclosed.state="1", histogram_opt.usefillcol.state="1", nAvg.real="10.000000", nDist.real="1000.000000", normlinecol.color.string="red", normpointtype.string="l", plotoptions.add_grid.state="0", plotoptions.asp.real="0.00000000", plotoptions.main.text="", plotoptions.pointcolor.color.string="", plotoptions.pointtype.string="", plotoptions.sub.text="", plotoptions.xaxt.state="", plotoptions.xlab.text="", plotoptions.xlog.state="", plotoptions.xmaxvalue.text="", plotoptions.xminvalue.text="", plotoptions.yaxt.state="", plotoptions.ylab.text="", plotoptions.ylog.state="", plotoptions.ymaxvalue.text="", plotoptions.yminvalue.text="", scalenorm.state="0", submit.mode="submit")
+		}),
+		new ("RKTest", id="plot_beta_distribution", call=function () {
+			rk.call.plugin ("rkward::plot_beta_distribution", a.real="2.00000000", b.real="2.00000000", function.string="p", log.state="1", lower.state="1", max.real="1.00000000", min.real="0.00000000", n.real="100.000000", ncp.real="0.00000000", plotoptions.add_grid.state="0", plotoptions.asp.real="0.00000000", plotoptions.main.text="", plotoptions.pointcolor.color.string="", plotoptions.pointtype.string="", plotoptions.sub.text="", plotoptions.xaxt.state="", plotoptions.xlab.text="", plotoptions.xlog.state="", plotoptions.xmaxvalue.text="", plotoptions.xminvalue.text="", plotoptions.yaxt.state="", plotoptions.ylab.text="", plotoptions.ylog.state="", plotoptions.ymaxvalue.text="", plotoptions.yminvalue.text="", submit.mode="submit")
+		})
+	), postCalls = list (	# like initCalls: run after all tests to clean up.
+		function () {
+			suppressWarnings (rm (list=c (), envir=globalenv()))
+		}
+	)
+)
+
+## always store the result in "results" and print it
+results <- rktest.runRKTestSuite (suite)
+print (results)


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