The TH package was developed to support the teaching and learning of hypothesis testing in R. Each function presents a graphical sequence containing the null and alternative hypotheses, significance level, reference distribution, critical values, rejection and non-rejection regions, calculated statistic, and statistical decision.
Version 1.0.0 preserves the educational graphical approach while
correcting unsafe argument defaults, directional F-test logic,
chi-square formulations, Welch degrees of freedom, input validation,
graphical side effects, and inferential wording. Numeric Ha
values remain supported for backward compatibility.
| Function | Statistical procedure |
|---|---|
tz1() |
One-Sample Z Test |
tz2() |
Two-Sample Z Test |
tt1() |
One-Sample t Test |
tt2i() |
Two-Sample t Test with Equal Variances |
tt2d() |
Two-Sample t Test with Unequal Variances |
tt2p() |
Paired t Test |
tf2() |
F Test for Two Variances |
tq2a() |
Chi-Square Goodness-of-Fit Test |
tq2i() |
Chi-Square Test of Independence |
tq2h() |
Chi-Square Test of Homogeneity |
Ha argumentFor tests concerning means, Ha = 1 selects a two-sided
test, Ha = 2 a right-tailed test, and Ha = 3 a
left-tailed test. The equivalent character values are
"two.sided", "greater", and
"less". In tf2(), only two-sided and
right-tailed alternatives are supported. The three chi-square procedures
use only the standard upper-tail omnibus test, so Ha must
be 2 or "greater".
| Statistical situation | Function |
|---|---|
| One mean and known population variance | tz1() |
| Two means and known population variances | tz2() |
| One mean and unknown population variance | tt1() |
| Two independent means with equal variances | tt2i() |
| Two independent means with unequal variances | tt2d() |
| Two paired measurements | tt2p() |
| Two variances | tf2() |
| Observed versus expected frequencies | tq2a() |
| Association between two categorical variables | tq2i() |
| Homogeneity across groups or populations | tq2h() |
Performs a Z test for one population mean when the population variance is known.
X <- c(52, 49, 51, 50, 53, 54, 48, 52, 51, 50)
tz1(X, mp = 50, vp = 4, alfa = 0.05, Ha = 1, unidade = " units")
## Two-Sample Z Test
Performs a Z test for comparing two population means when both population variances are known.
Performs Student’s t test for one population mean when the population variance is unknown.
Compares two independent population means under the assumption of equal population variances.
Compares two independent population means without assuming equal population variances.
Performs a t test for two dependent or paired measurements.
Performs an F test for comparing two population variances.
Compares observed frequencies with expected frequencies for mutually exclusive categories.
Assesses the association between two categorical variables.
Read the output in the following order:
Failure to reject the null hypothesis does not prove that it is true. It indicates that the data did not provide sufficient evidence to reject it at the selected significance level.
The appropriate test must be selected according to the sampling design, independence of observations, distributional assumptions, knowledge of population variances, equality of variances when required, and adequacy of expected frequencies in chi-square procedures.
Version 1.0.0 is an educational implementation with validated inputs, executable examples, automated regression tests, structured invisible results, and optional graphical output. Raw-data and summary-statistics modes are mutually exclusive. Users remain responsible for checking study design and statistical assumptions.
sessionInfo()
#> R version 4.6.1 (2026-06-24 ucrt)
#> Platform: x86_64-w64-mingw32/x64
#> Running under: Windows 11 x64 (build 26200)
#>
#> Matrix products: default
#> LAPACK version 3.12.1
#>
#> locale:
#> [1] LC_COLLATE=C LC_CTYPE=Portuguese_Brazil.utf8
#> [3] LC_MONETARY=Portuguese_Brazil.utf8 LC_NUMERIC=C
#> [5] LC_TIME=Portuguese_Brazil.utf8
#>
#> time zone: America/Sao_Paulo
#> tzcode source: internal
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] TH_1.0.0
#>
#> loaded via a namespace (and not attached):
#> [1] digest_0.6.39 R6_2.6.1 fastmap_1.2.0 xfun_0.59
#> [5] cachem_1.1.0 knitr_1.51 htmltools_0.5.9 rmarkdown_2.31
#> [9] lifecycle_1.0.5 cli_3.6.6 sass_0.4.10 jquerylib_0.1.4
#> [13] compiler_4.6.1 rstudioapi_0.19.0 tools_4.6.1 evaluate_1.0.5
#> [17] bslib_0.11.0 yaml_2.3.12 otel_0.2.0 jsonlite_2.0.0
#> [21] rlang_1.3.0