Re: Did behavior of "paired" argument in t.test() change?

Robert Baer via R-help <[email protected]>
Newsgroups gmane.comp.lang.r.general
Message-ID <[email protected]>
Thanks Ivan and Peter.

I had been extolling the virtues of long format to my students, and 
mentioning some its shortcomings with paired data like paired t.test. I 
then went off script (bad idea) to explain a workaround and fell down 
the rabbit hole. Thebug report 
<https://bugs.r-project.org/show_bug.cgi?id=14359> 14359 on this issue 
was first started in 2010 (several years after I had started using R), 
and finally resulted in a code change only in April 2024 - all of those 
years I was blissfully unaware and had developed some bad habits with 
regard to brittle order assumptions  ;-)

Even after rechecking ?t.test I was not certain that I was remembering 
the old behavior correctly, so it is good to know my memory is intact.  
The help is accurate, but the various pieces are a little dissociated.  
I think I learned I could trust the brittle ordering assumption 
(undocumented) by careful trial and error years ago.

Anyway, thanks for another great R learning experience -- It has been 
fun to see how thoughtfully and carefully the behavior of R base code is 
discussed before a change is made.  I wonder if 14 years of 
thinking/discussion is a record.

Also, I appreciate the suggestion to  use *split()* without having to 
completely ditch the use of the paired = TRUE argument, even if it still 
includes brittle order assumptions for pairs.   I must say that the 
Pair(x,y) ~ 1 formula syntax is not that easy for me to wrap my head 
around. I'll keep watching if there are further changes coming in R-devel

Rob

On 11/5/2025 6:28 AM, Peter Dalgaard wrote:

> Yes. Of course, Pair() requires the data to be in wide format. It's been a while (although not so long ago as some of the other things I cannot remember...) but I think the reason was that the  ...y~g, paired=TRUE... format was considered too brittle with respect to sort order and subsetting.
>
> -pd
>
>
>> On 4 Nov 2025, at 18.40, Ivan Krylov via R-help<[email protected]> wrote:
>>
>> В Tue, 4 Nov 2025 11:22:57 -0600
>> Robert Baer via R-help<[email protected]> пишет:
>>
>>> Errorin t.test.formula(value ~ time, data = data_long, paired =
>>> TRUE) :
>>> cannot use 'paired' in formula method
>> This was changed in R-4.4.0:
>> https://bugs.r-project.org/show_bug.cgi?id=14359
>>
>> The news item (see news(grepl('paired', Text))) recommends the use of
>> Pair(x1, x2) ~ 1 instead of the 'paired' argument. A further fix is
>> currently in R-devel (but not R-patched): without it, Pair(x1, x2) does
>> not handle the 'subset' argument.
>>
>> -- 
>> Best regards,
>> Ivan
>>
>> ______________________________________________
>> [email protected] mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guidehttps://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.

-- 
---
Robert W. Baer, Ph.D.
Professor of Physiology
Kirksville College of Osteopathic Medicine
A.T. Still Univerisity of Health Sciences
800 W. Jefferson St.
Kirksville, MO 63501

	[[alternative HTML version deleted]]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.