
Last chance! 50% off unlimited learning
Sale ends in
z.test(x, y = NULL, alternative = "two.sided", mu = 0, sigma.x = NULL, sigma.y = NULL, conf.level = 0.95)
NA
s and Inf
s are allowed but will be removed.NA
s and Inf
s are allowed but will be removed."greater"
, "less"
or "two.sided"
, or just the initial letter of each, indicating the
specification of the alternative hypothesis. For one-sample tests, alternative
refers to thex
.y
."htest"
, containing the following components:"z"
.conf.level
.
When alternative is not "two.sided"
, the confidence interval will be half-infinite,
to reflect the interpretation of a confidence interval as the set of all values k
for which one would not reject the null hypothesis that the true mean or difference in
means is k
. Here infinity will be represented by Inf
.mu
. Component
null.value
has a names attribute describing its elements."greater"
, "less"
or "two.sided"
.x
and y
.x
is drawn is mu
. For the standard
two-sample z-tests, the null hypothesis is that the population mean for x
less that for y
is mu
.
The alternative hypothesis in each case indicates the direction of divergence of the
population mean for x
(or difference of means for x
and y
) from mu
(i.e., "greater"
, "less"
, "two.sided"
).conf.int
) can be obtained in the usual
way by inverting the expression for the test statistic. Note however that, as explained
under the description of conf.int
, the confidence interval will be half-infinite
when alternative is not "two.sided"
; infinity will be represented by Inf
.y
is NULL
, a one-sample
z-test is carried out with x
.}
NULL
, a standard
two-sample z-test is performed.}zsum.test
, tsum.test
x <- rnorm(12)
z.test(x,sigma.x=1)
# Two-sided one-sample z-test where the assumed value for
# sigma.x is one. The null hypothesis is that the population
# mean for 'x' is zero. The alternative hypothesis states
# that it is either greater or less than zero. A confidence
# interval for the population mean will be computed.
x <- c(7.8, 6.6, 6.5, 7.4, 7.3, 7., 6.4, 7.1, 6.7, 7.6, 6.8)
y <- c(4.5, 5.4, 6.1, 6.1, 5.4, 5., 4.1, 5.5)
z.test(x, sigma.x=0.5, y, sigma.y=0.5, mu=2)
# Two-sided standard two-sample z-test where both sigma.x
# and sigma.y are both assumed to equal 0.5. The null hypothesis
# is that the population mean for 'x' less that for 'y' is 2.
# The alternative hypothesis is that this difference is not 2.
# A confidence interval for the true difference will be computed.
z.test(x, sigma.x=0.5, y, sigma.y=0.5, conf.level=0.90)
# Two-sided standard two-sample z-test where both sigma.x and
# sigma.y are both assumed to equal 0.5. The null hypothesis
# is that the population mean for 'x' less that for 'y' is zero.
# The alternative hypothesis is that this difference is not
# zero. A 90\% confidence interval for the true difference will
# be computed.
Run the code above in your browser using DataLab