|
View:
New views
10 Messages
—
Rating Filter:
Alert me
|
|
|
The equivalence of t.test and the hypothesis testing of one way ANOVAI read somewhere that t.test is equivalent to a hypothesis testing for
one way ANOVA. But I'm wondering how they are equivalent. In the following code, the p-value by t.test() is not the same from the value in the last command. Could somebody let me know where I am wrong? > set.seed(0) > N1=10 > N2=10 > x=rnorm(N1) > y=rnorm(N2) > t.test(x,y) Welch Two Sample t-test data: x and y t = 1.6491, df = 14.188, p-value = 0.1211 alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: -0.2156863 1.6584968 sample estimates: mean of x mean of y 0.3589240 -0.3624813 > > A = c(rep('x',N1),rep('y',N2)) > Y = c(x,y) > fr = data.frame(Y=Y,A=as.factor(A)) > afit=aov(Y ~ A,fr) > > X=model.matrix(afit) > B=afit$coefficients > V=solve(t(X) %*% X) > > mse=tail(summary(afit)[[1]]$'Mean Sq',1) > df=tail(summary(afit)[[1]]$'Df',1) > t_statisitic=(B/(mse * sqrt(diag(V))))[[2]] > 2*(1-pt(abs(t_statisitic),df))#the p-value from aov > ______________________________________________ R-help@... 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. |
|
|
Re: The equivalence of t.test and the hypothesis testing of one way ANOVAcompare
t.test(x, y, var.equal=T) with summary(afit) b On Nov 5, 2009, at 12:21 PM, Peng Yu wrote: > I read somewhere that t.test is equivalent to a hypothesis testing for > one way ANOVA. But I'm wondering how they are equivalent. In the > following code, the p-value by t.test() is not the same from the value > in the last command. Could somebody let me know where I am wrong? > >> set.seed(0) >> N1=10 >> N2=10 >> x=rnorm(N1) >> y=rnorm(N2) >> t.test(x,y) > > Welch Two Sample t-test > > data: x and y > t = 1.6491, df = 14.188, p-value = 0.1211 > alternative hypothesis: true difference in means is not equal to 0 > 95 percent confidence interval: > -0.2156863 1.6584968 > sample estimates: > mean of x mean of y > 0.3589240 -0.3624813 > >> >> A = c(rep('x',N1),rep('y',N2)) >> Y = c(x,y) >> fr = data.frame(Y=Y,A=as.factor(A)) >> afit=aov(Y ~ A,fr) >> >> X=model.matrix(afit) >> B=afit$coefficients >> V=solve(t(X) %*% X) >> >> mse=tail(summary(afit)[[1]]$'Mean Sq',1) >> df=tail(summary(afit)[[1]]$'Df',1) >> t_statisitic=(B/(mse * sqrt(diag(V))))[[2]] >> 2*(1-pt(abs(t_statisitic),df))#the p-value from aov > [1] 0.1090802 >> > > ______________________________________________ > R-help@... 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@... 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. |
|
|
Re: The equivalence of t.test and the hypothesis testing of one way ANOVANotice also
> t.stat <- t.test(x,y, var.equal=TRUE)$statistic > F.stat <- summary(afit)[[1]][1,4] > t.stat^2 == F.stat t TRUE -----Original Message----- From: r-help-bounces@... [mailto:r-help-bounces@...] On Behalf Of Peng Yu Sent: Thursday, November 05, 2009 9:21 AM To: r-help@... Subject: [R] The equivalence of t.test and the hypothesis testing of one way ANOVA I read somewhere that t.test is equivalent to a hypothesis testing for one way ANOVA. But I'm wondering how they are equivalent. In the following code, the p-value by t.test() is not the same from the value in the last command. Could somebody let me know where I am wrong? > set.seed(0) > N1=10 > N2=10 > x=rnorm(N1) > y=rnorm(N2) > t.test(x,y) Welch Two Sample t-test data: x and y t = 1.6491, df = 14.188, p-value = 0.1211 alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: -0.2156863 1.6584968 sample estimates: mean of x mean of y 0.3589240 -0.3624813 > > A = c(rep('x',N1),rep('y',N2)) > Y = c(x,y) > fr = data.frame(Y=Y,A=as.factor(A)) > afit=aov(Y ~ A,fr) > > X=model.matrix(afit) > B=afit$coefficients > V=solve(t(X) %*% X) > > mse=tail(summary(afit)[[1]]$'Mean Sq',1) > df=tail(summary(afit)[[1]]$'Df',1) > t_statisitic=(B/(mse * sqrt(diag(V))))[[2]] > 2*(1-pt(abs(t_statisitic),df))#the p-value from aov > ______________________________________________ R-help@... 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. =================================== P Please consider the environment before printing this e-mail Cleveland Clinic is ranked one of the top hospitals in America by U.S. News & World Report (2008). Visit us online at http://www.clevelandclinic.org for a complete listing of our services, staff and locations. Confidentiality Note: This message is intended for use\...{{dropped:13}} ______________________________________________ R-help@... 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. |
|
|
Re: The equivalence of t.test and the hypothesis testing of one way ANOVAIs it possible to use aov() to compute the same p-value that is
generated by t.test() with var.equal=F. An assumption of ANOVA is equal variance, I'm wondering how to relax such assumption to allow non equal variance? On Thu, Nov 5, 2009 at 8:31 AM, Benilton Carvalho <bcarvalh@...> wrote: > compare > > t.test(x, y, var.equal=T) > > with > > summary(afit) > > b > > On Nov 5, 2009, at 12:21 PM, Peng Yu wrote: > >> I read somewhere that t.test is equivalent to a hypothesis testing for >> one way ANOVA. But I'm wondering how they are equivalent. In the >> following code, the p-value by t.test() is not the same from the value >> in the last command. Could somebody let me know where I am wrong? >> >>> set.seed(0) >>> N1=10 >>> N2=10 >>> x=rnorm(N1) >>> y=rnorm(N2) >>> t.test(x,y) >> >> Welch Two Sample t-test >> >> data: x and y >> t = 1.6491, df = 14.188, p-value = 0.1211 >> alternative hypothesis: true difference in means is not equal to 0 >> 95 percent confidence interval: >> -0.2156863 1.6584968 >> sample estimates: >> mean of x mean of y >> 0.3589240 -0.3624813 >> >>> >>> A = c(rep('x',N1),rep('y',N2)) >>> Y = c(x,y) >>> fr = data.frame(Y=Y,A=as.factor(A)) >>> afit=aov(Y ~ A,fr) >>> >>> X=model.matrix(afit) >>> B=afit$coefficients >>> V=solve(t(X) %*% X) >>> >>> mse=tail(summary(afit)[[1]]$'Mean Sq',1) >>> df=tail(summary(afit)[[1]]$'Df',1) >>> t_statisitic=(B/(mse * sqrt(diag(V))))[[2]] >>> 2*(1-pt(abs(t_statisitic),df))#the p-value from aov >> >> [1] 0.1090802 >>> >> >> ______________________________________________ >> R-help@... 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@... 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. |
|
|
Re: The equivalence of t.test and the hypothesis testing of one way ANOVAThere extensions to aov for without assuming equal variances.
Reed, James F., I. & Stark, D. B. (1988), 'Robust alternatives to traditional analyses of variance: Welch $W^*$, James $J_I^*$, James $J_II^*$, and Brown-Forsythe $BF^*$', Computer Methods and Programs in Biomedicine 26, 233--238. I don't know whether they are implemented in R. Peng Yu <pengyu.ut@...> Sent by: r-help-bounces@... 11/06/2009 07:59 AM To r-help@... cc Subject Re: [R] The equivalence of t.test and the hypothesis testing of one way ANOVA Is it possible to use aov() to compute the same p-value that is generated by t.test() with var.equal=F. An assumption of ANOVA is equal variance, I'm wondering how to relax such assumption to allow non equal variance? On Thu, Nov 5, 2009 at 8:31 AM, Benilton Carvalho <bcarvalh@...> wrote: > compare > > t.test(x, y, var.equal=T) > > with > > summary(afit) > > b > > On Nov 5, 2009, at 12:21 PM, Peng Yu wrote: > >> I read somewhere that t.test is equivalent to a hypothesis testing for >> one way ANOVA. But I'm wondering how they are equivalent. In the >> following code, the p-value by t.test() is not the same from the value >> in the last command. Could somebody let me know where I am wrong? >> >>> set.seed(0) >>> N1=10 >>> N2=10 >>> x=rnorm(N1) >>> y=rnorm(N2) >>> t.test(x,y) >> >> Welch Two Sample t-test >> >> data: x and y >> t = 1.6491, df = 14.188, p-value = 0.1211 >> alternative hypothesis: true difference in means is not equal to 0 >> 95 percent confidence interval: >> -0.2156863 1.6584968 >> sample estimates: >> mean of x mean of y >> 0.3589240 -0.3624813 >> >>> >>> A = c(rep('x',N1),rep('y',N2)) >>> Y = c(x,y) >>> fr = data.frame(Y=Y,A=as.factor(A)) >>> afit=aov(Y ~ A,fr) >>> >>> X=model.matrix(afit) >>> B=afit$coefficients >>> V=solve(t(X) %*% X) >>> >>> mse=tail(summary(afit)[[1]]$'Mean Sq',1) >>> df=tail(summary(afit)[[1]]$'Df',1) >>> t_statisitic=(B/(mse * sqrt(diag(V))))[[2]] >>> 2*(1-pt(abs(t_statisitic),df))#the p-value from aov >> >> [1] 0.1090802 >>> >> >> ______________________________________________ >> R-help@... 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@... 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. [[alternative HTML version deleted]] ______________________________________________ R-help@... 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. |
|
|
Re: The equivalence of t.test and the hypothesis testing of one way ANOVAHas the materials in this paper been integrated to any book?
On Fri, Nov 6, 2009 at 8:48 AM, <JLucke@...> wrote: > > There extensions to aov for without assuming equal variances. > > Reed, James F., I. & Stark, D. B. (1988), 'Robust alternatives to traditional analyses of variance: Welch $W^*$, James $J_I^*$, James $J_II^*$, and Brown-Forsythe $BF^*$', Computer Methods and Programs in Biomedicine 26, 233--238. > > > I don't know whether they are implemented in R. > > > > Peng Yu <pengyu.ut@...> > Sent by: r-help-bounces@... > > 11/06/2009 07:59 AM > > To > r-help@... > cc > Subject > Re: [R] The equivalence of t.test and the hypothesis testing of one way ANOVA > > > > > Is it possible to use aov() to compute the same p-value that is > generated by t.test() with var.equal=F. An assumption of ANOVA is > equal variance, I'm wondering how to relax such assumption to allow > non equal variance? > > On Thu, Nov 5, 2009 at 8:31 AM, Benilton Carvalho <bcarvalh@...> wrote: > > compare > > > > t.test(x, y, var.equal=T) > > > > with > > > > summary(afit) > > > > b > > > > On Nov 5, 2009, at 12:21 PM, Peng Yu wrote: > > > >> I read somewhere that t.test is equivalent to a hypothesis testing for > >> one way ANOVA. But I'm wondering how they are equivalent. In the > >> following code, the p-value by t.test() is not the same from the value > >> in the last command. Could somebody let me know where I am wrong? > >> > >>> set.seed(0) > >>> N1=10 > >>> N2=10 > >>> x=rnorm(N1) > >>> y=rnorm(N2) > >>> t.test(x,y) > >> > >> Welch Two Sample t-test > >> > >> data: x and y > >> t = 1.6491, df = 14.188, p-value = 0.1211 > >> alternative hypothesis: true difference in means is not equal to 0 > >> 95 percent confidence interval: > >> -0.2156863 1.6584968 > >> sample estimates: > >> mean of x mean of y > >> 0.3589240 -0.3624813 > >> > >>> > >>> A = c(rep('x',N1),rep('y',N2)) > >>> Y = c(x,y) > >>> fr = data.frame(Y=Y,A=as.factor(A)) > >>> afit=aov(Y ~ A,fr) > >>> > >>> X=model.matrix(afit) > >>> B=afit$coefficients > >>> V=solve(t(X) %*% X) > >>> > >>> mse=tail(summary(afit)[[1]]$'Mean Sq',1) > >>> df=tail(summary(afit)[[1]]$'Df',1) > >>> t_statisitic=(B/(mse * sqrt(diag(V))))[[2]] > >>> 2*(1-pt(abs(t_statisitic),df))#the p-value from aov > >> > >> [1] 0.1090802 > >>> > >> > >> ______________________________________________ > >> R-help@... 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@... 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@... 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. |
|
|
Re: The equivalence of t.test and the hypothesis testing of one way ANOVAThere's oneway.test() which implements Welch's 1953 (?)
paper, I believe. -Peter Ehlers JLucke@... wrote: > There extensions to aov for without assuming equal variances. > > Reed, James F., I. & Stark, D. B. (1988), 'Robust alternatives to > traditional analyses of variance: Welch $W^*$, James $J_I^*$, James > $J_II^*$, and Brown-Forsythe $BF^*$', Computer Methods and Programs in > Biomedicine 26, 233--238. > > > I don't know whether they are implemented in R. > > > > > Peng Yu <pengyu.ut@...> > Sent by: r-help-bounces@... > 11/06/2009 07:59 AM > > To > r-help@... > cc > > Subject > Re: [R] The equivalence of t.test and the hypothesis testing of one way > ANOVA > > > > > > > Is it possible to use aov() to compute the same p-value that is > generated by t.test() with var.equal=F. An assumption of ANOVA is > equal variance, I'm wondering how to relax such assumption to allow > non equal variance? > > On Thu, Nov 5, 2009 at 8:31 AM, Benilton Carvalho <bcarvalh@...> > wrote: >> compare >> >> t.test(x, y, var.equal=T) >> >> with >> >> summary(afit) >> >> b >> >> On Nov 5, 2009, at 12:21 PM, Peng Yu wrote: >> >>> I read somewhere that t.test is equivalent to a hypothesis testing for >>> one way ANOVA. But I'm wondering how they are equivalent. In the >>> following code, the p-value by t.test() is not the same from the value >>> in the last command. Could somebody let me know where I am wrong? >>> >>>> set.seed(0) >>>> N1=10 >>>> N2=10 >>>> x=rnorm(N1) >>>> y=rnorm(N2) >>>> t.test(x,y) >>> Welch Two Sample t-test >>> >>> data: x and y >>> t = 1.6491, df = 14.188, p-value = 0.1211 >>> alternative hypothesis: true difference in means is not equal to 0 >>> 95 percent confidence interval: >>> -0.2156863 1.6584968 >>> sample estimates: >>> mean of x mean of y >>> 0.3589240 -0.3624813 >>> >>>> A = c(rep('x',N1),rep('y',N2)) >>>> Y = c(x,y) >>>> fr = data.frame(Y=Y,A=as.factor(A)) >>>> afit=aov(Y ~ A,fr) >>>> >>>> X=model.matrix(afit) >>>> B=afit$coefficients >>>> V=solve(t(X) %*% X) >>>> >>>> mse=tail(summary(afit)[[1]]$'Mean Sq',1) >>>> df=tail(summary(afit)[[1]]$'Df',1) >>>> t_statisitic=(B/(mse * sqrt(diag(V))))[[2]] >>>> 2*(1-pt(abs(t_statisitic),df))#the p-value from aov >>> [1] 0.1090802 >>> ______________________________________________ >>> R-help@... 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@... 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. > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@... 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@... 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. |
|
|
|
|
|
Re: The equivalence of t.test and the hypothesis testing of one way ANOVAGuido wrote
"However, using a transformation matrix one can transform a model assuming unequal variances into an equivalent model assuming equal variances. On such a transformed model the F test or T test can be applied." This is indeed news to me. I thought such transformations for unequal variances applied only to cases where the variances were known. Unknown, unequal variances leads to the Behrens-Fisher problem and its generalizations, a problem not resolved by mere linear transformation. Correct me and point me to the literature if I've misunderstood. Joe Guido van Steen <gvsteen@...> 11/07/2009 09:28 AM To r-help@... cc JLucke@..., Peng Yu <pengyu.ut@...> Subject Re: [R] The equivalence of t.test and the hypothesis testing of one way ANOVA Hi, Student's T-test is a test that can be used to test ONE SINGLE linear restriction - which serves the as alternative hypothesis - on a linear model - which serves as the null hypothesis - AT THE SAME TIME. Fisher's F test is an extension of the T test. The F test can be used to test ONE OR MORE linear restriction(s) on a linear model AT THE SAME TIME. So, to test a single restriction on a linear model one can use both the F test and the T test. When multiple restrictions are tested at the same time one needs to apply the F test. Both the F and the T test actually require equal variances. However, using a transformation matrix one can transform a model assuming unequal variances into an equivalent model assuming equal variances. On such a transformed model the F test or T test can be applied. The untransformed models are usually called general linear models. In R they can be handled using the glm() function. (See ?glm) A (one-way) Anova model is a specific type of general linear model (glm). So hypotheses on an Anova model are tested in exactly the same way as any other restrictions on a glm should be tested. Best wishes, Guido > ------------------------------ > > Message: 11 > Date: Fri, 6 Nov 2009 09:48:18 -0500 > From: JLucke@... > Subject: Re: [R] The equivalence of t.test and the > hypothesis testing > of one way ANOVA > To: Peng Yu <pengyu.ut@...> > Cc: r-help-bounces@..., > r-help@... > Message-ID: > > > Content-Type: text/plain > > There extensions to aov for without assuming equal > variances. > > Reed, James F., I. & Stark, D. B. (1988), 'Robust > alternatives to > traditional analyses of variance: Welch $W^*$, James > $J_I^*$, James > $J_II^*$, and Brown-Forsythe $BF^*$', Computer Methods and > Programs in > Biomedicine 26, 233--238. > > > I don't know whether they are implemented > in R. > > > > > Peng Yu <pengyu.ut@...> > > Sent by: r-help-bounces@... > 11/06/2009 07:59 AM > > To > r-help@... > cc > > Subject > Re: [R] The equivalence of t.test and the hypothesis > testing of one way > ANOVA > > > > > > > Is it possible to use aov() to compute the same p-value > that is > generated by t.test() with var.equal=F. An assumption of > ANOVA is > equal variance, I'm wondering how to relax such assumption > to allow > non equal variance? > > On Thu, Nov 5, 2009 at 8:31 AM, Benilton Carvalho <bcarvalh@...> > > wrote: > > compare > > > > t.test(x, y, var.equal=T) > > > > with > > > > summary(afit) > > > > b > > > > On Nov 5, 2009, at 12:21 PM, Peng Yu wrote: > > > >> I read somewhere that t.test is equivalent to a > hypothesis testing for > >> one way ANOVA. But I'm wondering how they are > equivalent. In the > >> following code, the p-value by t.test() is not the > same from the value > >> in the last command. Could somebody let me know > where I am wrong? > >> > >>> set.seed(0) > >>> N1=10 > >>> N2=10 > >>> x=rnorm(N1) > >>> y=rnorm(N2) > >>> t.test(x,y) > >> > >> Welch Two Sample > t-test > >> > >> data: x and y > >> t = 1.6491, df = 14.188, p-value = 0.1211 > >> alternative hypothesis: true difference in means > is not equal to 0 > >> 95 percent confidence interval: > >> -0.2156863 1.6584968 > >> sample estimates: > >> mean of x mean of y > >> 0.3589240 -0.3624813 > >> > >>> > >>> A = c(rep('x',N1),rep('y',N2)) > >>> Y = c(x,y) > >>> fr = data.frame(Y=Y,A=as.factor(A)) > >>> afit=aov(Y ~ A,fr) > >>> > >>> X=model.matrix(afit) > >>> B=afit$coefficients > >>> V=solve(t(X) %*% X) > >>> > >>> mse=tail(summary(afit)[[1]]$'Mean Sq',1) > >>> df=tail(summary(afit)[[1]]$'Df',1) > >>> t_statisitic=(B/(mse * sqrt(diag(V))))[[2]] > >>> 2*(1-pt(abs(t_statisitic),df))#the p-value > from aov > >> > >> [1] 0.1090802 > >>> > >> > >> ______________________________________________ > >> R-help@... > 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@... > 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. > > > [[alternative HTML version deleted]] > > > New Email names for you! Get the Email name you've always wanted on the new @ymail and @rocketmail. Hurry before someone else does! http://mail.promotions.yahoo.com/newdomains/aa/ [[alternative HTML version deleted]] ______________________________________________ R-help@... 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. |
|
|
|
| Free embeddable forum powered by Nabble | Forum Help |