GJP_analysis_forpaper3.m 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651
  1. clear all
  2. clc
  3. close all
  4. % % %% loading the processed data files (takes a while, its big)
  5. load('data/2fcasts_members_questions_extracted_data.mat');
  6. team2start = 11;
  7. %% removing the values for which there is no brier (because of minimum requirements from previous script, like minimum amount of answers)
  8. for team=1:size(forecast_time2close_all,1)
  9. for question=1:491
  10. N = numel(group_briers_all {team,question});
  11. if numel(group_briers_all {team,question}) == 0
  12. group_forecasts_all{team,question} = [] ;
  13. group_members_all{team,question} = [] ;
  14. group_timestamps_all{team,question} = [] ;
  15. forecast_time2close_all{team,question} = [] ;
  16. end
  17. end
  18. end
  19. %% creating the variables for the data table
  20. for t=team2start:90
  21. team4table{1,t} = repmat(t, numel(cat(2,group_briers_all{t,:})) ,1);
  22. question4table = [];
  23. for q = 1:size(questions2analyze_all{t},1)
  24. question4table = vertcat(question4table, repmat(questions2analyze_all{t}(q), numel(group_briers_all{t,q}) ,1));
  25. end
  26. question4table_all{1,t} = question4table;
  27. member4table{1,t} = cat(1,group_members_all{t,:});
  28. fcast4table{1,t} = cat(1,group_forecasts_all{t,:});
  29. brier4table{1,t} = cat(2,group_briers_all{t,:})';
  30. timestamp4table{1,t} = cat(1,group_timestamps_all{t,:});
  31. time2close4table {1,t} = cat(2,forecast_time2close_all{t,:})';
  32. end
  33. %% creating the data table
  34. team = cat(1,team4table{1,:});
  35. question_code = cat(1,question4table_all{1,:});
  36. question_n = nan(numel(question_code),1);
  37. unique_questions = unique(question_code);
  38. for i = 1:numel(unique_questions)
  39. question_n (ismember(question_code, unique_questions{i} )) = i;
  40. end
  41. member = cat(1,member4table{1,:});
  42. fcast = cat(1,fcast4table{1,:});
  43. brier = cat(1,brier4table{1,:});
  44. timestamp = cat(1,timestamp4table{1,:});
  45. time2close = cat(1,time2close4table{1,:});
  46. Data = table(team,member,question_code,question_n,fcast,brier,timestamp,time2close);
  47. Data(Data.team<team2start,:) = [];
  48. %%%%%% here i randomize the team vector, comment if i want real teams.
  49. % Data.team = Data.team(randperm(length(Data.team)));
  50. % Data.team = Data.fcast(randperm(length(Data.team)));
  51. % Data.timestamp = Data.timestamp(randperm(length(Data.team)));
  52. % b = Data.team;
  53. %% calculating the actual mean brier and standard error for the team and each team member, and testing each tream member against the whole team.
  54. N_comparisons = 2479; % this number depends on the amount and identity of teams being analyzed. 2479 is correct for teams 11 through 90.
  55. for t=team2start:90
  56. membs = unique(Data.member(Data.team==t));
  57. membersperteam_n (t) = numel(unique(Data.member(Data.team==t)));
  58. team_avg_brier(t) = mean(Data.brier(Data.team==t));
  59. team_se_brier(t) = std(Data.brier(Data.team==t)) / sqrt(numel( Data.brier(Data.team==t) ));
  60. clear m_avg_brier m_se_brier Wilcoxon WilcoxonPerformance
  61. for m = 1:numel(membs)
  62. m_avg_brier(m) = mean(Data.brier(Data.team==t & Data.member == membs(m)));
  63. m_se_brier(m) = std(Data.brier(Data.team==t & Data.member == membs(m))) / sqrt(numel( Data.brier(Data.team==t & Data.member == membs(m)) ));
  64. member_avg_brier{t} = m_avg_brier;
  65. member_se_brier{t} = m_se_brier;
  66. Wilcoxon(m) = ranksum (Data.brier(Data.team==t),Data.brier(Data.team==t & Data.member == membs(m)));
  67. if Wilcoxon (m) <= 0.05/N_comparisons && m_avg_brier(m) < team_avg_brier(t)
  68. WilcoxonPerformance(m) = -1; %%% if member is better than team
  69. elseif Wilcoxon (m) <= 0.05/N_comparisons && m_avg_brier(m) > team_avg_brier(t)
  70. WilcoxonPerformance (m) = 1; %%% if member is worse than team
  71. elseif Wilcoxon (m) > 0.05/N_comparisons
  72. WilcoxonPerformance (m) = 0; %%% if member is same than team
  73. end
  74. end
  75. Wilcoxon_team_vs_members_pvalues{t} = Wilcoxon;
  76. Wilcoxon_team_vs_members_performance{t} = WilcoxonPerformance;
  77. end
  78. %% members per team figure
  79. figure
  80. subplot 121
  81. plot (1:10,membersperteam_n(1:10),'s-')
  82. ylabel('# of members')
  83. xlabel('team')
  84. subplot 122
  85. plot (11:90,membersperteam_n(11:90),'s-')
  86. xlabel('team')
  87. %% members per team figure
  88. figure; set(gcf,'color','w')
  89. semilogy (1:90,membersperteam_n,'.-', 'linewidth' , 2,'markersize',15)
  90. hold on
  91. plot ([1 90],[70 70], 'linewidth' , 2)
  92. xlim([0 91])
  93. set(gca,'XTick',[10:10: 90])
  94. xlim ([0.5 90.5])
  95. set(gca,'XTickLabel',{[10:10:90]})
  96. xlabel('Team')
  97. ylabel('# members')
  98. set(gca,'fontsize',20)
  99. %% figure of proportion of team members diffferent performance than team mean
  100. for i = team2start:90
  101. t_perf = Wilcoxon_team_vs_members_performance{i};
  102. t_better(i) = sum (t_perf == -1) / numel(t_perf);
  103. t_worse(i) = sum (t_perf == 1)/ numel(t_perf);
  104. % t_better(i) = sum (t_perf == -1);
  105. % t_worse(i) = sum (t_perf == 1);
  106. t_diff(i) = t_better(i) + t_worse(i);
  107. end
  108. figure; set(gcf,'color','w');
  109. plot (1:90,t_better,1:90,t_worse)
  110. legend('Better than team average','Worse than team average','location','northeast')
  111. xlim([0 91])
  112. set(gca,'XTick',[10:10: 90])
  113. xlim ([0.5 90.5])
  114. set(gca,'XTickLabel',{[10:10:90]})
  115. xlabel('Team')
  116. ylabel('Proportion of team members')
  117. set(gca,'FontSize',20)
  118. sum(t_diff==0)
  119. %%
  120. concatenated_wilcoxonperfs = cat(2,Wilcoxon_team_vs_members_performance{1,:});
  121. disp([ 'Check that the N for the pvalue is = ' num2str(numel(cat(2,Wilcoxon_team_vs_members_performance{1,:})))] )
  122. Nbetter = sum(concatenated_wilcoxonperfs == -1);
  123. Nworse = sum(concatenated_wilcoxonperfs == 1);
  124. Nequal = sum(concatenated_wilcoxonperfs == 0);
  125. disp(['N members better than their team = ' num2str(Nbetter)])
  126. disp(['N members worse than their team = ' num2str(Nworse)])
  127. disp(['N members equal than their team = ' num2str(Nequal)])
  128. %% creating the new variables to analyze
  129. % confidence and absolute performance
  130. % confidence4table = nan(size(Data,1),1);
  131. abs_performance4table = nan(size(Data,1),1);
  132. confidence4table = abs(Data.fcast-0.5);
  133. abs_performance4table (Data.brier < 0.5) = 1;
  134. abs_performance4table (Data.brier > 0.5) = 0;
  135. abs_performance4table (Data.brier == 0.5) = -1;
  136. Data.confidence = confidence4table;
  137. Data.abs_performance = abs_performance4table;
  138. %% calculating correct outcomes for later. vector with 1 if q outcome 1, 0 if 0. Corresponding to the probability forecast.
  139. outcome_vector = nan(size(Data,1),1);
  140. outcome_vector(Data.fcast==0.5) = -1;
  141. outcome_vector(Data.abs_performance==1 & Data.fcast<0.5) = 0;
  142. outcome_vector(Data.abs_performance==0 & Data.fcast<0.5) = 1;
  143. outcome_vector(Data.abs_performance==0 & Data.fcast>0.5) = 0;
  144. outcome_vector(Data.abs_performance==1 & Data.fcast>0.5) = 1;
  145. Data.q_outcome = outcome_vector;
  146. %% descriptive histograms. Sanity check. should be histograms with -1 0 1 for performance and values between 0 and 0.5 for confidence
  147. figure; set(gcf,'color','w');
  148. subplot 121
  149. histogram (Data.abs_performance,'normalization','cdf')
  150. xlabel ('forecast absolute performance')
  151. ylabel ('Cumulative Probability')
  152. subplot 122
  153. histogram(Data.confidence,100,'normalization','pdf')
  154. xlabel ('Forecast Confidence')
  155. %% windowing confidence and absolute performance
  156. tw_start = 110:-10:30;
  157. tw_end = 80:-10:0;
  158. for tw = 1:numel(tw_start)
  159. clear time_index
  160. time_index = Data.time2close < tw_start(tw) & Data.time2close > tw_end(tw);
  161. abs_perf_window(tw) = mean(Data.abs_performance(time_index & Data.fcast ~= 0.5));
  162. confidence_mean_window(tw) = mean(Data.confidence(time_index));
  163. confidence_se_window(tw) = std(Data.confidence(time_index)) / sqrt(numel(Data.confidence(time_index)));
  164. brier_mean_window(tw) = mean(Data.brier(time_index));
  165. brier_se_window(tw) = std(Data.brier(time_index)) / sqrt(numel(Data.brier(time_index)));
  166. end
  167. %% figure of absolute performance and confidence across time windows
  168. figure; set(gcf,'color','w');
  169. subplot 211
  170. plot(1:9,abs_perf_window)
  171. set(gca,'XTick',[1:9])
  172. xlim ([0.5 9.5])
  173. set(gca,'XTickLabel',{'110-80','100-70','90-60','80-50','70-40','60-30','50-20','40-10','30-0'})
  174. xlabel('Interval of days before question closure')
  175. ylabel('Proportion of correct absolute forecasts')
  176. subplot 212
  177. errorbar(1:9,confidence_mean_window,confidence_se_window)
  178. ylim([0.28 0.4])
  179. xlim ([0.5 9.5])
  180. set(gca,'XTick',[1:9])
  181. set(gca,'XTickLabel',{'110-80','100-70','90-60','80-50','70-40','60-30','50-20','40-10','30-0'})
  182. xlabel('Interval of days before question closure')
  183. ylabel('Confidence Score')
  184. %% calculating the two performances per team per window
  185. min_answers = 5;
  186. for tw = 1:numel(tw_start)
  187. time_index = Data.time2close < tw_start(tw) & Data.time2close > tw_end(tw);
  188. Performance1_window_raw = nan(90,382);
  189. Performance2_window_raw = nan(90,382);
  190. Consensus_fcast_window_raw = nan(90,382);
  191. for t = team2start:90
  192. for q = 1:max(Data.question_n)
  193. clear values valuesP1 tans_val
  194. values = Data.brier(Data.team == t & Data.question_n == q & time_index);
  195. valuesP1 = Data.fcast(Data.team == t & Data.question_n == q & time_index);
  196. if numel(values) >= min_answers
  197. Performance2_window_raw(t,q) = nanmean(values);
  198. outcome4briercalc = max( unique(Data.q_outcome(Data.question_n==q)) );
  199. Performance1_window_raw(t,q) = BrierScoreCalc(nanmean(valuesP1),outcome4briercalc);
  200. Consensus_fcast_window_raw(t,q) = nanmean(valuesP1);
  201. end
  202. end
  203. end
  204. %%%performances by team to plot one line per team instead of the grand
  205. %%%average
  206. Perf1_groupmean_tw (:,tw) = nanmean(Performance1_window_raw,2);
  207. Perf2_groupmean_tw (:,tw) = nanmean(Performance2_window_raw,2);
  208. Perf1_questionmean_tw (:,tw) = nanmean(Performance1_window_raw,1);
  209. Perf2_questionmean_tw (:,tw) = nanmean(Performance2_window_raw,1);
  210. Consensus_groupmean_tw (:,tw) = nanmean(Consensus_fcast_window_raw,2);
  211. Consensus_questionmean_tw (:,tw) = nanmean(Consensus_fcast_window_raw,1);
  212. %%%%%
  213. Performance1_window_mean (tw) = nanmean(Performance1_window_raw(:));
  214. Performance1_window_se (tw) = nanstd(Performance1_window_raw(:)) / sqrt(numel(Performance1_window_raw(~isnan(Performance1_window_raw))));
  215. Performance2_window_mean (tw) = nanmean(Performance2_window_raw(:));
  216. Performance2_window_se (tw) = nanstd(Performance2_window_raw(:)) / sqrt(numel(Performance2_window_raw(~isnan(Performance2_window_raw))));
  217. Performance2_window_mean (tw) = nanmean(Performance2_window_raw(:));
  218. Performance2_window_se (tw) = nanstd(Performance2_window_raw(:)) / sqrt(numel(Performance2_window_raw(~isnan(Performance2_window_raw))));
  219. clear Performance_diff Performance_sum MI
  220. Performance_diff = Performance2_window_raw - Performance1_window_raw;
  221. Performance_sum = Performance2_window_raw + Performance1_window_raw;
  222. Perf2_KW {tw} = Performance2_window_raw(:);
  223. Perf1_KW {tw} = Performance1_window_raw(:);
  224. MI = Performance_diff./Performance_sum;
  225. MI_mean(tw) = nanmean(MI(:));
  226. MI_se(tw) = nanstd(MI(:)) / sqrt( sum(sum(~isnan(MI))) );
  227. end
  228. %% one more level of aggregation (2nd order compromise)
  229. for q = 1:size(Consensus_questionmean_tw,1)
  230. for tw = 1:9
  231. if isnan(Consensus_questionmean_tw (q,tw))
  232. Consensus_Brier_tw (q,tw) = nan;
  233. elseif ~isnan(Consensus_questionmean_tw (q,tw))
  234. Consensus_Brier_tw (q,tw) = BrierScoreCalc(Consensus_questionmean_tw (q,tw), max( unique(Data.q_outcome(Data.question_n==q))));
  235. end
  236. Nvalues_for_se(tw) = sum (~isnan(Consensus_questionmean_tw(:,tw)));
  237. end
  238. end
  239. Consensus_mean_2aggregation_tw = nanmean(Consensus_Brier_tw,1);
  240. Consensus_se_2aggregation_tw = nanstd(Consensus_Brier_tw,1) ./ sqrt(Nvalues_for_se);
  241. %% statistical testing
  242. for window = 1:9
  243. mat_testing = nan(90*382,3);
  244. mat_testing(:,1) = Perf2_KW{window}; %% blue
  245. mat_testing(:,2) = Perf1_KW{window}; %% red
  246. index_numel = numel(Consensus_Brier_tw(:,window));
  247. mat_testing(1:index_numel,3) = Consensus_Brier_tw(:,window); %% yellow
  248. % pKW (window) = kruskalwallis(mat_testing);
  249. [pKW(window),tbl{window},stats{window}] = kruskalwallis(mat_testing,[],'off')
  250. end
  251. %%% multiple comparisons
  252. multiple_comparisons = nan(3,11);
  253. multiple_comparisons(1,10:11)= [1 2];
  254. multiple_comparisons(2,10:11)= [2 3];
  255. multiple_comparisons(3,10:11)= [1 3];
  256. %%%% correcting the KW, multiplying by 9
  257. for window = 1:9
  258. if pKW(window)*9 < 0.05
  259. multiple_comparisons(1,window) = 3*ranksum (Perf2_KW{window},Perf1_KW{window});
  260. multiple_comparisons(2,window) = 3*ranksum (Consensus_Brier_tw(:,window),Perf1_KW{window});
  261. multiple_comparisons(3,window) = 3*ranksum (Perf2_KW{window},Consensus_Brier_tw(:,window));
  262. end
  263. multiple_comparisons_dunn{window} = multcompare(stats{window},'CType','dunn-sidak');
  264. end
  265. %% GLM preparation
  266. %%%% preparing the data
  267. clear b_curve r_curve y_curve
  268. b_curve = Perf2_KW;
  269. r_curve = Perf1_KW;
  270. for i = 1:9
  271. indb = ~isnan(Perf2_KW{i});
  272. b_curve{i} = Perf2_KW{i}(indb);
  273. indr = ~isnan(Perf1_KW{i});
  274. r_curve{i} = Perf1_KW{i}(indr);
  275. indy = ~isnan(Consensus_Brier_tw(:,i));
  276. y_curve{i} = Consensus_Brier_tw(indy,i);
  277. clear indr indb indy
  278. b_timebins{i} = i*ones(numel(b_curve{i}),1);
  279. r_timebins{i} = i*ones(numel(r_curve{i}),1);
  280. y_timebins{i} = i*ones(numel(y_curve{i}),1);
  281. end
  282. %%%% now concatenating and generating the long vector of data and the
  283. %%%% columns for conditions and time
  284. b_cat = vertcat(b_curve{:});
  285. r_cat = vertcat(r_curve{:});
  286. y_cat = vertcat(y_curve{:});
  287. briers4glm = vertcat(b_cat,r_cat,y_cat);
  288. condition4glm(1:numel(b_cat),1) = 1;
  289. condition4glm((1+numel(b_cat)):(numel(b_cat)+numel(r_cat)),1) = 2;
  290. condition4glm((1+numel(b_cat)+numel(r_cat)):(numel(b_cat)+numel(r_cat)+numel(y_cat)),1) = 3;
  291. timebin4glm = vertcat(b_timebins{:},r_timebins{:},y_timebins{:});
  292. %% running the glm
  293. Accuracy= briers4glm+eps; % Accuracy
  294. Timebin = timebin4glm; % stimuls difficulty
  295. Condition = condition4glm; % diffrent conditions
  296. figure;set(gcf,'color','w')
  297. subplot 121
  298. boxplot (Accuracy,Condition)
  299. subplot 122
  300. boxplot (Accuracy,Timebin)
  301. IntAccTime = Accuracy .* Timebin;
  302. IntCondTime = Condition .* Timebin;
  303. %%% you would make a table for these arrays
  304. MyTable = table(Timebin,Accuracy,Condition,IntAccTime,IntCondTime);
  305. %%% then, you would run the functcion
  306. glme = fitglme(MyTable,...
  307. 'Accuracy ~ 1+Condition + Timebin',...
  308. 'Distribution','inverse gaussian','FitMethod','MPL',...
  309. 'DummyVarCoding','effects');
  310. %%% and creat the table for the results
  311. Res_ACC = [glme.Coefficients.Estimate(2:end),glme.Coefficients.SE(2:end),...
  312. glme.Coefficients.Lower(2:end),glme.Coefficients.Upper(2:end),...
  313. glme.Coefficients.tStat(2:end),glme.Coefficients.pValue(2:end)];
  314. %% plotting the medians
  315. nBS=10000;
  316. quantileBS = 0.95;
  317. for i=1:9
  318. medians2plot(1,i) = median(b_curve{i});
  319. medians2plot(2,i) = median(r_curve{i});
  320. medians2plot(3,i) = median(y_curve{i});
  321. means2plot(1,i) = mean(b_curve{i});
  322. means2plot(2,i) = mean(r_curve{i});
  323. means2plot(3,i) = mean(y_curve{i});
  324. CIb(:,i) = median_ci(b_curve{i},nBS,quantileBS);
  325. CIr(:,i) = median_ci(r_curve{i},nBS,quantileBS);
  326. CIy(:,i) = median_ci(y_curve{i},nBS,quantileBS);
  327. end
  328. %% plotting performance across time
  329. figure;set(gcf,'color','w')
  330. errorbar(-97:10:-17,medians2plot(1,:),abs( CIb(1,:)-CIb(2,:)),abs(CIb(3,:)-CIb(2,:)),'linewidth',1.5)
  331. hold on
  332. errorbar(-95:10:-15,medians2plot(2,:),abs( CIr(1,:)-CIr(2,:)),abs(CIr(3,:)-CIr(2,:)),'linewidth',1.5)
  333. errorbar(-93:10:-13,medians2plot(3,:),abs( CIy(1,:)-CIy(2,:)),abs(CIy(3,:)-CIy(2,:)),'linewidth',1.5)
  334. xlim([-100 -10])
  335. set(gca,'XTick',[-95:10:-15])
  336. xlabel('Interval of days before question closure')
  337. ylabel('Brier Score')
  338. legend ({'Average of individual Briers';'Team Consensus 1st order';'Team Consensus 2nd order'},'location','northwest')
  339. set(gca,'FontSize',15)
  340. %% comparison of specific time windows within a curve.
  341. ranksum(b_curve{1},b_curve{5})
  342. ranksum(r_curve{1},r_curve{5})
  343. ranksum(y_curve{1},y_curve{5})
  344. %% calculating confidence and absolute performance per time window and per curve of aggregation level
  345. for tw = 1:9
  346. %%% calculate absolute correct
  347. b_prop_correct(tw) = 100 * sum(b_curve{tw}<0.5) / numel(b_curve{tw});
  348. r_prop_correct(tw) = 100 * sum(r_curve{tw}<0.5) / numel(r_curve{tw});
  349. y_prop_correct(tw) = 100 * sum(y_curve{tw}<0.5) / numel(y_curve{tw});
  350. %%% calculate absolute confidence
  351. for i = 1:numel(b_curve{tw})
  352. b_conf_temp(i) = 100 * abs ( Inverse_BrierScoreCalc(b_curve{tw}(i),1) - 0.5) / 0.5;
  353. end
  354. b_confidence {tw} = b_conf_temp;
  355. b_confidence_median(tw) = mean(b_confidence{tw});
  356. b_confidence_SE(tw) = std(b_confidence{tw}) / sqrt(numel(b_confidence{tw}));
  357. for i = 1:numel(r_curve{tw})
  358. r_conf_temp(i) = 100 * abs ( Inverse_BrierScoreCalc(r_curve{tw}(i),1) - 0.5) / 0.5;
  359. end
  360. r_confidence {tw} = r_conf_temp;
  361. r_confidence_median(tw) = mean(r_confidence{tw});
  362. r_confidence_SE(tw) = std(r_confidence{tw}) / sqrt(numel(r_confidence{tw}));
  363. for i = 1:numel(y_curve{tw})
  364. y_conf_temp(i) = 100 * abs ( Inverse_BrierScoreCalc(y_curve{tw}(i),1) - 0.5)/ 0.5;
  365. end
  366. y_confidence {tw} = y_conf_temp;
  367. y_confidence_median(tw) = mean(y_confidence{tw});
  368. y_confidence_SE(tw) = std(y_confidence{tw}) / sqrt(numel(y_confidence{tw}));
  369. clear b_confiidence_temp r_confiidence_temp y_confiidence_temp
  370. end
  371. %%
  372. figure;set(gcf,'color','w')
  373. subplot 211
  374. % plot(-95:10:-15,b_confidence_median)
  375. % hold on
  376. % plot(-95:10:-15,r_confidence_median)
  377. % plot(-95:10:-15,y_confidence_median)
  378. errorbar(-97:10:-17,b_confidence_median,b_confidence_SE,'linewidth',1.3)
  379. hold on
  380. errorbar(-95:10:-15,r_confidence_median,r_confidence_SE,'linewidth',1.3)
  381. errorbar(-93:10:-13,y_confidence_median,y_confidence_SE,'linewidth',1.3)
  382. xlim([-100 -10])
  383. set(gca,'XTick',[-95:10:-15])
  384. % xlabel('Interval of days before question closure')
  385. ylabel('% of max confidence')
  386. % legend ({'Average of individual Briers';'Team Consensus 1st order';'Team Consensus 2nd order'},'location','northwest')
  387. set(gca,'FontSize',10)
  388. subplot 212
  389. plot(-97:10:-17,b_prop_correct,'linewidth',1.3)
  390. hold on
  391. plot(-95:10:-15,r_prop_correct,'linewidth',1.3)
  392. plot(-93:10:-13,y_prop_correct,'linewidth',1.3)
  393. xlim([-100 -10])
  394. set(gca,'XTick',[-95:10:-15])
  395. xlabel('Interval of days before question closure')
  396. ylabel('% of Correct Forecasts')
  397. legend ({'Average of individual Briers';'Team Consensus 1st order';'Team Consensus 2nd order'},'location','northwest')
  398. set(gca,'FontSize',10)
  399. ylim([70 100])
  400. %% figure; set(gcf,'color','w'); OF MEAN (instead of median) PERFORMANCES IN TIME WINDOWS
  401. figure; set(gcf,'color','w');
  402. errorbar (1:9,Performance2_window_mean,Performance2_window_se,'linewidth',3)
  403. hold on
  404. errorbar (1:9,Performance1_window_mean,Performance1_window_se,'linewidth',3)
  405. errorbar (1:9,Consensus_mean_2aggregation_tw,Consensus_se_2aggregation_tw,'linewidth',3)
  406. xlim ([0.5 9.5])
  407. ylim([0.05 0.4])
  408. set(gca,'XTick',[1:9])
  409. set(gca,'XTickLabel',{'110-80','100-70','90-60','80-50','70-40','60-30','50-20','40-10','30-0'})
  410. xlabel('Interval of days before question closure')
  411. ylabel('Brier Score')
  412. legend ({'Average of individual Briers';'Team Consensus 1st order';'Team Consensus 2nd order'},'location','southwest')
  413. set(gca,'FontSize',15)
  414. %% same as above but instead of average, a line per question, averaging only across teams, just a sanity check
  415. figure; set(gcf,'color','w');
  416. for g = 11:90
  417. plot (1:9,Perf1_groupmean_tw (g,:),'b')
  418. hold on
  419. plot (1:9,Perf2_groupmean_tw (g,:) ,'r')
  420. end
  421. set(gca,'XTick',[1:9])
  422. set(gca,'XTickLabel',{'110-80','100-70','90-60','80-50','70-40','60-30','50-20','40-10','30-0'})
  423. xlabel('Interval of days before question closure')
  424. ylabel('Brier Score')
  425. legend ({'Brier of average forecast';'Average of individual Briers'})
  426. title('one line per team')
  427. set(gca,'FontSize',15)
  428. figure; set(gcf,'color','w');
  429. for g = 1:382
  430. plot (1:9,Perf1_questionmean_tw (g,:),'b')
  431. hold on
  432. plot (1:9,Perf2_questionmean_tw (g,:) ,'r')
  433. end
  434. set(gca,'XTick',[1:9])
  435. set(gca,'XTickLabel',{'110-80','100-70','90-60','80-50','70-40','60-30','50-20','40-10','30-0'})
  436. xlabel('Interval of days before question closure')
  437. ylabel('Brier Score')
  438. legend ({'Brier of average forecast';'Average of individual Briers'})
  439. title('one line per question')
  440. set(gca,'FontSize',15)
  441. %% plot modulation index
  442. figure; set(gcf,'color','w');
  443. errorbar (1:9,MI_mean,MI_se,'linewidth',3)
  444. xlim ([0.5 9.5])
  445. set(gca,'XTick',[1:9])
  446. set(gca,'XTickLabel',{'110-80','100-70','90-60','80-50','70-40','60-30','50-20','40-10','30-0'})
  447. xlabel('Interval of days before question closure')
  448. ylabel('Modulation Index')
  449. % legend ({'Brier of average forecast';'Average of individual Briers'})
  450. set(gca,'FontSize',15)
  451. %%
  452. Performance_diff = Performance2_window_raw - Performance1_window_raw;
  453. Performance_sum = Performance2_window_raw + Performance1_window_raw;
  454. MI = Performance_diff./Performance_sum;
  455. nanmean(MI(:))