-
Notifications
You must be signed in to change notification settings - Fork 0
/
regressionBased.m
117 lines (112 loc) · 4.03 KB
/
regressionBased.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
% regressionBased: plots all regression-based scaling exponents
% plots ln(Number of endpoints) vs ln(radius or length)
%HISTORY
% Jocie Shen, 7/11/16, first written
%============================================================
clear all; close all; clc;
cName = 'patient3_c.txt'
aName = 'patient3.txt'
%C++ Regression-based method: Scaling exponent a
figure
arr = fillArr(4, 'r', 'C++', cName);
[bins, frequency] = getBinFreq(arr, 4);
scatter(bins, frequency);
title('Regression-based calculation of a (C++)','fontweight','bold');
xlabel('ln(Number of endpoints)','fontweight','bold') % x-axis label
ylabel('ln(radius)','fontweight','bold') % y-axis label
coeffs = polyfit(bins, frequency, 1);
fittedX = linspace(min(bins), max(bins), length(frequency));
fittedY = polyval(coeffs, fittedX);
hold on;
plot(fittedX, fittedY, 'r-', 'LineWidth', 1);
[b,bint] = regress(frequency(:), bins(:));
CI = (abs(bint(1)) + abs(bint(2)))/2;
[b,bint,r,rint,stats] = regress(frequency(:),bins(:),95);
exp = b;
formatSpec = 'N = %4.2f\n';
fprintf(formatSpec,length(bins));
formatSpec = 'a (C++) %4.2f\n';
fprintf(formatSpec,exp);
formatSpec = 'CI = %4.2f\n';
fprintf(formatSpec,CI);
rsq = stats(1);
formatSpec = 'R^2 = %4.2f\n';
fprintf(formatSpec,rsq);
%C++ Regression-based method: Scaling exponent a
figure
arr = fillArr(4, 'l', 'C++', cName);
[bins, frequency] = getBinFreq(arr, 4);
scatter(bins, frequency);
title('Regression-based calculation of a (C++)','fontweight','bold');
xlabel('ln(Number of endpoints)','fontweight','bold') % x-axis label
ylabel('ln(radius)','fontweight','bold') % y-axis label
coeffs = polyfit(bins, frequency, 1);
fittedX = linspace(min(bins), max(bins), length(frequency));
fittedY = polyval(coeffs, fittedX);
hold on;
plot(fittedX, fittedY, 'r-', 'LineWidth', 1);
[b,bint] = regress(frequency(:), bins(:));
CI = (abs(bint(1)) + abs(bint(2)))/2;
[b,bint,r,rint,stats] = regress(frequency(:),bins(:),95);
exp = b;
formatSpec = 'N = %4.2f\n';
fprintf(formatSpec,length(bins));
formatSpec = 'a (C++) %4.2f\n';
fprintf(formatSpec,exp);
formatSpec = 'CI = %4.2f\n';
fprintf(formatSpec,CI);
rsq = stats(1);
formatSpec = 'R^2 = %4.2f\n';
fprintf(formatSpec,rsq);
%ANGICART Regression-based method: Scaling exponent a
figure
arr = fillArr(4, 'r', 'angicart', aName);
[bins, frequency] = getBinFreq(arr, 4);
scatter(bins, frequency);
title('Regression-based calculation of a (angicart)','fontweight','bold');
xlabel('ln(Number of endpoints)','fontweight','bold') % x-axis label
ylabel('ln(radius)','fontweight','bold') % y-axis label
coeffs = polyfit(bins, frequency, 1);
fittedX = linspace(min(bins), max(bins), length(frequency));
fittedY = polyval(coeffs, fittedX);
hold on;
plot(fittedX, fittedY, 'r-', 'LineWidth', 1);
[b,bint] = regress(frequency(:), bins(:));
CI = (abs(bint(1)) + abs(bint(2)))/2;
[b,bint,r,rint,stats] = regress(frequency(:),bins(:),95);
exp = b;
formatSpec = 'N = %4.2f\n';
fprintf(formatSpec,length(bins));
formatSpec = 'a (C++) %4.2f\n';
fprintf(formatSpec,exp);
formatSpec = 'CI = %4.2f\n';
fprintf(formatSpec,CI);
rsq = stats(1);
formatSpec = 'R^2 = %4.2f\n';
fprintf(formatSpec,rsq);
%ANGICART Regression-based method: Scaling exponent b
figure
arr = fillArr(4, 'l', 'angicart', aName);
[bins, frequency] = getBinFreq(arr, 4);
scatter(bins, frequency);
title('Regression-based calculation of b (angicart)','fontweight','bold');
xlabel('ln(Number of endpoints)','fontweight','bold') % x-axis label
ylabel('ln(length)','fontweight','bold') % y-axis label
coeffs = polyfit(bins, frequency, 1);
fittedX = linspace(min(bins), max(bins), length(frequency));
fittedY = polyval(coeffs, fittedX);
hold on;
plot(fittedX, fittedY, 'r-', 'LineWidth', 1);
[b,bint] = regress(frequency(:), bins(:));
CI = (abs(bint(1)) + abs(bint(2)))/2;
[b,bint,r,rint,stats] = regress(frequency(:),bins(:),95);
exp = b;
formatSpec = 'N = %4.2f\n';
fprintf(formatSpec,length(bins));
formatSpec = 'a (C++) %4.2f\n';
fprintf(formatSpec,exp);
formatSpec = 'CI = %4.2f\n';
fprintf(formatSpec,CI);
rsq = stats(1);
formatSpec = 'R^2 = %4.2f\n';
fprintf(formatSpec,rsq);