Wayne Aldo Gavioli
2007-Oct-09 22:37 UTC
[R] 2 Sample Confidence Interval - Formatting Data?
Hello all, I have to run a 2 Sample Confidence Interval on some data; the command for such intervals is "confint(...)", but in the help documentation it says that you need a "fitted model object" in order to run this command. What does that mean? The data is very small, it's: x=c(8,12,10,14,2,0,0) y=c(-6,0,1,2,-3,-4,2) and I want to be able to run a Confidence interval for the difference of two means (x-bar minus y-bar). Do I have to fit these two pieces of data into some kind of object? A little confused, Wayne
Nordlund, Dan (DSHS/RDA)
2007-Oct-09 23:17 UTC
[R] 2 Sample Confidence Interval - Formatting Data?
> -----Original Message----- > From: r-help-bounces at r-project.org > [mailto:r-help-bounces at r-project.org] On Behalf Of Wayne Aldo Gavioli > Sent: Tuesday, October 09, 2007 3:37 PM > To: r-help at stat.math.ethz.ch > Subject: [R] 2 Sample Confidence Interval - Formatting Data? > > > > Hello all, > > I have to run a 2 Sample Confidence Interval on some data; > the command for such > intervals is "confint(...)", but in the help documentation it > says that you > need a "fitted model object" in order to run this command. > What does that > mean? > > The data is very small, it's: > > x=c(8,12,10,14,2,0,0) > y=c(-6,0,1,2,-3,-4,2) > > > and I want to be able to run a Confidence interval for the > difference of two > means (x-bar minus y-bar). Do I have to fit these two pieces > of data into some > kind of object? > > > A little confused, > > > Wayne >Wayne, You may want to look at ?t.test instead. Hope this is helpful, Dan Daniel J. Nordlund Research and Data Analysis Washington State Department of Social and Health Services Olympia, WA 98504-5204
On Tue, 2007-10-09 at 18:37 -0400, Wayne Aldo Gavioli wrote:> > Hello all, > > I have to run a 2 Sample Confidence Interval on some data; the command for such > intervals is "confint(...)", but in the help documentation it says that you > need a "fitted model object" in order to run this command. What does that > mean? > > The data is very small, it's: > > x=c(8,12,10,14,2,0,0) > y=c(-6,0,1,2,-3,-4,2) > > > and I want to be able to run a Confidence interval for the difference of two > means (x-bar minus y-bar). Do I have to fit these two pieces of data into some > kind of object? > > > A little confused,Try this, presuming that your data above are not paired:> t.test(x, y)Welch Two Sample t-test data: x and y t = 3.0621, df = 9.264, p-value = 0.01308 alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: 2.039893 13.388678 sample estimates: mean of x mean of y 6.571429 -1.142857 See ?t.test for more information. confint(), as per the top of help page which you were reading: "Computes confidence intervals for one or more parameters in a fitted model." Said differently, it computes confidence intervals for the coefficients in a linear model, not for the difference in means in a two sample test. HTH, Marc Schwartz
Hello Wayne, Welch Test (as suggested by M.S.) can be a good choice, but since your sample is very small you must ask yourself what can you assume about the two samples (i.e. do they come from more or less normal distributions, etc.). Regards, Moshe. --- Wayne Aldo Gavioli <wgavioli at fas.harvard.edu> wrote:> > > Hello all, > > I have to run a 2 Sample Confidence Interval on some > data; the command for such > intervals is "confint(...)", but in the help > documentation it says that you > need a "fitted model object" in order to run this > command. What does that > mean? > > The data is very small, it's: > > x=c(8,12,10,14,2,0,0) > y=c(-6,0,1,2,-3,-4,2) > > > and I want to be able to run a Confidence interval > for the difference of two > means (x-bar minus y-bar). Do I have to fit these > two pieces of data into some > kind of object? > > > A little confused, > > > Wayne > > ______________________________________________ > 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. >