Paul Johnson
2009-May-14  21:10 UTC
[Rd] will one of you help me advocate a change in t.test (patch attached)
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>
Paul Johnson
2009-May-15  16:38 UTC
[Rd] will one of you help me advocate a change in t.test (patch attached)
On Fri, May 15, 2009 at 10:05 AM, Kevin W <kw.statr at gmail.com> wrote:> My view from the sidelines.... > > I think you have done the right thing to include a patch, but you have > provided no justification for the patch in terms of why it would be useful. > > Sincerely, > > Kevin >Ah, I see. I thought it was obvious. I think users should be able to easily know the standard error when they do t.tests. People who do t-tests sometimes need to discuss their findings, and the standard error may be an important consideration. While one can (of course) recover the standard error by doing some division, it is inconvenient and, at least in the classroom, on the border of tedious. We allow regression printouts with several layers of redundant information-- b se t p We should not make it difficult for users to discern the standard error that is actually used in the t.test procedure? pj -- Paul E. Johnson Professor, Political Science 1541 Lilac Lane, Room 504 University of Kansas