Coder Social home page Coder Social logo

rsquaredacademy / inferr Goto Github PK

View Code? Open in Web Editor NEW
36.0 5.0 8.0 1.52 MB

Parametric and non-parametric statistical tests

Home Page: https://inferr.rsquaredacademy.com/

License: Other

R 100.00%
inferential-statistics statistical-tests rstats parametric non-parametric inference

inferr's Introduction

inferr

Tools for Statistical Inference

CRAN_Status_Badge cran checks R build status Coverage status status Lifecycle: stable

Overview

inferr builds upon the statistical tests provided in stats, provides additional and flexible input options and more detailed and structured test results. As of version 0.3, inferr includes a select set of parametric and non-parametric statistical tests which are listed below:

  • One Sample t Test
  • Paired Sample t Test
  • Independent Sample t Test
  • One Sample Proportion Test
  • Two Sample Proportion Test
  • One Sample Variance Test
  • Two Sample Variance Test
  • Binomial Test
  • ANOVA
  • Chi Square Goodness of Fit Test
  • Chi Square Independence Test
  • Levene’s Test
  • Cochran’s Q Test
  • McNemar Test
  • Runs Test for Randomness

Installation

# install inferr from CRAN
install.packages("inferr")

# the development version from github
# install.packages("devtools")
devtools::install_github("rsquaredacademy/inferr")

Articles

Usage

One Sample t Test

infer_os_t_test(hsb, write, mu = 50, type = 'all')
#>                               One-Sample Statistics                               
#> ---------------------------------------------------------------------------------
#>  Variable    Obs     Mean     Std. Err.    Std. Dev.    [95% Conf. Interval] 
#> ---------------------------------------------------------------------------------
#>   write      200    52.775     0.6702       9.4786       51.4537    54.0969   
#> ---------------------------------------------------------------------------------
#> 
#>                                   Two Tail Test                                  
#>                                  ---------------                                  
#> 
#>                                Ho: mean(write) ~=50                              
#>                                Ha: mean(write) !=50                               
#> --------------------------------------------------------------------------------
#>  Variable      t      DF       Sig       Mean Diff.    [95% Conf. Interval] 
#> --------------------------------------------------------------------------------
#>   write      4.141    199    0.00005       2.775         1.4537     4.0969   
#> --------------------------------------------------------------------------------

ANOVA

infer_oneway_anova(hsb, write, prog)
#>                                 ANOVA                                  
#> ----------------------------------------------------------------------
#>                    Sum of                                             
#>                    Squares     DF     Mean Square      F        Sig.  
#> ----------------------------------------------------------------------
#> Between Groups    3175.698      2      1587.849      21.275      0    
#> Within Groups     14703.177    197      74.635                        
#> Total             17878.875    199                                    
#> ----------------------------------------------------------------------
#> 
#>                  Report                   
#> -----------------------------------------
#> Category     N       Mean      Std. Dev. 
#> -----------------------------------------
#>    1        45      51.333       9.398   
#>    2        105     56.257       7.943   
#>    3        50      46.760       9.319   
#> -----------------------------------------
#> 
#> Number of obs = 200       R-squared     = 0.1776 
#> Root MSE      = 8.6392    Adj R-squared = 0.1693

Chi Square Test of Independence

infer_chisq_assoc_test(hsb, female, schtyp)
#>                Chi Square Statistics                 
#> 
#> Statistics                     DF    Value      Prob 
#> ----------------------------------------------------
#> Chi-Square                     1    0.0470    0.8284
#> Likelihood Ratio Chi-Square    1    0.0471    0.8282
#> Continuity Adj. Chi-Square     1    0.0005    0.9822
#> Mantel-Haenszel Chi-Square     1    0.0468    0.8287
#> Phi Coefficient                     0.0153          
#> Contingency Coefficient             0.0153          
#> Cramer's V                          0.0153          
#> ----------------------------------------------------

Levene’s Test

infer_levene_test(hsb, read, group_var = race)
#>            Summary Statistics             
#> Levels    Frequency    Mean     Std. Dev  
#> -----------------------------------------
#>   1          24        46.67      10.24   
#>   2          11        51.91      7.66    
#>   3          20        46.8       7.12    
#>   4          145       53.92      10.28   
#> -----------------------------------------
#> Total        200       52.23      10.25   
#> -----------------------------------------
#> 
#>                              Test Statistics                              
#> -------------------------------------------------------------------------
#> Statistic                            Num DF    Den DF         F    Pr > F 
#> -------------------------------------------------------------------------
#> Brown and Forsythe                        3       196      3.44    0.0179 
#> Levene                                    3       196    3.4792     0.017 
#> Brown and Forsythe (Trimmed Mean)         3       196    3.3936     0.019 
#> -------------------------------------------------------------------------

Cochran’s Q Test

infer_cochran_qtest(exam, exam1, exam2, exam3)
#>    Test Statistics     
#> ----------------------
#> N                   15 
#> Cochran's Q       4.75 
#> df                   2 
#> p value          0.093 
#> ----------------------

McNemar Test

