-
Notifications
You must be signed in to change notification settings - Fork 1
/
rectilinear_nonlinear_stats_plots_family_sameA_all.m
286 lines (204 loc) · 9.45 KB
/
rectilinear_nonlinear_stats_plots_family_sameA_all.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
clear
% tetracosane C24
T1 = [580 590 600 610 625 675 700 725 750];
pv1 = [0.0010309 0.0015445 0.0021023 0.0025044 0.003415 0.009588 0.016419 0.026868 0.032001];
pL1 = [0.611756 0.6060484 0.5909036 0.5878981 0.57159 0.52602 0.50403 0.47456 0.43912];
% pentacosane C25
T2 = [580 590 600 610 615 650 690 730 750];
pv2 = [0.00109 0.001412 0.001406 0.002087415 0.00265 0.004574594 0.010672267 0.018401342 0.031339834];
pL2 = [0.616996 0.608843 0.59835 0.592602248 0.587282 0.555748238 0.519263592 0.471308627 0.45664106];
% hexacosane C26
T3 = [610 655 700 740 760];
pv3 = [ 0.001423 0.00429041 0.010017451 0.023451055 0.026356036];
pL3 = [ 0.592659 0.557560998 0.516726592 0.477174855 0.441255922];
% 615 0.001808302 0.59482208 data excluded b/c inconsistent with new data
% heptacosane C27
T4 = [580 610 620 660 700 745 765];
pv4 = [0.00036 0.001345 0.15333E-02 0.45482E-02 0.91630E-02 0.19332E-01 0.24939E-01];
pL4 = [0.620732 0.602083 0.58842 0.55523 0.52438 0.47300 0.44285];
% The 580 data is questionable b/c not equil, but it improved regression
% octacosane C28
T5 = [580 600 610 625 665 710 750 770];
pv5 = [0.000304 0.000655 0.001123 0.17462E-02 0.48022E-02 0.11550E-01 0.17752E-01 0.25336E-01];
pL5 = [0.624137 0.612879 0.602442 0.59089 0.56211 0.51428 0.46550 0.45160];
A = 4.031634e-4;
b1 = 0.1060823;
b2 = 0.1054392;
b3 = 0.1048676;
b4 = 0.1046103;
b5 = 0.1044448;
pc1 = 0.21137;
pc2 = 0.2094131;
pc3 = 0.2077101;
pc4 = 0.2063328;
pc5 = 0.2060522;
TC1 = 816.295217;
TC2 = 826.7979716;
TC3 = 835.3305909;
TC4 = 842.0696458;
TC5 = 848.270683;
n1 = length(T1);
n2 = length(T2);
n3 = length(T3);
n4 = length(T4);
n5 = length(T5);
n = n1+n2+n3+n4+n5;
beta = 0.32;
p = 16; % 16 now because all the parameters are regressed simultaneously
y1 = (pv1 + pL1)/2;
z1 = pL1 - pv1;
y2 = (pv2 + pL2)/2;
z2 = pL2 - pv2;
y3 = (pv3 + pL3)/2;
z3 = pL3 - pv3;
y4 = (pv4 + pL4)/2;
z4 = pL4 - pv4;
y5 = (pv5 + pL5)/2;
z5 = pL5 - pv5;
SE_fit1 = (y1 - (pc1 + A*(TC1-T1))).^2 + (z1 - (b1*(TC1-T1).^beta)).^2;
SE_fit2 = (y2 - (pc2 + A*(TC2-T2))).^2 + (z2 - (b2*(TC2-T2).^beta)).^2;
SE_fit3 = (y3 - (pc3 + A*(TC3-T3))).^2 + (z3 - (b3*(TC3-T3).^beta)).^2;
SE_fit4 = (y4 - (pc4 + A*(TC4-T4))).^2 + (z4 - (b4*(TC4-T4).^beta)).^2;
SE_fit5 = (y5 - (pc5 + A*(TC5-T5))).^2 + (z5 - (b5*(TC5-T5).^beta)).^2;
SSE_fit1 = sum(SE_fit1);
SSE_fit2 = sum(SE_fit2);
SSE_fit3 = sum(SE_fit3);
SSE_fit4 = sum(SE_fit4);
SSE_fit5 = sum(SE_fit5);
SSE_fit = SSE_fit1 + SSE_fit2 + SSE_fit3 + SSE_fit4 + SSE_fit5;
sigma2 = SSE_fit/(n-p);
RHS = sigma2 * (n + p * (finv(0.95^p,p,n-p)-1)); % Just one RHS because all one regression
% These are supposed to be slightly larger than the extrema found below, just so that you can verify this range.
% Be careful, for the b_range I realized that the displayed number is
% rounded off, so make sure it really found the min or max
A_range = [3.8766 4.0316 4.1766]*10^-4;
% I trimmed in the ranges by the last digit just so that we for sure were
% in the confidence region found by the individual sameA regressions
% Ranges used for 24
b_range1 = [0.1037 b1 0.1083];
pc_range1 = [0.204 pc1 0.218];
TC_range1 = [807 TC1 827];
% b_range1 = 0.1036:0.00008:0.1084;
% pc_range1 = 0.203:0.00025:0.219;
% TC_range1 = 806:0.25:828;
% Ranges used for 25
b_range2 = [0.1031 b2 0.1077];
pc_range2 = [0.202 pc2 0.216];
TC_range2 = [816 TC2 839];
% Found by using the best fit values for all other parameters.
% b_range2 = 0.103:0.0001:0.1078;
% pc_range2 = 0.201:0.00025:0.217;
% TC_range2 = 815:0.3:840;
% Ranges used for 26 (these data are worthless) Essentially you must have
% more data points to lock down pc-TC at all
b_range3 = [0.1009 b3 0.1086];
pc_range3 = [0.198 pc3 0.216];
TC_range3 = [821 TC3 854];
% b_range3 = 0.1008:0.0001:0.1087;
% pc_range3 = 0.197:0.00025:0.217;
% TC_range3 = 820:0.5:855;
% Ranges used for 27
b_range4 = [0.1019 b4 0.1072];
pc_range4 = [0.198 pc4 0.214];
TC_range4 = [831 TC4 855];
% b_range4 = 0.1018:0.0001:0.1073;
% pc_range4 = 0.197:0.0002:0.215;
% TC_range4 = 830:0.3:856;
% Ranges used for 28
b_range5 = [0.10186 b5 0.1068];
pc_range5 = [0.198 pc5 0.213];
TC_range5 = [838 TC5 862];
% b_range5 = 0.10185:0.0001:0.1069;
% pc_range5 = 0.197:0.00025:0.214;
% TC_range5 = 837:0.3:863;
% confidence_region1 = ones(length(pc_range1),length(TC_range1));
% confidence_region2 = ones(length(pc_range2),length(TC_range2));
% confidence_region3 = ones(length(pc_range3),length(TC_range3));
% confidence_region4 = ones(length(pc_range4),length(TC_range4));
% confidence_region5 = ones(length(pc_range5),length(TC_range5));
pc = [pc1 pc2 pc3 pc4 pc5];
s=1;
for g=1:length(A_range) % Only one A range
for h1=1:length(b_range1)
for i1=1:length(pc_range1)
for j1=1:length(TC_range1)
for h2=1:length(b_range2)
for i2=1:length(pc_range2)
for j2=1:length(TC_range2)
for h3=1:length(b_range3)
for i3=1:length(pc_range3)
for j3=1:length(TC_range3)
for h4=1:length(b_range4)
for i4=1:length(pc_range4)
for j4=1:length(TC_range4)
for h5=1:length(b_range5)
for i5=1:length(pc_range5)
for j5=1:length(TC_range5)
SE1 = (y1 - (pc_range1(i1) + A_range(g)*(TC_range1(j1)-T1))).^2 + (z1 - (b_range1(h1)*(TC_range1(j1)-T1).^beta)).^2;
SE2 = (y2 - (pc_range2(i2) + A_range(g)*(TC_range2(j2)-T2))).^2 + (z2 - (b_range2(h2)*(TC_range2(j2)-T2).^beta)).^2;
SE3 = (y3 - (pc_range3(i3) + A_range(g)*(TC_range3(j3)-T3))).^2 + (z3 - (b_range3(h3)*(TC_range3(j3)-T3).^beta)).^2;
SE4 = (y4 - (pc_range4(i4) + A_range(g)*(TC_range4(j4)-T4))).^2 + (z4 - (b_range4(h4)*(TC_range4(j4)-T4).^beta)).^2;
SE5 = (y5 - (pc_range5(i5) + A_range(g)*(TC_range5(j5)-T5))).^2 + (z5 - (b_range5(h5)*(TC_range5(j5)-T5).^beta)).^2;
SSE1 = sum(SE1);
SSE2 = sum(SE2);
SSE3 = sum(SE3);
SSE4 = sum(SE4);
SSE5 = sum(SE5);
SSE = SSE1 + SSE2 + SSE3 + SSE4 + SSE5;
if SSE > RHS
else
%We start confidence_region at one value and change it only if
%the SSE is less than the RHS. This is because we want to plot
%any pc-TC that is acceptable. Otherwise we would be
%overwritting accepted points whenever one is rejected.
% confidence_region1(i1,j1) = 0; % We only want to plot pc vs TC
% confidence_region2(i2,j2) = 0;
% confidence_region3(i3,j3) = 0;
% confidence_region4(i4,j4) = 0;
% confidence_region5(i5,j5) = 0;
A_ext(s) = A_range(g);
b_ext1(s) = b_range1(h1);
b_ext2(s) = b_range2(h2);
b_ext3(s) = b_range3(h3);
b_ext4(s) = b_range4(h4);
b_ext5(s) = b_range5(h5);
s=s+1;
pc = [pc; pc_range1(i1) pc_range2(i2) pc_range3(i3) pc_range4(i4) pc_range5(i5)];
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
A_low = min(A_ext);
A_high = max(A_ext);
b_low1 = min(b_ext1);
b_high1 = max(b_ext1);
b_low2 = min(b_ext2);
b_high2 = max(b_ext2);
b_low3 = min(b_ext3);
b_high3 = max(b_ext3);
b_low4 = min(b_ext4);
b_high4 = max(b_ext4);
b_low5 = min(b_ext5);
b_high5 = max(b_ext5);
% hold
%
% contour(TC_range1,pc_range1,confidence_region1)
% contour(TC_range2,pc_range2,confidence_region2)
% contour(TC_range3,pc_range3,confidence_region3)
% contour(TC_range4,pc_range4,confidence_region4)
% contour(TC_range5,pc_range5,confidence_region5)
%
% hold