Пример #1
0
        #SAS case
        self.endog = dta3['Relief']
        self.groups = dta3['Brand']
        self.alpha = 0.05
        self.setup_class_()
        #super(self, self).setup_class_()
        #CheckTuckeyHSD.setup_class_()

        self.meandiff2 = sas_['mean']
        self.confint2 = sas_[['lower','upper']].view(float).reshape((3,2))
        self.reject2 = sas_['sig'] == asbytes('***')

if __name__ == '__main__':
    import statsmodels.sandbox.stats.multicomp as multi #incomplete refactoring

    mc = multi.MultiComparison(dta['Rust'], dta['Brand'])
    res = mc.tukeyhsd()
    print res[0]

    mc2 = multi.MultiComparison(dta2['StressReduction'], dta2['Treatment'])
    res2 = mc2.tukeyhsd()
    print res2[0]

    mc2s = multi.MultiComparison(dta2['StressReduction'][3:29], dta2['Treatment'][3:29])
    res2s = mc2s.tukeyhsd()
    print res2s[0]
    res2s_001 = mc2s.tukeyhsd(alpha=0.01)
    #R result
    tukeyhsd2s = np.array([1.888889,0.8888889,-1,0.2658549,-0.5908785,-2.587133,3.511923,2.368656,0.5871331,0.002837638,0.150456,0.1266072]).reshape(3,4, order='F')
    assert_almost_equal(res2s_001[1][4], tukeyhsd2s[:,1:3], decimal=3)
Пример #2
0
    means = mci.groupstats.groupmean
    nobs = mci.groupstats.groupnobs
    resi = tukeyhsd(means,
                    nobs,
                    var_,
                    df=None,
                    alpha=0.05,
                    q_crit=qsturng(0.95, len(means), (nobs - 1).sum()))
    print(resi[4])
    var2 = (mci.groupstats.groupvarwithin() * (nobs - 1)).sum() \
                                                        / (nobs - 1).sum()
    assert_almost_equal(var_, var2, decimal=14)
    return resi


mc = multi.MultiComparison(dta['Rust'], dta['Brand'])
res = mc.tukeyhsd()
print(res)

mc2 = multi.MultiComparison(dta2['StressReduction'], dta2['Treatment'])
res2 = mc2.tukeyhsd()
print(res2)

mc2s = multi.MultiComparison(dta2['StressReduction'][3:29],
                             dta2['Treatment'][3:29])
