[Rd] will one of you help me advocate a change in t.test (patch attached)

Paul Johnson pauljohn32 at gmail.com
Thu May 14 23:10:08 CEST 2009


I wish the t.test function in stats would return the standard error.
It would be nicer for students if R simply reported the standard error
used to calculate the t value.  I trolled for this in r-help and got
no answers, which I interpreted to mean that this is boring but
possibly not wrong.  Hopefully.

I believe only simple changes are needed.

In the source code src/library/stats/t.test.R file:

at the bottom of the first function,  where the return value list is set:

  rval <- list(statistic = tstat, parameter = df, p.value = pval,
        conf.int = cint, estimate = estimate, null.value = mu,
        alternative = alternative, method = method, data.name = dname)

I wish that   "stderr = stderr" could be inserted after "estimate = estimate".

I *believe* after studying the source code it is necessary to
introduce a name for the stderr element in the list.

names(stderr) <- "standard error"

If I could get that much put in, I would be happy. But to make this
really helpful, the htest.R file's "print.htest" function needs to
check for the presence of stderr. Based on what htest.R has now, I
think it needs:


  if(!is.null(x$stderr))
	out <- c(out, paste(names(x$stderr), "=",
			    format(round(x$stderr, 3))))


I am attaching a patch file that will make these changes if it is
applied to the R-2.9.0 tree.

pj


-- 
Paul E. Johnson
Professor, Political Science
1541 Lilac Lane, Room 504
University of Kansas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: t.test-patch.diff
Type: text/x-patch
Size: 1886 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-devel/attachments/20090514/14b13e28/attachment.bin>


More information about the R-devel mailing list