Provides educational implementations of one- and two-sample Z tests, Student and Welch t tests, a paired t test, an F test for two variances, and Pearson chi-square tests for goodness of fit, independence, and homogeneity. Functions validate mutually exclusive raw-data and summary-statistics interfaces, return structured htest-compatible results, and optionally display step-by-step graphical explanations.
The TH package provides educational functions for teaching and performing hypothesis tests in R. Each function combines numerical inference with an optional graphical representation of the hypotheses, significance level, critical values, rejection and non-rejection regions, calculated statistic, and decision.
Version 1.0.0 introduces a self-contained interface, input validation, p-values, structured invisible results, executable examples, automated tests, corrected statistical logic, and restoration of graphical parameters.
After publication on CRAN:
install.packages("TH")
From a source archive built locally:
install.packages("TH_1.0.0.tar.gz", repos = NULL, type = "source")
library(TH)
| Function | 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() |
Welch two-sample t test |
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 |
X <- c(11, 12, 13, 12, 14, 13, 12, 15)
result <- tt1(X, mp = 10, alfa = 0.05, Ha = "greater", unidade = " units", plot = FALSE)
result
Numeric alternatives remain available for backward compatibility:
Ha = 1: "two.sided"Ha = 2: "greater"Ha = 3: "less"The F test supports "two.sided" and "greater". The three chi-square
procedures use the standard upper-tail omnibus test and therefore accept
only Ha = 2 or Ha = "greater".
help(package = "TH")
?tz1
browseVignettes("TH")
citation("TH")
From the project root:
source("development/build_and_check.R")
The final CRAN archive must be generated by R CMD build and checked
with R CMD check --as-cran on the resulting TH_1.0.0.tar.gz file.
Willian Silva Barros
Federal University of Pelotas
Email: [email protected]