Пример #1
0
def anova(dv):
    """Perform ANOVA."""

    df = make_summary()
    lm = ols('%s ~ C(group) * age * iq' % dv, data=df).fit()
    divider = '---------'
    print divider, dv, divider, '\n', anova_lm(lm, typ=2, robust='hc3')
Пример #2
0
def conventional_plot(dv):
    """Make a conventional plot."""

    i = 1
    for iv in ['age', 'iq']:

        for grouping in ['group', 'sex', 'cannabis']:

            plt.subplot(2, 3, i)

            for group, df in make_summary().groupby(grouping):

                sb.regplot(x=iv, y=dv, data=df, label=group, truncate=True, robust=False)
                # plt.xlim(17, 71)
                plt.legend()
            i += 1
Пример #3
0
import pandas as pd
import numpy as np
from prepare import make_summary

# df = pd.read_csv('v,a,t,z/sv,st,sz/all_samples.csv')
# z = df.z_Intercept_trans.mean()
# print 1 / (1 + np.exp(-z))

df1 = make_summary()
df2 = pd.read_csv('no_depends/all_samples.csv')
params = {}
for subj in df1.index:
    p = df2[[c for c in df2.columns if '.%i' % subj in c]].mean(axis=0).tolist()
    if len(p) != 0:
        params[subj] = p
df3 = pd.DataFrame(params).T
df3.columns = ['a', 't', 'v1', 'v2', 'z_trans']
df3['v'] = (df3.v1 + df3.v2)/2.
df3['z'] = 1 / (1 + np.exp(-df3.z_trans))
df = pd.concat([df1, df3], axis=1)
df.to_csv('summary.csv')

# import matplotlib.pyplot as plt
# import seaborn as sb
#
# for i, p in enumerate(['a', 't', 'v1', 'v2', 'z', 'v', 'z_trans'], 1):
#     plt.subplot(3, 3, i)
#     sb.regplot(x='age', y=p, csvs=df, label='all')
#     for group, _df in df.groupby('group'):
#         print group
#         sb.regplot(x='age', y=p, csvs=_df, label=group)
Пример #4
0
import pandas as pd

from prepare import make_summary
from tmp.analysis import get_path, pj

data = make_summary()
depends = ['v', 'a', 't', 'z']
include = ['sv', 'st']
path = get_path(depends, include)
samples = pd.read_csv(pj(path, 'all_samples.csv'), index_col=0)
samples['s_age'] = data.age.std()
print data.age.std()