------------------------------
Message: 11
Date: Fri, 6 Nov 2009 09:48:18 -0500
From: JLucke at ria.buffalo.edu
Subject: Re: [R] The equivalence of t.test and the
hypothesis testing
??? of one??? way ANOVA
To: Peng Yu <pengyu.ut at gmail.com>
Cc: r-help-bounces at r-project.org,
r-help at stat.math.ethz.ch
Message-ID:
??? <OFC71A4670.65D468B9-ON85257666.0050EE14-85257666.005175E1 at ria.buffalo.edu>
???
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 at gmail.com>
Sent by: r-help-bounces at r-project.org
11/06/2009 07:59 AM
To
r-help at stat.math.ethz.ch
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 at jhsph.edu>
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
one way ANOVA. But I'm wondering how they are
following code, the p-value by t.test() is not the
in the last command. Could somebody let me know
set.seed(0)
N1=10
N2=10
x=rnorm(N1)
y=rnorm(N2)
t.test(x,y)
data:? x and y
t = 1.6491, df = 14.188, p-value = 0.1211
alternative hypothesis: true difference in means
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