Skip to content

Commit

Permalink
Updated existing methods' documentation to new format
Browse files Browse the repository at this point in the history
  • Loading branch information
Corey-Bryant committed Mar 10, 2022
1 parent 7683b7d commit a79be3a
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 49 deletions.
2 changes: 1 addition & 1 deletion source/anova_documentation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ anova methods



Effect size measures formulas
Effect Size Measures Formulas
=============================
By default, this method will return the measures of :math:`R^2`, :math:`\text{Adj. }R^2`, :math:`\eta^2`, and :math:`\omega^2`;
note that for the factor terms the reported :math:`\eta^2` and :math:`\omega^2` will be partial, i.e. :math:`\eta^2_p` and :math:`\omega^2_p` respectively.
Expand Down
6 changes: 3 additions & 3 deletions source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
# -- Project information -----------------------------------------------------

project = 'researchpy'
copyright = '2018-2021, Corey Bryant'
copyright = '2018-2022, Corey Bryant'
author = 'Corey Bryant'

# The short X.Y version
version = '0.3.2'
version = '0.3.5'
# The full version, including alpha/beta/rc tags
release = '0.3.2'
release = '0.3.5'


# -- General configuration ---------------------------------------------------
Expand Down
20 changes: 17 additions & 3 deletions source/corr_case_documentation.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
*************
corr_case()
*************

Description
===========
Conducts Pearson (default method), Spearman rank, or Kendall's Tau-b correlation analysis using
case wise deletion. Returns the relevant information and results in 3 DataFrames
Expand All @@ -11,8 +15,11 @@ DataFrame 2 contains the r value results in a matrix style look.

DataFrame 3 contains the p-values in a matrix style look.

Arguments
---------
Parameters
==========

Input
-----
**def corr_case(dataframe, method = "pearson")**

* **dataframe** can either be a single Pandas Series or multiple Series/an
Expand All @@ -31,7 +38,10 @@ Arguments
.. _Kendall Tau-b: https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.kendalltau.html
Examples
--------
========

Loading Packages and Data
-------------------------
.. code:: python
import researchpy, numpy, pandas
Expand All @@ -42,6 +52,10 @@ Examples
df = pandas.DataFrame(numpy.random.randint(10, size= (100, 2)),
columns= ['beck', 'srq'])
Pearson r
---------

.. code:: python
# Since it returns 3 DataFrames for easy exporting, if the DataFrames
Expand Down
17 changes: 14 additions & 3 deletions source/corr_pair_documentation.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
***********
corr_pair()
***********

Description
===========
Conducts Pearson (default method), Spearman rank, or Kendall's Tau-b correlation analysis using
pair wise deletion. Returns the relevant information and results in 1 DataFrame
Expand All @@ -8,9 +12,11 @@ DataFrame 1 contains the variables being compared in the index, followed by the
corresponding r value, p-value, and N for the groups being compared.


Parameters
==========

Arguments
---------
Input
-----
**corr_pair(dataframe, method= "pearson")**

* **dataframe** can either be a single Pandas Series or multiple Series/an
Expand All @@ -30,7 +36,10 @@ Arguments


Examples
--------
========

Loading Packages and Data
-------------------------
.. code:: python
import researchpy, numpy, pandas
Expand All @@ -42,6 +51,8 @@ Examples
columns= ['mental_score', 'physical_score', 'emotional_score',
'happiness_index'])
Pearson r
---------
.. code:: python
# Can pass the entire DataFrame or multiple Series
Expand Down
79 changes: 46 additions & 33 deletions source/crosstab_documentation.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
**********
crosstab()
==========
**********

Description
===========
Returns up to 3 DataFrames depending on what desired. Can calculate row, column,
or cell percentages if requested. Otherwise, counts are returned as the default.

Expand All @@ -12,8 +16,11 @@ the expected frequency table.



Arguments
----------
Parameters
==========

Input
------
**crosstab(group1, group2, prop= None, test = False, margins= True,
correction = None, cramer_correction = None, exact = False, expected_freqs= False)**

Expand All @@ -22,6 +29,7 @@ correction = None, cramer_correction = None, exact = False, expected_freqs= Fals
the row percentages, 'column' will calculate the column percentages, and 'cell'
will calculate the cell percentage based on the entire sample
* **test**, can take "chi-square", "g-test", "mcnemar", or "fisher".

* If "chi-square", the chi-square (:math:`\chi^2`) test of independence :cite:`scipy_chi2` will
be calculated and returned in a second DataFrame.
* If "g-test", will conduct the G-test (likelihood-ratio :math:`\chi^2`) :cite:`scipy_chi2` and
Expand All @@ -42,8 +50,11 @@ correction = None, cramer_correction = None, exact = False, expected_freqs= Fals
* **expected_freqs**, if True, will return a DataFrame that contains the
expected counts for each cell. Not a valid argurment for *mcnemar* test.

**returns**
* Up to 3 Pandas DataFrames as a tuple;
Returns
--------

Up to 3 Pandas DataFrames will be returned within a tuple:

* First DataFrame is always the crosstab table with either the counts,
cell, row, or column percentages
* Second DataFrame is either the test results or the expected frequencies.
Expand All @@ -60,14 +71,14 @@ correction = None, cramer_correction = None, exact = False, expected_freqs= Fals



Effect size measures formulas
-----------------------------
Effect Size Measures Formulas
=============================
.. note::
If adjusted :math:`\chi^2` values are used in the test's calculation, then those
adjusted :math:`\chi^2` values are also used to calculate effect size.

