Skip to content

Wilcox paired test error message

6 messages · ruth parker, Sarah Goslee, David Winsemius +1 more

#
Hi,

If you're doing exactly as described below, then you need to add the
data argument to wilcox.test so R knows where to find beforesmall and
aftersmall. But if so, that's a rather uninformative error message.

Saraj
On Sun, Jun 23, 2013 at 2:34 PM, ruth parker <parkeractonruth at gmail.com> wrote:

  
    
#
On Jun 23, 2013, at 11:34 AM, ruth parker wrote:

            
In this instance, you are working with a matrix, so you need supply the two column vectors explicitly:

----------

wilcox.test( dat[ ,'beforesmall'] , dat[ , 'aftersmall'], paired=T)

------------

And if you are using attach() and haven't told us, then STOP DOING THAT. (It won't work with matrices and it creates confusion among the inexperienced people who use it most often.)
--
#
On Jun 23, 2013, at 22:30 , Sarah Goslee wrote:

            
Not really, if you use the formula interface, the rhs is supposed to be the grouping, as in 

wilcox.test(extra ~ group, data=sleep, paired=TRUE)

so it's telling you that "aftersmall" does not describe two groups.

(It is unfortunate, though, that we don't have a formula interface to the parallel-vector data layout for paired tests. That is the common case, the sleep data set is a rather rare exception. A formula specification for paired columns has been talked about; something like cbind(before, after) ~ 1 should be workable, but nothing has materialized to date.)

-pd

  
    
#
G'morning.
On Mon, Jun 24, 2013 at 2:22 AM, peter dalgaard <pdalgd at gmail.com> wrote:
Yep, sorry. That was actually my first thought, but then I misread the
helpfile.

You do still need the data argument, though. :)

Sarah

  
    
#
On Jun 24, 2013, at 15:21 , Sarah Goslee wrote:

            
-- or a preceding attach(), which at least some of us still use occasionally despite its dangers. For paired tests, it doesn't actually work to use data=, you need

with(mydata, t.test(beforesmall, aftersmall, paired=TRUE))

-pd