hb <- hsb
hb$himath <- ifelse(hsb$math > 60, 1, 0)
hb$hiread <- ifelse(hsb$read > 60, 1, 0)
infer_mcnemar_test(hb, himath, hiread)
#>            Controls 
#> ---------------------------------
#> Cases       0       1       Total 
#> ---------------------------------
#>   0        135      21        156 
#>   1         18      26         44 
#> ---------------------------------
#> Total      153      47        200 
#> ---------------------------------
#> 
#>        McNemar's Test        
#> ----------------------------
#> McNemar's chi2        0.2308 
#> DF                         1 
#> Pr > chi2              0.631 
#> Exact Pr >= chi2      0.7493 
#> ----------------------------
#> 
#>        Kappa Coefficient         
#> --------------------------------
#> Kappa                     0.4454 
#> ASE                        0.075 
#> 95% Lower Conf Limit      0.2984 
#> 95% Upper Conf Limit      0.5923 
#> --------------------------------
#> 
#> Proportion With Factor 
#> ----------------------
#> cases             0.78 
#> controls         0.765 
#> ratio           1.0196 
#> odds ratio      1.1667 
#> ----------------------

Getting Help

If you encounter a bug, please file a minimal reproducible example using reprex on github. For questions and clarifications, use StackOverflow.

Code of Conduct

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

inferr's People

Contributors

aravindhebbali avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

inferr's Issues

One sample kurtosis test

Syntax

ifr_os_kurtosis_test()

Description

Does a sample of n subjects (or objects) come from a population distribution that is mesokurtic?

Independent sample t test

The independent sample t test should throw an error when the grouping variable has more than 2 levels.

Incorrect package alias

From CRAN:

Dear maintainer,

You have file 'inferr/man/inferr.Rd' with \docType{package}, likely
intended as a package overview help file, but without the appropriate
PKGNAME-package \alias as per "Documenting packages" in R-exts.

This seems to be the consequence of the breaking change

  Using @docType package no longer automatically adds a -package alias.
  Instead document _PACKAGE to get all the defaults for package
  documentation.

in roxygen2 7.0.0 (2019-11-12) having gone unnoticed, see
<https://github.com/r-lib/roxygen2/issues/1491>.

As explained in the issue, to get the desired PKGNAME-package \alias
back, you should either change to the new approach and document the new
special sentinel

  "_PACKAGE"

or manually add

  @aliases inferr-package

if remaining with the old approach.

Please fix in your master sources as appropriate, and submit a fixed
version of your package within the next few months.

Best,
-k

One sample z test

Syntax

ifr_os_z_test()

Description

Does a sample of n subjects (or objects) come from a population in which the mean (μ) equals a specified value?

2 sample variance test

The 2 sample variance test should accept only binary variables for the group_var input. The number of continuous variables must also not exceed two.

README template

Use the standard template for README:

  • Overview
  • Installation
  • Shiny App
  • Usage
  • Articles
  • Features
  • Getting Help
  • Code of Conduct

0.3.1 Release Checklist

  • Check current CRAN check results
  • Polish NEWS
  • devtools::build_readme()
  • urlchecker::url_check()
  • devtools::check(remote = TRUE, manual = TRUE)
  • devtools::check_win_devel()
  • rhub::check_for_cran()
  • rhub::check(platform = 'ubuntu-rchk')
  • rhub::check_with_sanitizers()
  • revdepcheck::revdep_check(num_workers = 4)
  • Update cran-comments.md
  • Review pkgdown reference index for, e.g., missing topics

Submit to CRAN:

  • Bump version in DESCRIPTION and NEWS
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted 🎉
  • Tag release
  • Bump dev version in DESCRIPTION and NEWS
  • Update install instructions in README

Documentation

Add the following:

  • Contributing Guide
  • Issue Template

Independent sample t test

The input for independent sample t test is restricted to 1 continuous variable and 1 categorical variable. The input must be flexible and accommodate 2 continuous variables as well.

Power and sample size

Syntax

  • ifr_power()
  • ifr_sample_size()

Power and sample size computation for the following test:

  • infer_oneway_anova()
  • infer_os_prop_test()
  • infer_os_t_test()
  • infer_os_var_test()
  • infer_ts_ind_ttest()
  • infer_ts_paired_ttest()
  • infer_ts_prop_test()
  • infer_ts_prop_grp()
  • infer_ts_prop_calc()
  • infer_ts_var_test()

Migrate to testthat 3

Currently, output from print functions are tested using expect_output() . Migrating to edition 3 will allow snapshot based testing.

ANOVA: Post Hoc Multiple Comparisons

Equal variances assumed:

  • LSD
  • Bonferroni
  • Sidak
  • Scheffe
  • Tukey
  • Tukey's-b
  • Duncan
  • Gabriel

Equal variances not assumed:

  • Tamhane's T2
  • Dunnett's T3
  • Games-Howell
  • Dunnett's C

One sample skewness test

Syntax

ifr_os_skew_test()

Description

Does a sample of n subjects (or objects) come from a population distribution that is symmetrical (i.e., not skewed)?

Unequal sample sizes

The current API design does not take into account unequal sample sizes in case of two sample tests. This must be fixed on a priority basis.

  • infer_ts_ind_ttest()
  • infer_ts_var_test()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.