Cramer's Phi (2x2 table)
^^^^^^^^^^^^^^^^^^^^^^^^
------------------------
For analyses were it's a 2x2 table, the following formula is used to
calculate Cramer's Phi (:math:`\phi`) :cite:`cramer2016`:

Expand All @@ -79,7 +90,7 @@ Where N = total number of observations in the analysis


Cramer's V (RxC where R or C > 2)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
---------------------------------
For analyses were it's a table that is larger than a 2x2, the
following formula is used to calculate Cramer's V :cite:`cramer2016`:

Expand All @@ -101,7 +112,10 @@ Where r is the number of rows and c is the number of columns, and
Examples
--------
========

Loading Packages and Data
-------------------------
.. code:: python
import researchpy, pandas, numpy
Expand Down Expand Up @@ -161,6 +175,8 @@ Examples
</div>


Crosstabulation with Frequency
------------------------------

.. code:: python
Expand Down Expand Up @@ -228,13 +244,14 @@ Examples
</div>


Crosstabulation with Cell Percentages
-------------------------------------
Cell percentages are calculated by taking the frequency of the cell and dividing it by the total N.
For example, the cell proportion for :math:`\text{disease}_0` and :math:`\text{alive}_0` = :math:`\frac{9}{101}`.

.. code:: python
# Demonstration of calculating cell proportions
crosstab = researchpy.crosstab(df['disease'], df['alive'], prop= "cell")
crosstab
.. raw:: html
Expand Down Expand Up @@ -295,13 +312,11 @@ Examples
</div>



Crosstabulation with Row Percentages
-------------------------------------
.. code:: python
# Demonstration of calculating row proportions
crosstab = researchpy.crosstab(df['disease'], df['alive'], prop= "row")
crosstab
.. raw:: html
Expand Down Expand Up @@ -362,13 +377,12 @@ Examples
</div>


Crosstabulation with Column Percentages
---------------------------------------

.. code:: python
# Demonstration of calculating column proportions
crosstab = researchpy.crosstab(df['disease'], df['alive'], prop= "col")
crosstab
.. raw:: html
Expand Down Expand Up @@ -429,6 +443,8 @@ Examples
</div>


Chi Squared (:math:`\chi^2`) Test of Independence
--------------------------------------------------

.. code:: python
Expand Down Expand Up @@ -615,13 +631,11 @@ Examples
</div>



G-test
--------
.. code:: python
# Can also conduct the G-test (likelihood-ratio chi-square)
crosstab, res = researchpy.crosstab(df['disease'], df['alive'], test= "g-test")
res
.. raw:: html
Expand Down Expand Up @@ -656,16 +670,15 @@ Examples
</div>



Fisher's Exact test
-------------------
.. code:: python
# Can also conduct Fisher's exact test
# Need 2x2 data for Fisher's test.
numpy.random.seed(345)
df = pandas.DataFrame(numpy.random.randint(2, size= (90, 2)),
columns= ['tx', 'cured'])
columns= ['tx', 'cured'])
crosstab, res = researchpy.crosstab(df['tx'], df['cured'], test= "fisher")
Expand Down Expand Up @@ -764,16 +777,16 @@ Examples
</div>


McNemar test
-------------
Make sure that the outcomes are labelled the same in both variables.

.. code:: python
# Lastly, the McNemar test
# Make sure your outcomes are labelled the same in
# both variables
numpy.random.seed(345)
df = pandas.DataFrame(numpy.random.randint(2, size= (90, 2)),
columns= ['time1', 'time2'])
columns= ['time1', 'time2'])
crosstab, res = researchpy.crosstab(df['time1'], df['time2'], test= "mcnemar")
Expand Down Expand Up @@ -869,7 +882,7 @@ Examples


References
----------
==========
.. bibliography:: refs.bib
:list: bullet
:cited:
10 changes: 5 additions & 5 deletions source/difference_test_documentation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ difference_test()
*****************

Description
============
===========
Conducts a few different statistical tests which test for a difference between
independent or related samples with or without equal variances and has the ability
to calculate the effect size of the observed difference. The data is
returned in a Pandas DataFrame by default, but can be returned as a dictionary
if specified.

This method is similar to researchpy.ttest(), except it allows the user to use
the formula syntax.
This method is similar to researchpy.ttest(), except it allows the user to use the formula syntax.

This method can perform the following tests:

* Independent sample t-test :cite:`2018:scipy_ttest_ind`

* `psudo-code: difference_test(formula_like, data, equal_variances = True, independent_samples = True)`
Expand Down Expand Up @@ -125,8 +125,8 @@ Welch (1947)
-2 + \frac{(\frac{s^2_x}{n_x} + \frac{s^2_y}{n_y})^2}{\frac{(\frac{s^2_x}{n_x})^2}{n_x+1} + \frac{(\frac{s^2_y}{n_y})^2}{n_y+1}}
Effect size measures formulas
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Effect Size Measures Formulas
=============================

Cohen's d\ :sub:`s` (between subjects design)
""""""""""""""""""""""""""""""""""""""""""""""
Expand Down
3 changes: 2 additions & 1 deletion source/ttest_documentation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Conducts various comparison tests between two groups and returns data tables as
Pandas DataFrames with relevant information pertaining to the statistical test conducted.

This method can perform the following tests:

* Independent sample t-test :cite:p:`scipy_ttest_ind`

* `psudo-code: ttest(group1, group2, equal_variances = True, paired = False)`
Expand Down Expand Up @@ -101,7 +102,7 @@ Welch (1947)
Effect size measures formulas
Effect Size Measures Formulas
=============================

Cohen's d\ :sub:`s` (between subjects design)
Expand Down

0 comments on commit a79be3a

Please sign in to comment.