[R] Pulling p values

Peter Ehlers ehlers at ucalgary.ca
Sat Feb 26 14:53:00 CET 2011


On 2011-02-26 04:12, Gallavan, Robert wrote:
> Hi folks,
>
> I'm doing ANOVA with multiple comparisons.  I've used both the TukeyHSD  function and the multcomp procedure.  In both cases, I get some tantalizing results such as this...
>
> e = aov(lm(d.all[,(n+4)] ~ d.all[,4])
>
> TukeyHSD(e)
>
>    Tukey multiple comparisons of means
>      95% family-wise confidence level
>
> Fit: aov(formula = lm(d.all[, (n + 4)] ~ d.all[, 4], contrast = C))
>
> $`d.all[, 4]`
>                                   diff               lwr               upr                p adj
> 10 mpk-0 mpk                                -0.677375 -1.1779417 -0.1768083   0.0071092
> 30 mpk-0 mpk                               -1.074500 -1.5750667 -0.5739333    0.0000656
> 30 mpk-10 mpk                             -0.397125 -0.8976917  0.1034417    0.1369760
>
> I ask for the pvalues and get...
>
> i = h$pvalues
> i
>     10 mpk - 0 mpk              30 mpk - 0 mpk                 30 mpk - 10 mpk
>     2.630022e-03                   2.288575e-05                       5.863517e-02
>
> It looks like a matrix, but it is a vector of length 3 and the third element, for example, is....
>
>> length(i)
> [1] 3
>> q = i[3]
>> q
> 30 mpk - 10 mpk
>       0.05863517
>
> The contrast label is bound to the p-value as a single element.

Well, 'bound to' just means that you have a vector with names.
So you can just unname() it.

But do let us in on your secret: what's 'h'?

>
> Does anyone know how to extract just the p-value from this procedure?  Or a simple way to generate these comparisons?
>
> Thanks,
>
> Bob Gallavan
> An obvious newbie

Newbies need to peruse the posting guide;
In particular, note the comment about HTML mail.

Peter Ehlers

>
>
> ------------------------------"This message is the property of i3Global and may include confidential and/or proprietary information, and may be used only by the person or entity to which it is addressed. If the reader of this e-mail is not the intended recipient or his or her authorized agent, the reader is hereby notified that any dissemination, distribution or copying of this e-mail is prohibited. If you have received this e-mail in error, please notify the sender by replying to this message and delete this e-mail immediately."==============================
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list