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): sequence subject period treatment AUC logAUC 1 RT 1 1 Reference 44.1 3.786460 2 RT 1 2 Test 39.1 3.666122 3 RT 2 1 Reference 33.6 3.514526 4 RT 2 2 Test 23.8 3.169686 5 RT 3 1 Reference 45.5 3.817712 6 RT 3 2 Test 40.8 3.708682 7 TR 4 1 Test 19.5 2.970414 8 TR 4 2 Reference 21.1 3.049273 9 TR 5 1 Test 67.2 4.207673 10 TR 5 2 Reference 51.5 3.941582 11 TR 6 1 Test 25.7 3.246491 12 TR 6 2 Reference 30.1 3.404525 13 RT 7 1 Reference 35.3 3.563883 14 RT 7 2 Test 26.7 3.284664 15 RT 8 1 Reference 26.0 3.258097 16 RT 8 2 Test 36.5 3.597312 17 RT 9 1 Reference 38.2 3.642836 18 RT 9 2 Test 57.8 4.056989 19 TR 10 1 Test 33.6 3.514526 20 TR 10 2 Reference 32.5 3.481240 21 TR 11 1 Test 25.1 3.222868 22 TR 11 2 Reference 36.8 3.605498 23 TR 12 1 Test 44.1 3.786460 24 TR 12 2 Reference 42.9 3.758872 25 RT 13 1 Reference 25.6 3.242592 26 RT 13 2 Test 20.1 3.000720 27 RT 14 1 Reference 58.0 4.060443 28 RT 14 2 Test 45.3 3.813307 29 RT 15 1 Reference 47.2 3.854394 30 RT 15 2 Test 51.8 3.947390 31 TR 16 1 Test 16.5 2.803360 32 TR 16 2 Reference 21.4 3.063391 33 TR 17 1 Test 47.3 3.856510 34 TR 17 2 Reference 39.4 3.673766 35 TR 18 1 Test 22.6 3.117950 36 TR 18 2 Reference 17.3 2.850707 37 RT 19 1 Reference 17.5 2.862201 38 RT 19 2 Test 30.1 3.404525 39 RT 20 1 Reference 51.7 3.945458 40 RT 20 2 Test 36.0 3.583519 41 RT 21 1 Reference 24.5 3.198673 42 RT 21 2 Test 18.2 2.901422 43 TR 22 1 Test 36.3 3.591818 44 TR 22 2 Reference 27.2 3.303217 45 TR 23 1 Test 29.4 3.380995 46 TR 23 2 Reference 39.6 3.678829 47 TR 24 1 Test 18.3 2.906901 48 TR 24 2 Reference 20.7 3.030134 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])) Best regards, Helmut -- Ing. Helmut Sch?tz BEBAC - Consultancy Services for Bioequivalence and Bioavailability Studies Neubaugasse 36/11 1070 Vienna, Austria tel/fax +43 1 2311746 e-mail helmut.schuetz at bebac.at web http://bebac.at forum http://forum.bebac.at
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, > HelmutHaris Skiadas Department of Mathematics and Computer Science Hanover College
On 4/18/07, Helmut Sch?tz <helmut.schuetz at bebac.at> 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): > > sequence subject period treatment AUC logAUC > 1 RT 1 1 Reference 44.1 3.786460 > 2 RT 1 2 Test 39.1 3.666122 > 3 RT 2 1 Reference 33.6 3.514526 > 4 RT 2 2 Test 23.8 3.169686 > 5 RT 3 1 Reference 45.5 3.817712 > 6 RT 3 2 Test 40.8 3.708682 > 7 TR 4 1 Test 19.5 2.970414 > 8 TR 4 2 Reference 21.1 3.049273 > 9 TR 5 1 Test 67.2 4.207673 > 10 TR 5 2 Reference 51.5 3.941582 > 11 TR 6 1 Test 25.7 3.246491 > 12 TR 6 2 Reference 30.1 3.404525 > 13 RT 7 1 Reference 35.3 3.563883 > 14 RT 7 2 Test 26.7 3.284664 > 15 RT 8 1 Reference 26.0 3.258097 > 16 RT 8 2 Test 36.5 3.597312 > 17 RT 9 1 Reference 38.2 3.642836 > 18 RT 9 2 Test 57.8 4.056989 > 19 TR 10 1 Test 33.6 3.514526 > 20 TR 10 2 Reference 32.5 3.481240 > 21 TR 11 1 Test 25.1 3.222868 > 22 TR 11 2 Reference 36.8 3.605498 > 23 TR 12 1 Test 44.1 3.786460 > 24 TR 12 2 Reference 42.9 3.758872 > 25 RT 13 1 Reference 25.6 3.242592 > 26 RT 13 2 Test 20.1 3.000720 > 27 RT 14 1 Reference 58.0 4.060443 > 28 RT 14 2 Test 45.3 3.813307 > 29 RT 15 1 Reference 47.2 3.854394 > 30 RT 15 2 Test 51.8 3.947390 > 31 TR 16 1 Test 16.5 2.803360 > 32 TR 16 2 Reference 21.4 3.063391 > 33 TR 17 1 Test 47.3 3.856510 > 34 TR 17 2 Reference 39.4 3.673766 > 35 TR 18 1 Test 22.6 3.117950 > 36 TR 18 2 Reference 17.3 2.850707 > 37 RT 19 1 Reference 17.5 2.862201 > 38 RT 19 2 Test 30.1 3.404525 > 39 RT 20 1 Reference 51.7 3.945458 > 40 RT 20 2 Test 36.0 3.583519 > 41 RT 21 1 Reference 24.5 3.198673 > 42 RT 21 2 Test 18.2 2.901422 > 43 TR 22 1 Test 36.3 3.591818 > 44 TR 22 2 Reference 27.2 3.303217 > 45 TR 23 1 Test 29.4 3.380995 > 46 TR 23 2 Reference 39.6 3.678829 > 47 TR 24 1 Test 18.3 2.906901 > 48 TR 24 2 Reference 20.7 3.030134 > > 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.testYou could change the order of the levels of the treatment factor. See ?relevel> > 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])) > > Best regards, > Helmut > > -- > Ing. Helmut Sch?tz > BEBAC - Consultancy Services for > Bioequivalence and Bioavailability Studies > Neubaugasse 36/11 > 1070 Vienna, Austria > tel/fax +43 1 2311746 > e-mail helmut.schuetz at bebac.at > web http://bebac.at > forum http://forum.bebac.at > > ______________________________________________ > R-help at stat.math.ethz.ch 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. >
take a look at ?relevel() Best, Dimitris ---- Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm ----- Original Message ----- From: "Helmut Sch?tz" <helmut.schuetz at bebac.at> To: <r-help at stat.math.ethz.ch> Sent: Wednesday, April 18, 2007 2:46 PM Subject: [R] Two sample t.test, order of comparions 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): sequence subject period treatment AUC logAUC 1 RT 1 1 Reference 44.1 3.786460 2 RT 1 2 Test 39.1 3.666122 3 RT 2 1 Reference 33.6 3.514526 4 RT 2 2 Test 23.8 3.169686 5 RT 3 1 Reference 45.5 3.817712 6 RT 3 2 Test 40.8 3.708682 7 TR 4 1 Test 19.5 2.970414 8 TR 4 2 Reference 21.1 3.049273 9 TR 5 1 Test 67.2 4.207673 10 TR 5 2 Reference 51.5 3.941582 11 TR 6 1 Test 25.7 3.246491 12 TR 6 2 Reference 30.1 3.404525 13 RT 7 1 Reference 35.3 3.563883 14 RT 7 2 Test 26.7 3.284664 15 RT 8 1 Reference 26.0 3.258097 16 RT 8 2 Test 36.5 3.597312 17 RT 9 1 Reference 38.2 3.642836 18 RT 9 2 Test 57.8 4.056989 19 TR 10 1 Test 33.6 3.514526 20 TR 10 2 Reference 32.5 3.481240 21 TR 11 1 Test 25.1 3.222868 22 TR 11 2 Reference 36.8 3.605498 23 TR 12 1 Test 44.1 3.786460 24 TR 12 2 Reference 42.9 3.758872 25 RT 13 1 Reference 25.6 3.242592 26 RT 13 2 Test 20.1 3.000720 27 RT 14 1 Reference 58.0 4.060443 28 RT 14 2 Test 45.3 3.813307 29 RT 15 1 Reference 47.2 3.854394 30 RT 15 2 Test 51.8 3.947390 31 TR 16 1 Test 16.5 2.803360 32 TR 16 2 Reference 21.4 3.063391 33 TR 17 1 Test 47.3 3.856510 34 TR 17 2 Reference 39.4 3.673766 35 TR 18 1 Test 22.6 3.117950 36 TR 18 2 Reference 17.3 2.850707 37 RT 19 1 Reference 17.5 2.862201 38 RT 19 2 Test 30.1 3.404525 39 RT 20 1 Reference 51.7 3.945458 40 RT 20 2 Test 36.0 3.583519 41 RT 21 1 Reference 24.5 3.198673 42 RT 21 2 Test 18.2 2.901422 43 TR 22 1 Test 36.3 3.591818 44 TR 22 2 Reference 27.2 3.303217 45 TR 23 1 Test 29.4 3.380995 46 TR 23 2 Reference 39.6 3.678829 47 TR 24 1 Test 18.3 2.906901 48 TR 24 2 Reference 20.7 3.030134 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])) Best regards, Helmut -- Ing. Helmut Sch?tz BEBAC - Consultancy Services for Bioequivalence and Bioavailability Studies Neubaugasse 36/11 1070 Vienna, Austria tel/fax +43 1 2311746 e-mail helmut.schuetz at bebac.at web http://bebac.at forum http://forum.bebac.at ______________________________________________ R-help at stat.math.ethz.ch 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. Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
Dear Charilaos! Charilaos Skiadas wrote:>> >> 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.I applied relevel() as suggested by Douglas and Dimitri: > relevel(resp$treatment, ref = "Reference") > result <- t.test(logAUC ~ treatment, data = resp, subset = (period == 1), var.equal = FALSE, conf.level = 0.90) > result yielding 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 So right now the confidence interval in the log-domain is of the correct order. Your first suggestion is working (sign changed due to reversed level) > as.numeric(exp(diff(result$estimate))) > [1] 0.8365723 But still I have to apply > as.numeric(exp(-result$conf.int[2])) [1] 0.634936 > as.numeric(exp(-result$conf.int[1])) [1] 1.102242 because > as.numeric(exp(-result$conf.int)) [1] 1.102242 0.634936 in order to get the correct CI in the untransformed domain I had to sort the list: > sort(as.numeric(exp(-result$conf.int))) [1] 0.634936 1.102242 Best regards, Helmut -- Ing. Helmut Sch?tz BEBAC - Consultancy Services for Bioequivalence and Bioavailability Studies Neubaugasse 36/11 1070 Vienna, Austria tel/fax +43 1 2311746 e-mail helmut.schuetz at bebac.at web http://bebac.at forum http://forum.bebac.at
Reasonably Related Threads
- How to generate 'minor' ticks in lattice (qqmath)
- R and Gnumeric
- comparion between xen n kvm :Performance analysis of transport protocol(TCP) during live migration
- Multiple lon lat points in the map with ggplot2
- Help understanding and lowering LLVM IDS conditional codes correctly