[R] Two sample t.test, order of comparions
Charilaos Skiadas
skiadas at hanover.edu
Wed Apr 18 15:19:05 CEST 2007
On Apr 18, 2007, at 8:46 AM, Helmut Schütz wrote:
> Dear group members,
>
> I want to compare response variables ("logAUC") of two groups
> (treatment
> "Test", "Reference") of a subset ("period == 1") in dataframe "resp"
> (below):
[ snip ]
> The formula method of t.test
>
>> result <- t.test(logAUC ~ treatment, data = resp, subset = (period ==
> 1), var.equal = FALSE, conf.level = 0.90)
>> result
>
> gives
>
> Welch Two Sample t-test
>
> data: logAUC by treatment
> t = 1.1123, df = 21.431, p-value = 0.2783
> alternative hypothesis: true difference in means is not equal to 0
> 90 percent confidence interval:
> -0.0973465 0.4542311
> sample estimates:
> mean in group Reference mean in group Test
> 3.562273 3.383831
>
> Now I'm interested rather in the confidence interval of "Test" -
> "Reference" rather than "Reference" - "Test" which is given by t.test
>
> Do you know a more elegant way than the clumsy one I have tried?
>
>> as.numeric(exp(result$estimate[2]-result$estimate[1]))
>> as.numeric(exp(-result$conf.int[2]))
>> as.numeric(exp(-result$conf.int[1]))
First off, those three could probably be simplified slightly as:
as.numeric(exp(-diff(result$estimate)))
as.numeric(exp(-result$conf.int))
The simplest solution I think is to specify that resp$treatment
should have the levels ordered in the way you like them using this
first:
resp$treatment <- ordered(resp$treatment, levels=rev(levels(resp
$treatment)))
Then the t.test will show things in the order you want them.
> Best regards,
> Helmut
Haris Skiadas
Department of Mathematics and Computer Science
Hanover College
More information about the R-help
mailing list