-
Notifications
You must be signed in to change notification settings - Fork 0
/
DataGeneration.m
152 lines (134 loc) · 5.28 KB
/
DataGeneration.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
function [W0] = DataGeneration(p, q, k, n, option)
% generating pq*n regression coefficients %
% there are k nonzero coefficients in each set%
% option, 4 values:
% 1. 'diag_non_bal': diagnal-beta with different structures and balanced groups
% 2. 'diag_non_unbal': diagnal-beta with different structures and unbalanced groups
% 3. 'diag_same_bal': diagnal-beta with same structures but different values and balanced groups
% 4. 'diag_same_unbal': diagnal-beta with same structures but different values and unbalanced groups
if(strcmp(option,'diag_non_bal'))
if(p > q)
blksize = 5;
blk0 = cell(10, 1);
for i = 1:10
blk0{i} = ones(blksize).* binornd(1, 0.8, blksize, blksize);
end
bet_temp_1 = zeros(q, q);
bet_temp_1(1:10*blksize, 1:10*blksize) = blkdiag(blk0{:});
bet_temp_2 = zeros(q, q);
bet_temp_2((10*blksize+1):20*blksize, (10*blksize+1):20*blksize) = blkdiag(blk0{:});
bet_temp_3 = zeros(q, q);
bet_temp_3((20*blksize+1):30*blksize, (20*blksize+1):30*blksize) = blkdiag(blk0{:});
bet_single_1 = [bet_temp_1; zeros(p-q, q)];
bet_single_2 = [bet_temp_2; zeros(p-q, q)];
bet_single_3 = [bet_temp_3; zeros(p-q, q)];
W0 = cell(q, 1);
for i = 1:q
W0{i} = [repmat(bet_single_1(:,i), 1, n/3), repmat(bet_single_2(:,i), 1, n/3), repmat(bet_single_3(:,i), 1, n/3)];
end
else
blksize = 5;
blk0 = cell(10, 1);
for i = 1:10
blk0{i} = ones(blksize).* binornd(1, 0.8, blksize, blksize);
end
bet_single_1 = zeros(p, q);
bet_single_1(1:10*blksize, 1:10*blksize) = blkdiag(blk0{:});
bet_single_2 = zeros(p, q);
bet_single_2((10*blksize+1):20*blksize, (10*blksize+1):20*blksize) = blkdiag(blk0{:});
bet_single_3 = zeros(p, q);
bet_single_3((20*blksize+1):30*blksize, (20*blksize+1):30*blksize) = blkdiag(blk0{:});
W0 = cell(q, 1);
for i = 1:q
W0{i} = [repmat(bet_single_1(:,i), 1, n/3), repmat(bet_single_2(:,i), 1, n/3), repmat(bet_single_3(:,i), 1, n/3)];
end
end
return;
end
if(strcmp(option,'diag_non_unbal'))
if(p > q)
blksize = 5;
blk0 = cell(10, 1);
for i = 1:10
blk0{i} = ones(blksize).* binornd(1, 0.8, blksize, blksize);
end
bet_temp_1 = zeros(q, q);
bet_temp_1(1:10*blksize, 1:10*blksize) = blkdiag(blk0{:});
bet_temp_2 = zeros(q, q);
bet_temp_2((10*blksize+1):20*blksize, (10*blksize+1):20*blksize) = blkdiag(blk0{:});
bet_temp_3 = zeros(q, q);
bet_temp_3((20*blksize+1):30*blksize, (20*blksize+1):30*blksize) = blkdiag(blk0{:});
bet_single_1 = [bet_temp_1; zeros(p-q, q)];
bet_single_2 = [bet_temp_2; zeros(p-q, q)];
bet_single_3 = [bet_temp_3; zeros(p-q, q)];
W0 = cell(q, 1);
for i = 1:q
W0{i} = [repmat(bet_single_1(:,i), 1, 60), repmat(bet_single_2(:,i), 1, 80), repmat(bet_single_3(:,i), 1, 100)];
end
else
blksize = 5;
blk0 = cell(10, 1);
for i = 1:10
blk0{i} = ones(blksize).* binornd(1, 0.8, blksize, blksize);
end
bet_single_1 = zeros(p, q);
bet_single_1(1:10*blksize, 1:10*blksize) = blkdiag(blk0{:});
bet_single_2 = zeros(p, q);
bet_single_2((10*blksize+1):20*blksize, (10*blksize+1):20*blksize) = blkdiag(blk0{:});
bet_single_3 = zeros(p, q);
bet_single_3((20*blksize+1):30*blksize, (20*blksize+1):30*blksize) = blkdiag(blk0{:});
W0 = cell(q, 1);
for i = 1:q
W0{i} = [repmat(bet_single_1(:,i), 1, 60), repmat(bet_single_2(:,i), 1, 80), repmat(bet_single_3(:,i), 1, 100)];
end
end
return;
end
if(strcmp(option,'diag_same_bal'))
blksize = 5;
blk1 = cell(30, 1);
for i = 1:30
blk1{i} = unifrnd(-2.2,-2, blksize, blksize).* binornd(1, 0.8, blksize, blksize);
end
bet_single_1 = blkdiag(blk1{:});
blk2 = cell(30, 1);
for i = 1:30
blk2{i} = unifrnd(1,1.2, blksize, blksize).* binornd(1, 0.8, blksize, blksize);
end
bet_single_2 = blkdiag(blk2{:});
blk3 = cell(30, 1);
for i = 1:30
blk3{i} = unifrnd(2.5,2.8, blksize, blksize).* binornd(1, 0.8, blksize, blksize);
end
bet_single_3 = blkdiag(blk3{:});
W0 = cell(q, 1);
for i = 1:q
W0{i} = [repmat(bet_single_1(:,i), 1, n/3), repmat(bet_single_2(:,i), 1, n/3), repmat(bet_single_3(:,i), 1, n/3)];
end
return;
end
if(strcmp(option,'diag_same_unbal'))
blksize = 5;
blk1 = cell(30, 1);
for i = 1:30
blk1{i} = unifrnd(-2.2,-2, blksize, blksize).* binornd(1, 0.8, blksize, blksize);
end
bet_single_1 = blkdiag(blk1{:});
blk2 = cell(30, 1);
for i = 1:30
blk2{i} = unifrnd(1,1.2, blksize, blksize).* binornd(1, 0.8, blksize, blksize);
end
bet_single_2 = blkdiag(blk2{:});
blk3 = cell(30, 1);
for i = 1:30
blk3{i} = unifrnd(2.5,2.8, blksize, blksize).* binornd(1, 0.8, blksize, blksize);
end
bet_single_3 = blkdiag(blk3{:});
W0 = cell(q, 1);
for i = 1:q
W0{i} = [repmat(bet_single_1(:,i), 1, 60), repmat(bet_single_2(:,i), 1, 80), repmat(bet_single_3(:,i), 1, 100)];
end
return;
end
disp('option is wrong!');
end