In [1]:
from grmpy.test.auxiliary import refactor_results
from scipy.stats import gaussian_kde
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
%matplotlib inline
import grmpy
In [31]:
df = grmpy.simulate('tutorial.grmpy.ini')
In [4]:
df.head()
Out[4]:
In [6]:
pickle_file = pd.read_pickle('data.grmpy.pkl')
pickle_file.head()
Out[6]:
In [7]:
benefits= df.Y1 - df.Y0
TT = np.mean(benefits[df.D==1])
TUT = np.mean(benefits[df.D==0])
ATE = np.mean(benefits)
density = gaussian_kde(benefits)
xs = np.linspace(-4,5)
plt.figure(figsize=(20,10))
plt.plot(xs,density(xs))
plt.axvline(x=TUT, c='g', label='TUT')
plt.axvline(x=TT, c='r', label='TT')
plt.axvline(x=ATE, c='y',label='ATE')
plt.xlabel('Y1-Y0', fontsize=20)
plt.ylabel('Density', fontsize=20)
plt.legend(fontsize=20)
plt.show()
In [28]:
df_ = grmpy.simulate('tutorial2.grmpy.ini')
In [29]:
benefits_ = df_.Y1 - df_.Y0
TT = np.mean(benefits_[df.D==1])
TUT = np.mean(benefits_[df.D==0])
ATE = np.mean(benefits_)
density = gaussian_kde(benefits_)
xs = np.linspace(-4,5)
plt.figure(figsize=(20,10))
plt.plot(xs,density(xs))
plt.axvline(x=TUT, c='g', label='TUT')
plt.axvline(x=TT, c='r', label='TT')
plt.axvline(x=ATE, c='y',label='ATE')
plt.xlabel('Y1-Y0', fontsize=20)
plt.ylabel('Density', fontsize=20)
plt.legend(fontsize=20)
plt.show()
In [41]:
results = grmpy.estimate('tutorial.grmpy.ini')
In [42]:
refactor_results(results, 'tutorial.grmpy.ini')
In [43]:
df2 = grmpy.simulate('test.grmpy.ini')
benefits_est = df2.Y1 - df.Y0
density = gaussian_kde(benefits)
density_est = gaussian_kde(benefits_est)
xs = np.linspace(-4,5)
plt.figure(figsize=(20,10))
plt.plot(xs, density_est(xs), c='g', label='est')
plt.plot(xs, density(xs), c='b', label='sim')
plt.xlabel('Y1-Y0', fontsize=20)
plt.ylabel('Density', fontsize=20)
plt.legend(fontsize=20)
plt.show()
In [44]:
results = grmpy.estimate('tutorial_auto.grmpy.ini')
In [45]:
refactor_results(results, 'tutorial_auto.grmpy.ini')
In [46]:
df2 = grmpy.simulate('test.grmpy.ini')
benefits_est = df2.Y1 - df.Y0
density = gaussian_kde(benefits)
density_est = gaussian_kde(benefits_est)
xs = np.linspace(-4,5)
plt.figure(figsize=(20,10))
plt.plot(xs, density_est(xs), c='g', label='est')
plt.plot(xs, density(xs), c='b', label='sim')
plt.xlabel('Y1-Y0', fontsize=20)
plt.ylabel('Density', fontsize=20)
plt.legend(fontsize=20)
plt.show()
In [ ]: