Hi. 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. ------------------------------------ Steven F. Freeman * Center for Organizational Dynamics * University of Pennsylvania * (215) 898-6967 * Fax: (215) 898-8934 * Cell: (215) 802-4680 * stfreema@sas.upenn.edu * http://center.grad.upenn.edu/faculty/freeman.html [[alternative HTML version deleted]]
Hi, You did not specify if data are paired or not, as data are paired you should use option paired=TRUE in t.test(). Variances of the two samples have to be not significatevely different, (see ? var.test) to use t.test, if not you should specify var.equal=FALSE. var.equal: a logical variable indicating whether to treat the two ariances as being equal. If 'TRUE' then the pooled variance is used to estimate the variance otherwise the Welch (or Satterthwaite) approximation to the degrees of freedom is used. paired: a logical indicating whether you want a paired t-test. If 'paired' is 'TRUE' then both 'x' and 'y' must be specified and they must be the same length. Missing values are removed (in pairs if 'paired' is 'TRUE'). If 'var.equal' is 'TRUE' then the pooled estimate of the variance is used. By default, if 'var.equal' is 'FALSE' then the variance is estimated separately for both groups and the Welch modification to the degrees of freedom is used.>From the output of your test you're sending Iunderstand that variances of the two samples are significatively different (Welch Two Sample t-test) and delta values are also significatively different from 0. See ? t.test Regards Vito You wrote: Hi. 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/
As Vito Ricci has already pointed out, the Welsh test is for two group unpaired data with unequal variance assumption. If you have the original data, say x and y, then you can simply do t.test( x, y, paired=FALSE, var.equal=FALSE ). If you do not have the original data, you can still calculate the relevant statistics and p-value as long as you know the group length and variance. 'stats:::t.test.default' shows you the code behind t-test. I think the relevant bits are as follows mx <- 0 my <- 2 mu <- 0 # You will need to fill these with your observed values vy <- var(y) vx <- var(x) ny <- length(y) ny <- length(y) stderrx <- sqrt(vx/nx) stderry <- sqrt(vy/ny) stderr <- sqrt(stderrx^2 + stderry^2) df <- stderr^4/(stderrx^4/(nx - 1) + stderry^4/(ny - 1)) tstat <- (mx - my - mu)/stderr # for two sided alternative pval <- 2 * pt(-abs(tstat), df) alpha <- 1 - conf.level cint <- qt(1 - alpha/2, df) cint <- tstat + c(-cint, cint) cint <- mu + cint * stderr On Wed, 2004-11-24 at 04:28, Steve Freeman wrote:> Hi. > > 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. > > ------------------------------------ > Steven F. Freeman * Center for Organizational Dynamics * University of > Pennsylvania * (215) 898-6967 * Fax: (215) 898-8934 * Cell: (215) 802-4680 * > stfreema at sas.upenn.edu * http://center.grad.upenn.edu/faculty/freeman.html > > > [[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-- Adaikalavan Ramasamy ramasamy at cancer.org.uk Centre for Statistics in Medicine http://www.ihs.ox.ac.uk/csm/ Cancer Research UK Tel : 01865 226 677 Old Road Campus, Headington, Oxford Fax : 01865 226 962
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 withn-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/