Mean.test {LearningStats} | R Documentation |
One Sample Mean Test of a Normal Population
Description
Mean.test
allows to compute hypothesis tests for a Normal population mean in both scenarios:
known and unknown population variance.
Usage
Mean.test(x, mu0, sigma = NULL, sc = NULL, s = NULL, n = NULL,
alternative = "two.sided", alpha = 0.05, plot = TRUE, lwd = 1)
Arguments
x |
a numeric vector of data values or, if single number, estimated mean. |
mu0 |
a single number corresponding with the mean to test. |
sigma |
population standard deviation. Defaults to NULL, if specified, a t-test with known variance will be performed. |
sc |
cuasi-standard deviation of sample x. By default computes the cuasi-standard deviation of argument x. |
s |
sample standard deviation of sample x. Defaults to NULL, if provided, it computes the cuasi-standard deviation. |
n |
sample size. By default length of argument x. |
alternative |
a character string specifying the alternative hypothesis, must be one of
" |
alpha |
a single number in (0,1), significance level. |
plot |
a logical value indicating whether to display a graph including the test statistic value for the sample, its distribution, the rejection region and p-value. |
lwd |
single number indicating the line width of the plot. |
Details
The formula interface is applicable when the user provides the sample and also when the user provides the value of the sample characteristics (sample mean, cuasi-standard deviation or sample standard deviation, jointly with the sample size).
Value
A list with class "lstest
" and "htest
" containing the following components:
statistic |
the value of the test statistic. |
parameter |
the degrees of freedom of the statistic's distribution. NULL for the Normal distribution. |
p.value |
the p-value of the test. |
estimate |
the sample mean. |
null.value |
the value specified by the null. |
alternative |
a character string describing the alternative. |
method |
a character string indicating the method used. |
data.name |
a character string giving the names of the data. |
alpha |
the significance level. |
dist.name |
a character string indicating the distribution of the test statistic. |
statformula |
a character string with the statistic's formula. |
reject.region |
a character string with the reject region. |
unit |
a character string with the units. |
Examples
x <- rnorm(50, mean = 4, sd = 2)
#unknown sigma
Mean.test(x, mu0 = 3.5)
Mean.test(mean(x), sc = sd(x), n = length(x), mu0 = 3.5)
#known sigma
Mean.test(x, mu0 = 3.5, sigma = 2)