-
Notifications
You must be signed in to change notification settings - Fork 0
/
PatientSims.m
66 lines (54 loc) · 1.97 KB
/
PatientSims.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
clear all;
close all;
%% Distribution Parameters
NumberOfSubjects = 1000;
WEIGHT = 1;
ALB = 2;
BSLD = 3;
eGFR = 4;
Means(WEIGHT) = 76.8; % kg
Means(ALB) = 39.6; % g/L
Means(BSLD) = 89.6; % mm
Means(eGFR) = 88.47; % mL/min/1.73 m^2
SD(WEIGHT) = 10;
SD(ALB) = 3.3;
SD(BSLD) = 14.87;
SD(eGFR) = 9.7;
LowCutoff(WEIGHT) = 56.8;
LowCutoff(ALB) = 15;
LowCutoff(BSLD) = 10;
LowCutoff(eGFR) = 25.4;
HighCutoff(WEIGHT) = 96.8;
HighCutoff(ALB) = 57;
HighCutoff(BSLD) = 895;
HighCutoff(eGFR) = 403;
%% Generate Simulations
% Initiate Random Numbers
rng(0, 'twister');
% Generate Subpopulations
for i = 1:4 % 4 params
xtemp = SD(i) .* randn(NumberOfSubjects, 1) + Means(i);
a = length(xtemp(xtemp < LowCutoff(i))) + length(xtemp(xtemp > HighCutoff(i)));
cycle = 1;
while a > 0
xtemp(xtemp < LowCutoff(i) | xtemp > HighCutoff(i)) = SD(i) .* randn(a, 1) + Means(i);
a = length(xtemp(xtemp <= LowCutoff(i))) + length(xtemp(xtemp > HighCutoff(i)));
cycle = cycle + 1;
end
xdist(i, :) = xtemp;
end
% Output the means, SDs of the simulated populations
SimMeans = mean(xdist, 2);
SimSDs = std(xdist, 0, 2);
fprintf('Weight distribution, input mean %4.1f, simulated mean %4.1f; input SD %4.1f, simulated SD %4.1f \n', ...
Means(WEIGHT), SimMeans(WEIGHT), SD(WEIGHT), SimSDs(WEIGHT))
fprintf('Albumin distribution, input mean %4.1f, simulated mean %4.1f; input SD %4.1f, simulated SD %4.1f \n', ...
Means(ALB), SimMeans(ALB), SD(ALB), SimSDs(ALB))
fprintf('Tumor burden distribution, input mean %4.1f, simulated mean %4.1f; input SD %4.1f, simulated SD %4.1f \n', ...
Means(BSLD), SimMeans(BSLD), SD(BSLD), SimSDs(BSLD))
fprintf('Estimated glomerular filtration rate distribution, input mean %4.1f, simulated mean %4.1f; input SD %4.1f, simulated SD %4.1f \n', ...
Means(eGFR), SimMeans(eGFR), SD(eGFR), SimSDs(eGFR))
patientID = (1:NumberOfSubjects)';
Params = xdist';
name = sprintf('PatientSims_%d.mat', NumberOfSubjects);
save(name, 'patientID', 'Params');