clear;

[num, txt, raw] = xlsread( 'Data.xls', 'Anwers' );
ind = num([1:12 28:39 55:66 82:93],2:5);
group = num([14:25 41:52 68:79 95:106],2:5);
no_audio = [13 14 16 23];
to_keep = ones(length(ind),1);
to_keep(no_audio) = 0;
to_keep = find(to_keep>0);


invers = 1:2:4*12;
ind(invers,:) = (ind(invers,:)-7)*-1;
group(invers,:) = (group(invers,:)-7)*-1;


missing = find(isnan(sum(ind,2)));
shift_miss = mean(ind(missing,1:3),2) > mean(group(missing,1:3),2);

ind_all = [ind(1:12,:) ind(13:24,:) ind(25:36,:) ind(37:48,:)];
group_all = [group(1:12,:) group(13:24,:) group(25:36,:) group(37:48,:)];

group_m = [mean(group_all(1:2,~isnan(group_all(1,:))),2);mean(group_all(~sum(isnan(group_all),2),:),2)];
ind_m = [mean(ind_all(1:2,~isnan(ind_all(1,:))),2);mean(ind_all(~sum(isnan(ind_all),2),:),2)];

group_mean = mean(group(to_keep,:),2);
ind_mean = mean(ind(to_keep,:),2);


[num, txt, raw] = xlsread( 'Data.xls', 'personality' );
neuro1 = [1 11 16 46];
neuro2 = [6 21 26 36 41 51 56];
extra1 = [7 12 37 42];
extra2 = [ 2 17 27 57];
extra3 = [22 32 47 52];
open1 = [13 23 43];
open2 = [48 53 58];
open3 = [3 8 18 38];
agree1 = [9 14 19 24 29 44 54 59];
agree2 = [4 34 39 49];
consc1 = [5 10 15 30 55];
consc2 = [25 35 60];
consc3 = [20 40 45 50];
inv = [1 16 31 12 27 57 23 48 3 8 18 38 19 24 29 44 54 59 39 15 30 55 45];
survey = num;
survey(:,inv) = (survey(:,inv)-6)*-1;
neurotism = mean(survey(:, [neuro1 neuro2]),2);
extraversion = mean(survey(:, [extra1 extra2 extra3]),2);
openess = mean(survey(:, [open1 open2 open3]),2);
agreeableness = mean(survey(:, [agree1 agree2]),2);
conscientiousness = mean(survey(:, [consc1 consc2 consc3]),2);
psych = [neurotism extraversion openess agreeableness conscientiousness];


save group_polarization.mat psych group* ind*;