z.test for dataframe
Rui answered the main question by pointing out that you need z.test(m, stdev=s(m)), or you could use z.test(m,,sd(m)), but I think the stdev= approach is clearer. But you are really abusing the concept of z tests in general (and the z.test function in particular) by using the sd of the sample. If you use the sd of the sample then you should be doing a t test (and the t.test function does this simpler than the z.test function). The z.test function was designed to use in classes that introduce the concepts of inference using the generally unrealistic (but simpler) case of knowing the population standard deviation, but not the mean. The z.test function was to be a bridge so that the students could use a function that was similar to the t.test function that they would eventually use.
On Wed, Oct 17, 2012 at 12:45 AM, Balqis <aehan3616 at gmail.com> wrote:
Hi!
I'm trying to use sapply to my dataframe for z.test function (teaching
demos package)
Sep=cbind(kIp,k02p,k04p,k07p)
Sep=as.data.frame(Sep)
kzt=sapply(Sep, function(m) z.test(m,sd(m)))
Error in z.test(m, sd(Sep)) :
You must specify a Standard Deviation of the population
kzt=sapply(Sep, function(m) z.test(m,sd(Sep)))
Error in z.test(m, sd(Sep)) :
You must specify a Standard Deviation of the population
#obviously it can't process the z.test because of the sd function embedded
inside the function. can someone point me how to fix this. Many thanks!
[[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.
Gregory (Greg) L. Snow Ph.D. 538280 at gmail.com