# -*- coding: utf-8 -*- """ Created on Sun Nov 14 11:09:44 2021 @author: Machi """ import numpy as np import pandas as pd import seaborn as sns import matplotlib.pyplot as plt from statsmodels.formula.api import ols from statsmodels.stats.anova import anova_lm from statsmodels.stats.multicomp import pairwise_tukeyhsd df = {'x':list(np.random.normal(10, 5, 20)), 'y':list(np.random.normal(20, 5, 20))} data = pd.Dataframe(df) %config InlineBackend.figure_format = 'retina' data_melt = data.melt() data_melt.columns = ['Treat', 'value'] print(data_melt) sns.boxplot(x = 'Treat', y = 'value', data = data_melt) model = ols('value ~C(Treat)', data = data_melt).fit() anova_table = anova_lm(model, type = 2) result = pd.Dataframe(anova_table) print(result)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)