If my sample size is small is there a particular switch option that I need to use with t.test so that it calculates the t ratio correctly? Here is a dummy example? รก =0.05 Mean pain reduction for A =27; B =31 and SD are SDA=9 SDB=12 drgA.p<-rnorm(5,27,9); drgB.p<-rnorm(5,31,12) t.test(drgA.p,drgB.p) # what do I need to give as additional parameter here? I can do it manually but was looking for a switch option that I need to specify for t.test. Thanks ../Murli [[alternative HTML version deleted]]
Hi Nair, If the two populations are normal the t-test gives you the exact result for whatever the sample size is (the sample size will affect the number of degrees of freedom). When the populations are not normal and the sample size is large it is still OK to use t-test (because of the Central Limit Theorem) but this is not necessarily true for the small sample size. You could use simulation to find the relevant probabilities. --- "Nair, Murlidharan T" <mnair at iusb.edu> wrote:> If my sample size is small is there a particular > switch option that I need to use with t.test so that > it calculates the t ratio correctly? > > Here is a dummy example? > > ? =0.05 > > Mean pain reduction for A =27; B =31 and SD are > SDA=9 SDB=12 > > drgA.p<-rnorm(5,27,9); > > drgB.p<-rnorm(5,31,12) > > t.test(drgA.p,drgB.p) # what do I need to give as > additional parameter here? > > > > I can do it manually but was looking for a switch > option that I need to specify for t.test. > > > > Thanks ../Murli > > > > > [[alternative HTML version deleted]] > > > ______________________________________________ > 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. >
Indeed, I understand what you say. The df of freedom for the dummy example is n1+n2-2 = 8. But when I run the t.test I get it as 5.08, am I missing something? -----Original Message----- From: Moshe Olshansky [mailto:m_olshansky at yahoo.com] Sent: Tuesday, August 07, 2007 9:05 PM To: Nair, Murlidharan T; r-help at stat.math.ethz.ch Subject: Re: [R] small sample techniques Hi Nair, If the two populations are normal the t-test gives you the exact result for whatever the sample size is (the sample size will affect the number of degrees of freedom). When the populations are not normal and the sample size is large it is still OK to use t-test (because of the Central Limit Theorem) but this is not necessarily true for the small sample size. You could use simulation to find the relevant probabilities. --- "Nair, Murlidharan T" <mnair at iusb.edu> wrote:> If my sample size is small is there a particular > switch option that I need to use with t.test so that > it calculates the t ratio correctly? > > Here is a dummy example? > > ? =0.05 > > Mean pain reduction for A =27; B =31 and SD are > SDA=9 SDB=12 > > drgA.p<-rnorm(5,27,9); > > drgB.p<-rnorm(5,31,12) > > t.test(drgA.p,drgB.p) # what do I need to give as > additional parameter here? > > > > I can do it manually but was looking for a switch > option that I need to specify for t.test. > > > > Thanks ../Murli > > > > > [[alternative HTML version deleted]] > > > ______________________________________________ > 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. >
On Wed, 8 Aug 2007, Nair, Murlidharan T wrote:> Indeed, I understand what you say. The df of freedom for the dummy example is n1+n2-2 = 8. But when I run the t.test I get it as 5.08, am I missing something? >Yes. You are probably looking for the version of the t.test that assumes equal variances (the original one), so you need var.equal=TRUE. -thomas> -----Original Message----- > From: Moshe Olshansky [mailto:m_olshansky at yahoo.com] > Sent: Tuesday, August 07, 2007 9:05 PM > To: Nair, Murlidharan T; r-help at stat.math.ethz.ch > Subject: Re: [R] small sample techniques > > Hi Nair, > > If the two populations are normal the t-test gives you > the exact result for whatever the sample size is (the > sample size will affect the number of degrees of > freedom). > When the populations are not normal and the sample > size is large it is still OK to use t-test (because of > the Central Limit Theorem) but this is not necessarily > true for the small sample size. > You could use simulation to find the relevant > probabilities. > > --- "Nair, Murlidharan T" <mnair at iusb.edu> wrote: > >> If my sample size is small is there a particular >> switch option that I need to use with t.test so that >> it calculates the t ratio correctly? >> >> Here is a dummy example? >> >> ? =0.05 >> >> Mean pain reduction for A =27; B =31 and SD are >> SDA=9 SDB=12 >> >> drgA.p<-rnorm(5,27,9); >> >> drgB.p<-rnorm(5,31,12) >> >> t.test(drgA.p,drgB.p) # what do I need to give as >> additional parameter here? >> >> >> >> I can do it manually but was looking for a switch >> option that I need to specify for t.test. >> >> >> >> Thanks ../Murli >> >> >> >> >> [[alternative HTML version deleted]] >> >>> ______________________________________________ >> 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. >> > > ______________________________________________ > 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. >Thomas Lumley Assoc. Professor, Biostatistics tlumley at u.washington.edu University of Washington, Seattle
About using t tests and confidence intervals for "large" samples - "large" may need to be very large. The old pre-computer-age rule of n >= 30 is inadequate. For example, for an exponential distribution, the actual size of a nominal 2.5% one-sided t-test is not accurate to within 10% (i.e. between 2.25% & 2.75%) until n is around 5000. The error (actual - nominal size) decreases very slowly, at the rate 1/sqrt(n). In practice, real distributions may be even more skewed than the exponential distribution, even though they appear less skewed, if they have long tails. In this case the sample size would need to be even larger for t procedures to be reasonably accurate. An alternative is to use bootstrapping. Bootstrap procedures that decrease at the rate 1/n include bootstrap t, BCa, and bootstrap tilting. Moshe Olshansky <m_olshansky at yahoo.com> wrote:>If the two populations are normal the t-test gives you >the exact result for whatever the sample size is (the >sample size will affect the number of degrees of >freedom). >When the populations are not normal and the sample >size is large it is still OK to use t-test (because of >the Central Limit Theorem) but this is not necessarily >true for the small sample size. >You could use simulation to find the relevant >probabilities. >...=======================================================| Tim Hesterberg Senior Research Scientist | | timh at insightful.com Insightful Corp. | | (206)802-2319 1700 Westlake Ave. N, Suite 500 | | (206)283-8691 (fax) Seattle, WA 98109-3044, U.S.A. | | www.insightful.com/Hesterberg | =======================================================Short course - Bootstrap Methods and Permutation Tests Oct 10-11 San Francisco, 3-4 Oct UK. http://www.insightful.com/services/training.asp
As Thomas Lumley noted, there exist several versions of t-test. If you use t1 <- t.test(x,y) then no assumption is made of x and y having equal variance and of the two sample sizes being equal and then an approximate t-test is used with an approximate number of degrees of freedom (and this is what you got). If you use t2 <- t.test(x,y,var.equal=TRUE) then equal variance is assumed and you get 8 degrees of freedom. If you use t3 <- t.test(x,y,paired=TRUE) then equal sample sizes are assumed and the number of degrees of freedom is 4 (5-1). --- "Nair, Murlidharan T" <mnair at iusb.edu> wrote:> Indeed, I understand what you say. The df of freedom > for the dummy example is n1+n2-2 = 8. But when I run > the t.test I get it as 5.08, am I missing something? > > > -----Original Message----- > From: Moshe Olshansky [mailto:m_olshansky at yahoo.com] > > Sent: Tuesday, August 07, 2007 9:05 PM > To: Nair, Murlidharan T; r-help at stat.math.ethz.ch > Subject: Re: [R] small sample techniques > > Hi Nair, > > If the two populations are normal the t-test gives > you > the exact result for whatever the sample size is > (the > sample size will affect the number of degrees of > freedom). > When the populations are not normal and the sample > size is large it is still OK to use t-test (because > of > the Central Limit Theorem) but this is not > necessarily > true for the small sample size. > You could use simulation to find the relevant > probabilities. > > --- "Nair, Murlidharan T" <mnair at iusb.edu> wrote: > > > If my sample size is small is there a particular > > switch option that I need to use with t.test so > that > > it calculates the t ratio correctly? > > > > Here is a dummy example? > > > > ? =0.05 > > > > Mean pain reduction for A =27; B =31 and SD are > > SDA=9 SDB=12 > > > > drgA.p<-rnorm(5,27,9); > > > > drgB.p<-rnorm(5,31,12) > > > > t.test(drgA.p,drgB.p) # what do I need to give as > > additional parameter here? > > > > > > > > I can do it manually but was looking for a switch > > option that I need to specify for t.test. > > > > > > > > Thanks ../Murli > > > > > > > > > > [[alternative HTML version deleted]] > > > > > ______________________________________________ > > 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. > > > >