Here you will find daily news and tutorials about R, contributed by over 750 bloggers.
There are many ways to follow us - By e-mail:On Facebook: If you are an R blogger yourself you are invited to add your own R content feed to this site (Non-English R bloggers should add themselves- here)

The mean safety audit score of ACME Co. stores in New York (n=200) was 74.3pts February last year. Suppose we decided to sample 22 out of the 200 stores one year later. We find that the sample mean is 78.6pts and the sample standard deviation is 3.2pts. Can we reject the null hypothesis that the sample mean score does not differ from last years true mean? That is to say can we prove that this sample mean is indicative of the population and is explained by probability.

Null hypothesis of a two-tailed test of the population mean is:

where is the hypothesized value of the true population mean

The test statistic or output of the test (t) is defined by the sample mean ( ), size (n), and standard deviation (s).

xbar <- 78.6 # sample mean
mu0 <- 74.3 # hypothesized val
s <- 3.2 # Sample stdev
n <- 22 # Sample size
t <- (xbar-mu0)/(s/sqrt(n))
t # test statistic
[1] 6.302746

Now to compute the range for the .05 significance level:

T, our test statistic of 6.302746 does not lie between the range of -2.079614, and 2.079614. This means we can reject the null hypothesis that the mean score does not differ from last year.

Thanks to zhiqiang for the great WP LaTeX plugin and to Alex for SyntaxHighlighter Evolved.

Related

To leave a comment for the author, please follow the link and comment on their blog: Kevin Davenport » R.