Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
62 views

ANOVA, T-Test and Other Statistical Tests With Python

This document discusses how to perform various statistical tests like ANOVA, t-tests, and MANOVA using Python. It shows code examples for implementing one-way ANOVA, repeated measures ANOVA, independent t-tests, and MANOVA using libraries like SciPy, Pingouin, and Statsmodels. The examples use iris flower data to demonstrate how to conduct these tests and analyze differences between groups.

Uploaded by

Teto Schedule
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
62 views

ANOVA, T-Test and Other Statistical Tests With Python

This document discusses how to perform various statistical tests like ANOVA, t-tests, and MANOVA using Python. It shows code examples for implementing one-way ANOVA, repeated measures ANOVA, independent t-tests, and MANOVA using libraries like SciPy, Pingouin, and Statsmodels. The examples use iris flower data to demonstrate how to conduct these tests and analyze differences between groups.

Uploaded by

Teto Schedule
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

ANOVA, T-test and other statistical tests with Python | by Fra... https://towardsdatascience.com/anova-t-test-and-other-statistic...

1 of 11 9/30/2021, 12:32 PM
ANOVA, T-test and other statistical tests with Python | by Fra... https://towardsdatascience.com/anova-t-test-and-other-statistic...

2 of 11 9/30/2021, 12:32 PM
ANOVA, T-test and other statistical tests with Python | by Fra... https://towardsdatascience.com/anova-t-test-and-other-statistic...

3 of 11 9/30/2021, 12:32 PM
ANOVA, T-test and other statistical tests with Python | by Fra... https://towardsdatascience.com/anova-t-test-and-other-statistic...

4 of 11 9/30/2021, 12:32 PM
ANOVA, T-test and other statistical tests with Python | by Fra... https://towardsdatascience.com/anova-t-test-and-other-statistic...

5 of 11 9/30/2021, 12:32 PM
ANOVA, T-test and other statistical tests with Python | by Fra... https://towardsdatascience.com/anova-t-test-and-other-statistic...

6 of 11 9/30/2021, 12:32 PM
ANOVA, T-test and other statistical tests with Python | by Fra... https://towardsdatascience.com/anova-t-test-and-other-statistic...

from scipy import stats


import pandas as pd

# import the data


df= pd.read_csv("Iris_Data.csv")
setosa = df[(df['species'] == 'Iris-setosa')]
versicolor = df[(df['species'] == 'Iris-versicolor')]

# homogeneity
stats.levene(setosa['sepal_width'],
versicolor['sepal_width'])

# Shapiro-Wilk test for normality


stats.shapiro(setosa['sepal_width'])
stats.shapiro(versicolor['sepal_width'])

stats.ttest_ind(setosa['sepal_width'],

7 of 11 9/30/2021, 12:32 PM
ANOVA, T-test and other statistical tests with Python | by Fra... https://towardsdatascience.com/anova-t-test-and-other-statistic...

versicolor['sepal_width'])

import pingouin as pg

# Read an example dataset


df = pg.read_dataset('mixed_anova')

# Run the ANOVA


aov = pg.anova(data=df, dv='Scores', between='Group',
detailed=True)
print(aov)

8 of 11 9/30/2021, 12:32 PM
ANOVA, T-test and other statistical tests with Python | by Fra... https://towardsdatascience.com/anova-t-test-and-other-statistic...

pg.rm_anova(data=df, dv='Scores', within='Time',


subject='Subject', detailed=True)

from statsmodels.multivariate.manova import MANOVA

maov = MANOVA.from_formula('Sepal_Length + Sepal_Width + \


Petal_Length + Petal_Width ~
Species', data=df)

print(maov.mv_test())

9 of 11 9/30/2021, 12:32 PM
ANOVA, T-test and other statistical tests with Python | by Fra... https://towardsdatascience.com/anova-t-test-and-other-statistic...

10 of 11 9/30/2021, 12:32 PM
ANOVA, T-test and other statistical tests with Python | by Fra... https://towardsdatascience.com/anova-t-test-and-other-statistic...

11 of 11 9/30/2021, 12:32 PM

You might also like