Skip to content

Commit

Permalink
Merge pull request #227 from timothy1191xa/lin_reg
Browse files Browse the repository at this point in the history
added function to plot risk aversion
  • Loading branch information
timothy1191xa committed Dec 13, 2015
2 parents dcadb1d + 875a810 commit 6107d73
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions code/utils/functions/linear_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ def combine_all_data(data_dir = "/Users/macbookpro/Desktop/stat159_Project/"):

def load_each_subject(data_dir = "/Users/macbookpro/Desktop/stat159_Project/"):

all_subjects = ['001', '002', '003', '004', '005', '006', '007',
'008', '009', '010', '011', '012', '013', '014', '015', '016']

l = []

for i in all_subjects:
Expand Down Expand Up @@ -281,15 +284,14 @@ def beta_statistics():
for i in range(len(data)):
betas[i], pvalues[i] = linear_regression(data[i], 'RT', 'gain', 'loss')


lambdas = []

for i in range(len(data)):
lambdas.append( math.log(betas[i][2] / betas[i][1]) )

return

def plot_neural_and_behav_loss_aversion(data, subject):
def plot_neural_and_behav_loss_aversion(data, beta = None):

all_subjects = ['001', '002', '003', '004', '005', '006', '007',
'008', '009', '010', '011', '012', '013', '014', '015', '016']
Expand Down Expand Up @@ -321,11 +323,15 @@ def my_line(x, B = B):
x_vals = [0, max(loss_aversion)]
y_vals = [my_line(0), my_line(max(loss_aversion))]

plt.plot(loss_aversion, lambdas, '+')
plt.plot(loss_aversion, lambdas, '+')
plt.plot(x_vals, y_vals)

plt.xlabel('negative loss beta - gain beta')
plt.ylabel('log of lambda')
#plt.xlabel('negative loss beta - gain beta')
#plt.ylabel('log of lambda')

plt.title("Scatterplot of correspondence between neural \nloss aversion and behavioral loss aversion")
plt.xlabel(r'Neural loss aversion [-($\beta[loss]) - \beta[gain]$]')
plt.ylabel(r'Behavioral loss aversion [ln($\lambda)$]')

plt.show()

Expand Down

0 comments on commit 6107d73

Please sign in to comment.