On Thu, 23 Nov 2006, Peter Dalgaard wrote: > Robin Hankin <[EMAIL PROTECTED]> writes: > >> Hi >> >> I have a vector x of length n. I am interested in x[1] >> being different from the other observations (ie x[-1]). >> >> My null hypothesis is that x[1] >> is drawn from a Gaussian distribution of the same >> mean as observations x[-1], which are assumed >> to be iid Gaussian. The (unknown) variance >> of x[1] is assumed to be the same as the >> variance of x[-1]. >> >> >> This should be an unpaired t-test. >> >> But >> >> >> > x <- c(23,25,29,27,30,30) >> > t.test(x=x[1] , y=x[-1]) >> Error in t.test.default(x = x[1], y = x[-1]) : >> not enough 'x' observations >> > >> >> >> >> What arguments do I need to send to t.test() to test my null? > > > You can't. Shouldn't be too much of a problem to modify t.test.default > to stop it complaining. (It's not quite enough to remove the check for > nx < 2, though. You also need to deal with var(x) being NA if x has > length one.)
And the check is correct if var.equal=FALSE, the default. I've got a modification for the case var.equal=TRUE running, and will patch R shortly. > Alternatively, just write up the formula for the t statistic: > >> x <- c(23,25,29,27,30,30) >> (x[1]-mean(x[-1]))/sqrt(var(x[-1])*(1+1/(length(x)-1))) > [1] -2.189595 >> 2*pt(-2.1896,4) > [1] 0.09373392 > > > -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595 ______________________________________________ R-help@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.