Title: | Deal with One and Two (Normal) Samples |
---|---|
Description: | We introduce an R function one_two_sample() which can deal with one and two (normal) samples, Ying-Ying Zhang, Yi Wei (2012) <doi:10.2991/asshm-13.2013.29>. For one normal sample x, the function reports descriptive statistics, plot, interval estimation and test of hypothesis of x. For two normal samples x and y, the function reports descriptive statistics, plot, interval estimation and test of hypothesis of x and y, respectively. It also reports interval estimation and test of hypothesis of mu1-mu2 (the difference of the means of x and y) and sigma1^2 / sigma2^2 (the ratio of the variances of x and y), tests whether x and y are from the same population, finds the correlation coefficient of x and y if x and y have the same length. |
Authors: | Frederic Bertrand [cre] , Ying-Ying Zhang (Robert) [aut] |
Maintainer: | Frederic Bertrand <[email protected]> |
License: | GPL (>= 2) |
Version: | 1.1-0 |
Built: | 2025-01-29 04:07:40 UTC |
Source: | https://github.com/cran/OneTwoSamples |
In this package, we introduce an R function one_two_sample() which can deal with one and two (normal) samples, Ying-Ying Zhang, Yi Wei (2012), doi:10.2991/asshm-13.2013.29. For one normal sample x, the function reports descriptive statistics, plot, interval estimation and test of hypothesis of x. For two normal samples x and y, the function reports descriptive statistics, plot, interval estimation and test of hypothesis of x and y, respectively. It also reports interval estimation and test of hypothesis of mu1-mu2 (the difference of the means of x and y) and sigma1^2/sigma2^2 (the ratio of the variances of x and y), tests whether x and y are from the same population, finds the correlation coefficient of x and y if x and y have the same length.
Package: | OneTwoSamples |
Type: | Package |
Version: | 1.1-0 |
Date: | 2023-03-22 |
License: | GPL (>= 2) |
The most important functions are: one_two_sample() and one_sample().
Ying-Ying Zhang (Robert)
Maintainer: Frederic Bertrand <[email protected]>
Zhang, Y. Y., Wei, Y. (2013), One and two samples using only an R funtion, doi:10.2991/asshm-13.2013.29.
library("OneTwoSamples")
library("OneTwoSamples")
Compute various descriptive statistics of x, such as mean, median, skewness, and kurtosis, etc.
data_outline(x)
data_outline(x)
x |
A numeric vector. |
A data.frame with variables:
N |
The length. |
Mean |
The mean. |
Var |
The variance. |
std_dev |
Standard deviation. |
Median |
The median. |
std_mean |
The standard error of the sample mean. |
CV |
The coefficient of variation. |
CSS |
The corrected sum of squares. |
USS |
The uncorrected sum of squares. |
R |
The extreme difference. |
R1 |
The half extreme difference, or the difference of upper quartile and lower quartile. |
Skewness |
The coefficient of skewness. |
Kurtosis |
The coefficient of kurtosis. |
row.names |
1. |
Ying-Ying Zhang (Robert) [email protected]
Zhang, Y. Y., Wei, Y. (2013), One and two samples using only an R funtion, doi:10.2991/asshm-13.2013.29.
x=rnorm(10, mean = 1, sd = 0.2); x data_outline(x)
x=rnorm(10, mean = 1, sd = 0.2); x data_outline(x)
Show details of an object.
detail(x)
detail(x)
x |
Any |
A list with components:
x |
The argument |
isS4 |
Logical, indicates whether |
isObject |
Logical, indicates whether |
class |
The class of |
attributes |
The attributes of |
Ying-Ying Zhang (Robert) [email protected]
Zhang, Y. Y., Wei, Y. (2013), One and two samples using only an R funtion, doi:10.2991/asshm-13.2013.29.
isS4
, is.object
, class
, attributes
x=rnorm(10, mean = 1, sd = 0.2); x t = t.test(x); t detail(t)
x=rnorm(10, mean = 1, sd = 0.2); x t = t.test(x); t detail(t)
mu
of one normal sample
Compute the two sided interval estimation of mu
of one normal sample when the population variance is known or unknown.
interval_estimate1(x, sigma = -1, alpha = 0.05)
interval_estimate1(x, sigma = -1, alpha = 0.05)
x |
A numeric vector. |
sigma |
The standard deviation of the population. |
alpha |
The significance level, a real number in [0, 1]. Default to 0.05. 1-alpha is the degree of confidence. |
A data.frame with variables:
mean |
The sample mean. |
df |
The degree of freedom. |
a |
The confidence lower limit. |
b |
The confidence upper limit. |
Ying-Ying Zhang (Robert) [email protected]
Zhang, Y. Y., Wei, Y. (2013), One and two samples using only an R funtion, doi:10.2991/asshm-13.2013.29.
x=rnorm(10, mean = 1, sd = 0.2); x interval_estimate1(x, sigma = 0.2) interval_estimate1(x)
x=rnorm(10, mean = 1, sd = 0.2); x interval_estimate1(x, sigma = 0.2) interval_estimate1(x)
mu1-mu2
of two normal samples
Compute the two sided interval estimation of mu1-mu2
of two normal samples when the population variances are known, unknown equal, or unknown unequal.
interval_estimate2(x, y, sigma = c(-1, -1), var.equal = FALSE, alpha = 0.05)
interval_estimate2(x, y, sigma = c(-1, -1), var.equal = FALSE, alpha = 0.05)
x |
A numeric vector. |
y |
A numeric vector. |
sigma |
A numeric vector of length 2, which contains the standard deviations of two populations. When the standard deviations are known, input it, then the function computes the interval endpoints using normal population; when the standard deviations are unknown, ignore it, now we need to consider whether the two populations have equal variances. See |
var.equal |
A logical variable indicating whether to treat the two variances as being equal. If |
alpha |
The significance level, a real number in [0, 1]. Default to 0.05. 1-alpha is the degree of confidence. |
A data.frame with variables:
mean |
The difference of sample means xb-yb. |
df |
The degree of freedom. |
a |
The confidence lower limit. |
b |
The confidence upper limit. |
Ying-Ying Zhang (Robert) [email protected]
Zhang, Y. Y., Wei, Y. (2013), One and two samples using only an R funtion, doi:10.2991/asshm-13.2013.29.
x=rnorm(10, mean = 1, sd = 0.2); x y=rnorm(20, mean = 2, sd = 0.3); y interval_estimate2(x, y, sigma = c(0.2, 0.3)) interval_estimate2(x, y, var.equal = TRUE) interval_estimate2(x, y)
x=rnorm(10, mean = 1, sd = 0.2); x y=rnorm(20, mean = 2, sd = 0.3); y interval_estimate2(x, y, sigma = c(0.2, 0.3)) interval_estimate2(x, y, var.equal = TRUE) interval_estimate2(x, y)
mu
of one non-normal sample with large sample size
Compute the two sided interval estimation of mu
of one non-normal sample with large sample size when the population variance is known or unknown.
interval_estimate3(x, sigma = -1, alpha = 0.05)
interval_estimate3(x, sigma = -1, alpha = 0.05)
x |
A numeric vector. |
sigma |
The standard deviation of the population. |
alpha |
The significance level, a real number in [0, 1]. Default to 0.05. 1-alpha is the degree of confidence. |
A data.frame with variables:
mean |
The sample mean. |
a |
The confidence lower limit. |
b |
The confidence upper limit. |
Ying-Ying Zhang (Robert) [email protected]
Zhang, Y. Y., Wei, Y. (2013), One and two samples using only an R funtion, doi:10.2991/asshm-13.2013.29.
x = rexp(50, 1/2); x interval_estimate3(x)
x = rexp(50, 1/2); x interval_estimate3(x)
mu
of one normal sample
Compute the two sided or one sided interval estimation of mu
of one normal sample when the population variance is known or unknown.
interval_estimate4(x, sigma = -1, side = 0, alpha = 0.05)
interval_estimate4(x, sigma = -1, side = 0, alpha = 0.05)
x |
A numeric vector. |
sigma |
The standard deviation of the population. |
side |
A parameter used to control whether to compute two sided or one sided interval estimation. When computing the one sided upper limit, input |
alpha |
The significance level, a real number in [0, 1]. Default to 0.05. 1-alpha is the degree of confidence. |
A data.frame with variables:
mean |
The sample mean. |
df |
The degree of freedom. |
a |
The confidence lower limit. |
b |
The confidence upper limit. |
Ying-Ying Zhang (Robert) [email protected]
Zhang, Y. Y., Wei, Y. (2013), One and two samples using only an R funtion, doi:10.2991/asshm-13.2013.29.
x=rnorm(10, mean = 1, sd = 0.2); x interval_estimate4(x, sigma = 0.2, side = -1) interval_estimate4(x, side = 1)
x=rnorm(10, mean = 1, sd = 0.2); x interval_estimate4(x, sigma = 0.2, side = -1) interval_estimate4(x, side = 1)
mu1-mu2
of two normal samples
Compute the two sided or one sided interval estimation of mu1-mu2
of two normal samples when the population variances are known, unknown equal, or unknown unequal.
interval_estimate5(x, y, sigma = c(-1, -1), var.equal = FALSE, side = 0, alpha = 0.05)
interval_estimate5(x, y, sigma = c(-1, -1), var.equal = FALSE, side = 0, alpha = 0.05)
x |
A numeric vector. |
y |
A numeric vector. |
sigma |
A numeric vector of length 2, which contains the standard deviations of two populations. When the standard deviations are known, input it, then the function computes the interval endpoints using normal population; when the standard deviations are unknown, ignore it, now we need to consider whether the two populations have equal variances. See |
var.equal |
A logical variable indicating whether to treat the two variances as being equal. If |
side |
A parameter used to control whether to compute two sided or one sided interval estimation. When computing the one sided upper limit, input |
alpha |
The significance level, a real number in [0, 1]. Default to 0.05. 1-alpha is the degree of confidence. |
A data.frame with variables:
mean |
The difference of sample means xb-yb. |
df |
The degree of freedom. |
a |
The confidence lower limit. |
b |
The confidence upper limit. |
Ying-Ying Zhang (Robert) [email protected]
Zhang, Y. Y., Wei, Y. (2013), One and two samples using only an R funtion, doi:10.2991/asshm-13.2013.29.
x=rnorm(10, mean = 1, sd = 0.2); x y=rnorm(20, mean = 2, sd = 0.3); y interval_estimate5(x, y, sigma = c(0.2, 0.3), side = -1) interval_estimate5(x, y, var.equal = TRUE) interval_estimate5(x, y)
x=rnorm(10, mean = 1, sd = 0.2); x y=rnorm(20, mean = 2, sd = 0.3); y interval_estimate5(x, y, sigma = c(0.2, 0.3), side = -1) interval_estimate5(x, y, var.equal = TRUE) interval_estimate5(x, y)
sigma^2
of one normal sample
Compute the two sided interval estimation of sigma^2
of one normal sample when the population mean is known or unknown.
interval_var1(x, mu = Inf, alpha = 0.05)
interval_var1(x, mu = Inf, alpha = 0.05)
x |
A numeric vector. |
mu |
The population mean. When it is known, input it, and the function computes the interval endpoints using a chi-square distribution with degree of freedom |
alpha |
The significance level, a real number in [0, 1]. Default to 0.05. 1-alpha is the degree of confidence. |
A data.frame with variables:
var |
The estimate of the population variance. When the population mean |
df |
The degree of freedom. |
a |
The confidence lower limit. |
b |
The confidence upper limit. |
Ying-Ying Zhang (Robert) [email protected]
Zhang, Y. Y., Wei, Y. (2013), One and two samples using only an R funtion, doi:10.2991/asshm-13.2013.29.
x=rnorm(10, mean = 1, sd = 0.2); x interval_var1(x, mu = 1) interval_var1(x)
x=rnorm(10, mean = 1, sd = 0.2); x interval_var1(x, mu = 1) interval_var1(x)
sigma1^2 / sigma2^2
of two normal samples
Compute the two sided interval estimation of sigma1^2 / sigma2^2
of two normal samples when the population means are known or unknown.
interval_var2(x, y, mu = c(Inf, Inf), alpha = 0.05)
interval_var2(x, y, mu = c(Inf, Inf), alpha = 0.05)
x |
A numeric vector. |
y |
A numeric vector. |
mu |
The population means. When it is known, input it, and the function computes the interval endpoints using an F distribution with degree of freedom |
alpha |
The significance level, a real number in [0, 1]. Default to 0.05. 1-alpha is the degree of confidence. |
A data.frame with variables:
rate |
The estimate of the ratio of population variances, |
df1 |
The first degree of freedom. |
df2 |
The second degree of freedom. |
a |
The confidence lower limit. |
b |
The confidence upper limit. |
Ying-Ying Zhang (Robert) [email protected]
Zhang, Y. Y., Wei, Y. (2013), One and two samples using only an R funtion, doi:10.2991/asshm-13.2013.29.
x=rnorm(10, mean = 1, sd = 0.2); x y=rnorm(20, mean = 2, sd = 0.3); y interval_var2(x, y, mu = c(1,2)) interval_var2(x, y)
x=rnorm(10, mean = 1, sd = 0.2); x y=rnorm(20, mean = 2, sd = 0.3); y interval_var2(x, y, mu = c(1,2)) interval_var2(x, y)
sigma^2
of one normal sample
Compute the two sided or one sided interval estimation of sigma^2
of one normal sample when the population mean is known or unknown.
interval_var3(x, mu = Inf, side = 0, alpha = 0.05)
interval_var3(x, mu = Inf, side = 0, alpha = 0.05)
x |
A numeric vector. |
mu |
The population mean. When it is known, input it, and the function computes the interval endpoints using a chi-square distribution with degree of freedom |
side |
A parameter used to control whether to compute two sided or one sided interval estimation. When computing the one sided upper limit, input |
alpha |
The significance level, a real number in [0, 1]. Default to 0.05. 1-alpha is the degree of confidence. |
A data.frame with variables:
var |
The estimate of the population variance. When the population mean |
df |
The degree of freedom. |
a |
The confidence lower limit. |
b |
The confidence upper limit. |
Ying-Ying Zhang (Robert) [email protected]
Zhang, Y. Y., Wei, Y. (2013), One and two samples using only an R funtion, doi:10.2991/asshm-13.2013.29.
x=rnorm(10, mean = 1, sd = 0.2); x interval_var3(x, mu = 1, side = -1) interval_var3(x)
x=rnorm(10, mean = 1, sd = 0.2); x interval_var3(x, mu = 1, side = -1) interval_var3(x)
sigma1^2 / sigma2^2
of two normal samples
Compute the two sided or one sided interval estimation of sigma1^2 / sigma2^2
of two normal samples when the population means are known or unknown.
interval_var4(x, y, mu = c(Inf, Inf), side = 0, alpha = 0.05)
interval_var4(x, y, mu = c(Inf, Inf), side = 0, alpha = 0.05)
x |
A numeric vector. |
y |
A numeric vector. |
mu |
The population means. When it is known, input it, and the function computes the interval endpoints using an F distribution with degree of freedom |
side |
A parameter used to control whether to compute two sided or one sided interval estimation. When computing the one sided upper limit, input |
alpha |
The significance level, a real number in [0, 1]. Default to 0.05. 1-alpha is the degree of confidence. |
A data.frame with variables:
rate |
The estimate of the ratio of population variances, |
df1 |
The first degree of freedom. |
df2 |
The second degree of freedom. |
a |
The confidence lower limit. |
b |
The confidence upper limit. |
Ying-Ying Zhang (Robert) [email protected]
Zhang, Y. Y., Wei, Y. (2013), One and two samples using only an R funtion, doi:10.2991/asshm-13.2013.29.
x=rnorm(10, mean = 1, sd = 0.2); x y=rnorm(20, mean = 2, sd = 0.3); y interval_var4(x, y, mu = c(1,2), side = -1) interval_var4(x, y)
x=rnorm(10, mean = 1, sd = 0.2); x y=rnorm(20, mean = 2, sd = 0.3); y interval_var4(x, y, mu = c(1,2), side = -1) interval_var4(x, y)
mu
of one normal sample
Compute the two sided or one sided test of hypothesis of mu
of one normal sample when the population variance is known or unknown.
mean_test1(x, mu = 0, sigma = -1, side = 0)
mean_test1(x, mu = 0, sigma = -1, side = 0)
x |
A numeric vector. |
mu |
|
sigma |
The standard deviation of the population. |
side |
A parameter used to control two sided or one sided test of hypothesis. When inputting |
A data.frame with variables:
mean |
The sample mean. |
df |
The degree of freedom. |
statistic |
The statistic, when |
p_value |
The P value. |
Ying-Ying Zhang (Robert) [email protected]
Zhang, Y. Y., Wei, Y. (2013), One and two samples using only an R funtion, doi:10.2991/asshm-13.2013.29.
x=rnorm(10, mean = 1, sd = 0.2); x mean_test1(x, mu = 1, sigma = 0.2, side = 1) mean_test1(x, mu = 1)
x=rnorm(10, mean = 1, sd = 0.2); x mean_test1(x, mu = 1, sigma = 0.2, side = 1) mean_test1(x, mu = 1)
mu1
and mu2
of two normal samples
Compute the two sided or one sided test of hypothesis of mu1
and mu2
of two normal samples when the population variances are known, unknown equal, or unknown unequal.
mean_test2(x, y, sigma = c(-1, -1), var.equal = FALSE, side = 0)
mean_test2(x, y, sigma = c(-1, -1), var.equal = FALSE, side = 0)
x |
A numeric vector. |
y |
A numeric vector. |
sigma |
A numeric vector of length 2, which contains the standard deviations of two populations. When the standard deviations are known, input it, then the function computes the interval endpoints using normal population; when the standard deviations are unknown, ignore it, now we need to consider whether the two populations have equal variances. See |
var.equal |
A logical variable indicating whether to treat the two variances as being equal. If |
side |
A parameter used to control two sided or one sided test of hypothesis. When inputting |
A data.frame with variables:
mean |
The difference of sample means xb-yb. |
df |
The degree of freedom. |
statistic |
The statistic, when |
p_value |
The P value. |
Ying-Ying Zhang (Robert) [email protected]
Zhang, Y. Y., Wei, Y. (2013), One and two samples using only an R funtion, doi:10.2991/asshm-13.2013.29.
x=rnorm(10, mean = 1, sd = 0.2); x y=rnorm(20, mean = 2, sd = 0.3); y mean_test2(x, y, sigma = c(0.2, 0.3), side = 1) mean_test2(x, y, var.equal = TRUE, side = 1) mean_test2(x, y, side = 1)
x=rnorm(10, mean = 1, sd = 0.2); x y=rnorm(20, mean = 2, sd = 0.3); y mean_test2(x, y, sigma = c(0.2, 0.3), side = 1) mean_test2(x, y, var.equal = TRUE, side = 1) mean_test2(x, y, side = 1)
Deal with one sample x
, especially normal. Report descriptive statistics, plot, interval estimation and test of hypothesis of x
.
one_sample(x, mu = Inf, sigma = -1, side = 0, alpha = 0.05)
one_sample(x, mu = Inf, sigma = -1, side = 0, alpha = 0.05)
x |
A numeric vector. |
mu |
In two sided or one sided interval estimation (or test of hypothesis) of In two sided or one sided test of hypothesis of |
sigma |
In two sided or one sided interval estimation (or test of hypothesis) of In two sided or one sided test of hypothesis of |
side |
In two sided or one sided interval estimation of In two sided or one sided interval estimation of In two sided or one sided test of hypothesis of In two sided or one sided test of hypothesis of |
alpha |
The significance level, a real number in [0, 1]. Default to 0.05. 1-alpha is the degree of confidence. |
A list with the following components:
mu_interval |
It contains the results of interval estimation of |
mu_hypothesis |
It contains the results of test of hypothesis of |
sigma_interval |
It contains the results of interval estimation of |
sigma_hypothesis |
It contains the results of test of hypothesis of |
Ying-Ying Zhang (Robert) [email protected]
Zhang, Y. Y., Wei, Y. (2013), One and two samples using only an R funtion, doi:10.2991/asshm-13.2013.29.
x=rnorm(10, mean = 1, sd = 0.2); x one_sample(x, mu = 1, sigma = 0.2, side = 1) one_sample(x, sigma = 0.2, side = 1) one_sample(x, mu = 1, side = 1) one_sample(x)
x=rnorm(10, mean = 1, sd = 0.2); x one_sample(x, mu = 1, sigma = 0.2, side = 1) one_sample(x, sigma = 0.2, side = 1) one_sample(x, mu = 1, side = 1) one_sample(x)
Deal with one and two (normal) samples. For one normal sample x, the function reports descriptive statistics, plot, interval estimation and test of hypothesis of x. For two normal samples x and y, the function reports descriptive statistics, plot, interval estimation and test of hypothesis of x and y, respectively. It also reports interval estimation and test of hypothesis of mu1-mu2 (the difference of the means of x and y) and sigma1^2/sigma2^2 (the ratio of the variances of x and y), tests whether x and y are from the same population, finds the correlation coefficient of x and y if x and y have the same length.
one_two_sample(x, y = NULL, mu = c(Inf, Inf), sigma = c(-1, -1), var.equal = FALSE, ratio = 1, side = 0, alpha = 0.05)
one_two_sample(x, y = NULL, mu = c(Inf, Inf), sigma = c(-1, -1), var.equal = FALSE, ratio = 1, side = 0, alpha = 0.05)
x |
A numeric vector. |
y |
A numeric vector. |
mu |
If |
sigma |
If |
var.equal |
A logical variable indicating whether to treat the two variances as being equal. If |
ratio |
The hypothesized ratio of the population variances of |
side |
If |
alpha |
The significance level, a real number in [0, 1]. Default to 0.05. 1-alpha is the degree of confidence. |
A list with the following components:
one_sample_x |
It contains the results by |
one_sample_y |
It contains the results by |
mu1_mu2_interval |
It contains the results of interval estimation of |
mu1_mu2_hypothesis |
It contains the results of test of hypothesis of |
sigma_ratio_interval |
It contains the results of interval estimation of |
sigma_ratio_hypothesis |
It contains the results of test of hypothesis of |
res.ks |
It contains the results of |
res.binom |
It contains the results of |
res.wilcox |
It contains the results of |
cor.pearson |
It contains the results of |
cor.kendall |
It contains the results of |
cor.spearman |
It contains the results of |
Ying-Ying Zhang (Robert) [email protected]
Zhang, Y. Y., Wei, Y. (2013), One and two samples using only an R funtion, doi:10.2991/asshm-13.2013.29.
## One sample x=rnorm(10, mean = 1, sd = 0.2); x ## one_sample(x, ...) == one_two_sample(x, ...) one_sample(x, mu = 1, sigma = 0.2, side = 1) one_two_sample(x, mu = 1, sigma = 0.2, side = 1) one_sample(x, sigma = 0.2, side = 1) one_two_sample(x, sigma = 0.2, side = 1) one_sample(x, mu = 1, side = 1) one_two_sample(x, mu = 1, side = 1) one_sample(x) one_two_sample(x) ## Two samples set.seed(1) x=rnorm(10, mean = 1, sd = 0.2); x y=rnorm(20, mean = 2, sd = 0.3); y y2=rnorm(20, mean = 2, sd = 0.2); y2 ## sigma1, sigma2 known; mu1, mu2 known one_two_sample(x, y, sigma = c(0.2, 0.3), mu = c(1, 2)) ## sigma1 = sigma2 unknown; mu1, mu2 known one_two_sample(x, y2, var.equal = TRUE, mu = c(1, 2)) ## sigma1 != sigma2 unknown; mu1, mu2 known one_two_sample(x, y, mu = c(1, 2)) ## sigma1, sigma2 known; mu1, mu2 unknown one_two_sample(x, y, sigma = c(0.2, 0.3)) ## sigma1 = sigma2 unknown; mu1, mu2 unknown one_two_sample(x, y2, var.equal = TRUE) ## sigma1 != sigma2 unknown; mu1, mu2 unknown one_two_sample(x, y)
## One sample x=rnorm(10, mean = 1, sd = 0.2); x ## one_sample(x, ...) == one_two_sample(x, ...) one_sample(x, mu = 1, sigma = 0.2, side = 1) one_two_sample(x, mu = 1, sigma = 0.2, side = 1) one_sample(x, sigma = 0.2, side = 1) one_two_sample(x, sigma = 0.2, side = 1) one_sample(x, mu = 1, side = 1) one_two_sample(x, mu = 1, side = 1) one_sample(x) one_two_sample(x) ## Two samples set.seed(1) x=rnorm(10, mean = 1, sd = 0.2); x y=rnorm(20, mean = 2, sd = 0.3); y y2=rnorm(20, mean = 2, sd = 0.2); y2 ## sigma1, sigma2 known; mu1, mu2 known one_two_sample(x, y, sigma = c(0.2, 0.3), mu = c(1, 2)) ## sigma1 = sigma2 unknown; mu1, mu2 known one_two_sample(x, y2, var.equal = TRUE, mu = c(1, 2)) ## sigma1 != sigma2 unknown; mu1, mu2 known one_two_sample(x, y, mu = c(1, 2)) ## sigma1, sigma2 known; mu1, mu2 unknown one_two_sample(x, y, sigma = c(0.2, 0.3)) ## sigma1 = sigma2 unknown; mu1, mu2 unknown one_two_sample(x, y2, var.equal = TRUE) ## sigma1 != sigma2 unknown; mu1, mu2 unknown one_two_sample(x, y)
Compute the P value of a cumulative distribution function (cdf).
p_value(cdf, x, paramet = numeric(0), side = 0)
p_value(cdf, x, paramet = numeric(0), side = 0)
cdf |
The cumulative distribution function. For normal distribution, |
x |
A given value to compute the P value. |
paramet |
The parameter of the corresponding distribution. For normal distribution, |
side |
A parameter indicating whether to compute one sided or two sided P value. When inputting |
The P value.
Ying-Ying Zhang (Robert) [email protected]
Zhang, Y. Y., Wei, Y. (2013), One and two samples using only an R funtion, doi:10.2991/asshm-13.2013.29.
p_value(pnorm, x = 0, side = 1) p_value(pt, x = 0, paramet = 5, side = 1)
p_value(pnorm, x = 0, side = 1) p_value(pt, x = 0, paramet = 5, side = 1)
sigma^2
of one normal sample
Compute the two sided or one sided test of hypothesis of sigma^2
of one normal sample when the population mean is known or unknown.
var_test1(x, sigma2 = 1, mu = Inf, side = 0)
var_test1(x, sigma2 = 1, mu = Inf, side = 0)
x |
A numeric vector. |
sigma2 |
|
mu |
The population mean. |
side |
A parameter used to control two sided or one sided test of hypothesis. When inputting |
A data.frame with variables:
var |
The estimate of the population variance. When the population mean |
df |
The degree of freedom. |
chisq2 |
The chisquare statistic. |
p_value |
The P value. |
Ying-Ying Zhang (Robert) [email protected]
Zhang, Y. Y., Wei, Y. (2013), One and two samples using only an R funtion, doi:10.2991/asshm-13.2013.29.
x=rnorm(10, mean = 1, sd = 0.2); x var_test1(x, sigma2 = 0.2^2, mu = 1, side = 1) var_test1(x, sigma2 = 0.2^2, side = 1)
x=rnorm(10, mean = 1, sd = 0.2); x var_test1(x, sigma2 = 0.2^2, mu = 1, side = 1) var_test1(x, sigma2 = 0.2^2, side = 1)
sigma1^2
and sigma2^2
of two normal samples
Compute the two sided or one sided test of hypothesis of sigma1^2
and sigma2^2
of two normal samples when the population means are known or unknown.
var_test2(x, y, mu = c(Inf, Inf), side = 0)
var_test2(x, y, mu = c(Inf, Inf), side = 0)
x |
A numeric vector. |
y |
A numeric vector. |
mu |
The population means. When it is known, input it, and the function computes the F value using an F distribution with degree of freedom |
side |
A parameter used to control two sided or one sided test of hypothesis. When inputting |
A data.frame with variables:
rate |
The estimate of the ratio of population variances, |
df1 |
The first degree of freedom. |
df2 |
The second degree of freedom. |
F |
The F statistic. |
p_value |
The P value. |
Ying-Ying Zhang (Robert) [email protected]
Zhang, Y. Y., Wei, Y. (2013), One and two samples using only an R funtion, doi:10.2991/asshm-13.2013.29.
x=rnorm(10, mean = 1, sd = 0.2); x y=rnorm(20, mean = 2, sd = 0.3); y var_test2(x, y, mu = c(1, 2), side = 1) var_test2(x, y, side = 1)
x=rnorm(10, mean = 1, sd = 0.2); x y=rnorm(20, mean = 2, sd = 0.3); y var_test2(x, y, mu = c(1, 2), side = 1) var_test2(x, y, side = 1)