res2s = mc2s.tukeyhsd()
print(res2s)
res2s_001 = mc2s.tukeyhsd(alpha=0.01)
#R result
tukeyhsd2s = np.array([
    1.888889, 0.8888889, -1, 0.2658549, -0.5908785, -2.587133, 3.511923,
Пример #3
0
################################################################
summary_df["cv"] = summary_df.std_vel / summary_df.mean_vel

_, norm_p = stats.shapiro(summary_df.cv.dropna())
_, var_p = stats.levene(
    summary_df[summary_df.experiment_type == 'baseline'].cv.dropna(),
    summary_df[summary_df.experiment_type == 'control'].cv.dropna(),
    summary_df[summary_df.experiment_type == 'button'].cv.dropna(),
    summary_df[summary_df.experiment_type == 'touch'].cv.dropna(),
    center='median'
    )

if norm_p < 0.05 or var_p < 0.05:
    print('steel-dwass\n', sp.posthoc_dscf(summary_df, val_col='cv', group_col='experiment_type'))
else:
    multicomp_result = multicomp.MultiComparison(np.array(summary_df.dropna(how='any').cv, dtype="float64"), summary_df.dropna(how='any').experiment_type)
    print('levene', multicomp_result.tukeyhsd().summary())
print ('----', 'baseline', 'control', 'button', 'touch')
print('mean',
    summary_df[summary_df.experiment_type == 'baseline'].cv.dropna().mean(),
    summary_df[summary_df.experiment_type == 'control'].cv.dropna().mean(),
    summary_df[summary_df.experiment_type == 'button'].cv.dropna().mean(),
    summary_df[summary_df.experiment_type == 'touch'].cv.dropna().mean(),
)
print('var',
    summary_df[summary_df.experiment_type == 'baseline'].cv.dropna().std(),
    summary_df[summary_df.experiment_type == 'control'].cv.dropna().std(),
    summary_df[summary_df.experiment_type == 'button'].cv.dropna().std(),
    summary_df[summary_df.experiment_type == 'touch'].cv.dropna().std(),
    )
axes = sns.boxplot(data=summary_df, x='experiment_type', y='cv', showmeans=True, meanline=True, meanprops={"linestyle":"--", "color":"Red"})
Пример #4
0
              sp.posthoc_conover_friedman(inttype_accuracy))
else:
    melted_df = pd.melt(inttype_accuracy.reset_index(),
                        id_vars="subject",
                        var_name="experiment_type",
                        value_name="accuracy")
    anova_result = stats_anova.AnovaRM(melted_df, "accuracy", "subject",
                                       ["experiment_type"])
    print("reperted anova: ", anova_result.fit())
    melted_df = pd.melt(inttype_accuracy,
                        var_name="experiment_type",
                        value_name="accuracy")
    print("levene result", var_p)
    # gamesHowellTest(melted_df, "experiment_type", "accuracy")
    multicomp_result = multicomp.MultiComparison(
        np.array(melted_df.dropna(how='any').accuracy, dtype="float64"),
        melted_df.dropna(how='any').experiment_type)
    print(multicomp_result.tukeyhsd().summary())

inttype_accuracy.CONTROL.mean()
inttype_accuracy.BUTTON.mean()
inttype_accuracy.TOUCH.mean()
subject_accuracy = inttype_accuracy.T
_, anova_p = stats.friedmanchisquare(
    subject_accuracy.ando,
    subject_accuracy.aso,
    subject_accuracy.hikosaka,
    subject_accuracy.ichiki,
    subject_accuracy.ienaga,
    subject_accuracy.ikai,
    subject_accuracy.isobe,
# face_df = pd.read_csv('/media/kuriatsu/SamsungKURI/master_study_bag/202012experiment2/results/face.csv')
nasa_df = pd.read_csv('/media/kuriatsu/SamsungKURI/master_study_bag/202012experiment2/results/nasa-tlx.csv')
accuracy_df = pd.read_csv('/media/kuriatsu/SamsungKURI/master_study_bag/202012experiment2/results/accuracy_summary.csv')
# accuracy_raw_df = pd.read_csv('/media/kuriatsu/SamsungKURI/master_study_bag/202012experiment2/results/accuracy.csv')
time_df = pd.read_csv('/media/kuriatsu/SamsungKURI/master_study_bag/202012experiment2/results/time.csv')
rank_df = pd.read_csv('/media/kuriatsu/SamsungKURI/master_study_bag/202012experiment2/results/rank.csv')

fig = plt.figure()
ax = fig.add_subplot(111)
# hatches = ['/', '+', 'x', '.']


print('time')
_, p = stats.levene(time_df.query('experiment_type == "baseline"').time, time_df.query('experiment_type == "control"').time, time_df.query('experiment_type == "button"').time, time_df.query('experiment_type == "touch"').time, center='median')
print('levene-first time', p)
multicomp_result = multicomp.MultiComparison(time_df['time'], time_df['experiment_type'])
calcMeanAndDev(time_df, 'time', total_list)
print(multicomp_result.tukeyhsd().summary())
axes = sns.boxplot(x='experiment_type', y='time', data=time_df,showmeans=True, meanline=True, meanprops={"linestyle":"--", "color":"Red"})
axes.set_ylim([0, 100])
## add hatch
# for i, bar in enumerate(axes.artists):
#     bar.set_hatch(hatches[i])
# addAnotation(plt, 1, 3, time_df.query('experiment_type == ["button", "touch"]').time.max(), 2, -2, '*', 'k')
plt.show()

print('first_intervene_time')
axes = sns.boxplot(x='experiment_type', y='first_intervene_time', data=summary_df, showmeans=True, meanline=True, meanprops={"linestyle":"--", "color":"Red"})
_, p = stats.levene(summary_df.query('experiment_type == "baseline"').first_intervene_time, summary_df.query('experiment_type == "control"').first_intervene_time, summary_df.query('experiment_type == "button"').first_intervene_time, summary_df.query('experiment_type == "touch"').first_intervene_time, center='median')
print('levene-first intervenetime', p)
multicomp_result = multicomp.MultiComparison(summary_df['first_intervene_time'], summary_df['experiment_type'])