Skip to content

SolvingLab/astat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

astat: Intelligent and Easy Statistical Analysis

License: GPL (>=3) R Version

Overview

astat is an R package that provides an intelligent and user-friendly framework for statistical analysis. It automates common statistical tests, model selection, and result interpretation with simplified syntax and adaptive recommendations. The package is designed for both beginners and experienced data analysts who want to perform hypothesis testing and inference efficiently.

Installation

You can install the development version of astat from GitHub:

# Install devtools if not already installed
install.packages("devtools")

# Install astat
devtools::install_github("SolvingLab/astat")

Features

  • Automatic Test Selection: Intelligently selects appropriate statistical tests based on data characteristics
  • Comprehensive Statistical Tests: Supports t-tests, ANOVA, non-parametric tests, chi-square tests, and correlation analysis
  • Flexible Input Formats: Accepts formula interface, variable names, or direct vectors
  • Batch Testing: Tests multiple variables simultaneously with summary reports
  • Effect Size Calculation: Computes Cohen's d, odds ratios, Cramér's V, and other effect size metrics
  • Missing Data Handling: Robust handling of missing values with multiple strategies

Main Functions

stat_continuous()

Performs statistical tests on continuous variables with automatic selection between parametric and non-parametric methods.

Usage:

# Two-group comparison
stat_continuous(weight ~ treatment, data = df)

# Paired comparison
stat_continuous(before ~ after, data = df, paired = TRUE)

# Multiple group comparison (ANOVA or Kruskal-Wallis)
stat_continuous(score ~ group, data = df)

# Batch testing
stat_continuous(data = df, group = "treatment", 
                variables = c("height", "weight", "age"))

Test Selection:

  • Two groups with normal data → t-test
  • Two groups with non-normal data → Wilcoxon test
  • Multiple groups with normal data → ANOVA
  • Multiple groups with non-normal data → Kruskal-Wallis test

stat_categorical()

Performs statistical tests on categorical variables with automatic selection between chi-square, Fisher's exact, and McNemar tests.

Usage:

# Association test
stat_categorical(gender ~ disease, data = df)

# Paired comparison (McNemar test)
stat_categorical(before ~ after, data = df, paired = TRUE)

# Batch testing
stat_categorical(data = df, group = "treatment", 
                 variables = c("smoking", "drinking", "education"))

Test Selection:

  • 2×2 table with paired data → McNemar test
  • 2×2 table with expected frequencies ≥5 → Chi-square test
  • 2×2 table with expected frequencies <5 → Fisher's exact test
  • Larger tables → Chi-square test or simulation-based methods

stat_cor()

Calculates correlation matrices with p-values and supports multiple correlation methods.

Usage:

# Correlation matrix
stat_cor(mtcars[, 1:5])

# Between two sets of variables
stat_cor(mtcars[, 1:3], mtcars[, 4:6])

# With multiple testing correction
stat_cor(data, cor.method = "spearman", 
         p.adjust = TRUE, p.adjust.method = "bonferroni")

Correlation Methods:

  • Pearson (parametric)
  • Spearman (non-parametric)
  • Kendall (non-parametric)

Example

library(astat)

# Create example dataset
df <- data.frame(
  age = rnorm(100, 50, 10),
  weight = rnorm(100, 70, 15),
  height = rnorm(100, 170, 10),
  gender = sample(c("Male", "Female"), 100, replace = TRUE),
  treatment = rep(c("Control", "Treatment"), 50),
  smoking = sample(c("Yes", "No"), 100, replace = TRUE)
)

# Test continuous variables
result1 <- stat_continuous(data = df, group = "treatment", 
                           variables = c("age", "weight", "height"))

# Test categorical variables
result2 <- stat_categorical(data = df, group = "treatment", 
                            variables = c("gender", "smoking"))

# Correlation analysis
result3 <- stat_cor(df[, c("age", "weight", "height")], 
                    cor.method = "pearson", p.adjust = TRUE)

Citation

If you use astat in your research, please cite:

Liu, Z. (2025). astat: Intelligent and Easy Statistical Analysis. 
R package version 1.0.0. https://github.com/SolvingLab/astat

Author

Zaoqu Liu
Email: liuzaoqu@163.com
ORCID: 0000-0002-0452-742X

License

This package is licensed under the GPL (≥ 3) License.

Dependencies

  • R (≥ 3.3.0)
  • dplyr
  • tidyr
  • tibble

Bug Reports and Contributions

To report bugs or request features, please open an issue on the GitHub repository.


© 2025 Zaoqu Liu. All rights reserved.

About

Intelligent and Easy Statistical Analysis

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages