Kay Cichini
2012-May-04 09:29 UTC
[R] Test if a sample mean of integers with range -inf; inf is different from zero
Hi all, how would you test if a sample mean of integers with range -inf;inf is different from zero: # my sample of integers: c <- c(-3, -1, 0, 1, 0, 3, 4, 10, 12) # is mean of c <> 0?: mean(c) Thanks, Kay [[alternative HTML version deleted]]
R. Michael Weylandt
2012-May-04 10:24 UTC
[R] Test if a sample mean of integers with range -inf; inf is different from zero
mean(c) != 0 But if you mean in a statistical sense... t.test() is one possibility. Michael On Fri, May 4, 2012 at 5:29 AM, Kay Cichini <kay.cichini at gmail.com> wrote:> Hi all, > > how would you test ?if a sample mean of integers with range -inf;inf ?is > different from zero: > > # my sample of integers: > c <- c(-3, -1, 0, 1, 0, 3, 4, 10, 12) > > # is mean of c <> 0?: > mean(c) > > Thanks, > Kay > > ? ? ? ?[[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org 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.
Petr Savicky
2012-May-04 10:38 UTC
[R] Test if a sample mean of integers with range -inf; inf is different from zero
On Fri, May 04, 2012 at 11:29:51AM +0200, Kay Cichini wrote:> Hi all, > > how would you test if a sample mean of integers with range -inf;inf is > different from zero: > > # my sample of integers: > c <- c(-3, -1, 0, 1, 0, 3, 4, 10, 12) > > # is mean of c <> 0?: > mean(c)Hi. It is better to use a name of a vector different from "c", which is a function, which you also use. Testing, whether the sample mean is zero is simple, since one can use mean(c) == 0 or sum(c) == 0 which are equivalent even in the inaccurate computer arithmetic. So, i think, you are asking for a statistical test, whether the true distribution mean is zero on the basis of a sample. Testing this requires some additional information on the distribution. If we do not know anything about the distribution except that the values are integers, then the sample mean can be arbitrarily large even if the distribuition mean is zero. Consider, for example, a uniform distribution on {-M, M} for some very large integer M. Observing a large sample mean does not allow to reject the null hypothesis on any level, since a large mean may have large probability even if the null hypothesis is true. If there is no bound on the values, then testing anything concerning the mean may not be possible, since the expected may not exist. Do you have a reason to think that the true distribution has an expected value? An example of an integer random variable without an expected value is s*X where s is uniform on {-1, 1} and X has value 2^i with probability 2^-i for i a positive integer. Hope this helps. Petr Savicky.