[R] Re: T-test syntax question

Vito Ricci vito_ricci at yahoo.com
Wed Nov 24 12:32:06 CET 2004


Hi,

In case of paired data, if you have only differencies
and not original data you can get this t test based on
differencies:

Say d is the vector with differencies data and suppose
you wish to test if the mean of differency is equal to
zero:

md<-mean(d) ## sample mean of differencies
sdd<-sd(d) ## sample sd of differencies
n<-length(d) ## sample size
t.value<-(md/(sdd/sqrt(n))) ## sample t-value with n-1
df
pt(t.value,n-1,lower.tail=FALSE) ## p-value of test

> set.seed(13)
> d<-rnorm(50)
> md<-mean(d) ## sample mean of differencies
> sdd<-sd(d) ## sample sd of differencies
> n<-length(d) ## sample size
> t.value<-(md/(sdd/sqrt(n))) ## sample t-value with
n-1 df
> pt(t.value,n-1,lower.tail=FALSE) ## p-value of test
[1] 0.5755711

Best regards,
Vito



Steven F. Freeman wrote:

I'd like to do a t-test to compare the Delta values of
items with Crit=1
with Delta values of items with Crit=0. What is the
t.test syntax?

It should produce a result like this below (I can't
get in touch with the
person who originally did this for me)

    Welch Two Sample t-test

data:  t1$Delta by Crit
t = -3.4105, df = 8.674, p-value = 0.008173
alternative hypothesis: true
difference in means is not equal to 0
95 percent confidence interval:
 -0.04506155 -0.00899827
sample estimates:
mean in group FALSE  mean in group TRUE 
         0.03331391          0.06034382 

Thanks.

=====
Diventare costruttori di soluzioni
Became solutions' constructors

"The business of the statistician is to catalyze 
the scientific learning process."  
George E. P. Box


Visitate il portale http://www.modugno.it/
e in particolare la sezione su Palese  http://www.modugno.it/archivio/palese/




More information about the R-help mailing list