-
Notifications
You must be signed in to change notification settings - Fork 7
/
mkheader.ado
271 lines (235 loc) · 8.41 KB
/
mkheader.ado
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
*!mkheader version 0.4.0
*!Written 22Apr2023
*!Written by Sergio Venturini and Mehmet Mehmetoglu
*!The following code is distributed under GNU General Public License version 3 (GPL-3)
program mkheader
version 15.1
syntax [, matrix1(string) matrix2(string) DIGits(integer 5) noGRoup ///
noSTRuctural RAWsum rebus_it(integer -999) rebus_gqi(real 0) ///
fimix_it(integer -999) fimix_ll(real 0) GAS CONsistent ]
/* Options:
--------
matrix1(string) --> matrix containing the model assessment
indexes
matrix2(string) --> matrix containing the outer weights maximum
relative difference history
digits(integer 5) --> number of digits to display (default 5)
nogroup --> multigroup indicator
nostructural --> indicator of whether the model includes a
structural part
rawsum --> scores are raw sum of indicators
rebus_it --> number of REBUS-PLS iterations
rebus_gqi --> REBUS-PLS group quality index (GQI)
fimix_it --> number of FIMIX-PLS iterations
fimix_ll --> FIMIX-PLS log-likelihood value attained
gas --> PLS-GAS indicator
consistent --> indicator for consistent PLS (PLSc)
*/
local props = e(properties)
local init : word 1 of `props'
local wscheme : word 2 of `props'
local tol = e(tolerance)
local alllatents = e(lvs)
local allformative = e(formative)
local num_lv : word count `alllatents'
local num_lv_B : word count `allformative'
local num_lv_A = `num_lv' - `num_lv_B'
local relative_lbl "relative"
local isrelative : list relative_lbl in props
display
if ("`consistent'" == "") {
local header "Partial least squares SEM"
}
else {
local header "Consistent partial least squares (PLSc) SEM"
}
if (`isrelative') {
local rel_diff "rel. diff."
}
else {
local rel_diff "sq. diff."
}
if ((`rebus_it' == -999) & (`fimix_it' == -999) & ("`gas'" == "")) {
if ("`group'" == "nogroup") {
if ("`structural'" == "nostructural") {
local nobs: display _skip(0) "`header'" _col(49) ///
"Number of obs" _col(69) "=" _skip(5)
display as text "`nobs'" _continue
display as result e(N)
display
local init_head: display _skip(0) "Initialization: "
display as text "`init_head'" _continue
display as result "`init'"
}
else {
if ("`rawsum'" == "") {
local niter = colsof(`matrix2')
forvalues i = 1/`niter' {
local iter_lbl = "Iteration " + string(`i') + ///
": outer weights " + "`rel_diff'" + " = "
display as text _skip(0) "`iter_lbl'" _continue
display as result string(`matrix2'[1, `i'], "%9.`digits'e")
}
display
}
local nobs: display _skip(0) "`header'" _col(49) ///
"Number of obs" _col(69) "=" _skip(5)
display as text "`nobs'" _continue
display as result e(N)
if (`num_lv_A' > 0) {
local avrsq: display _skip(0) _col(49) "Average R-squared" _col(69) ///
"=" _skip(5)
display as text "`avrsq'" _continue
display as result string(`matrix1'[1, 1], "%9.`digits'f")
local avave: display _skip(0) _col(49) "Average communality" ///
_col(69) "=" _skip(5)
display as text "`avave'" _continue
display as result string(`matrix1'[1, 2], "%9.`digits'f")
}
else {
display
}
if ("`rawsum'" == "") {
local gof: display _skip(0) "Weighting scheme: "
display as text "`gof'" _continue
display as result "`wscheme'" _col(49) _continue
}
else {
local gof: display _skip(0) "Weighting scheme: "
display as text "`gof'" _continue
display as result "rawsum" _col(49) _continue
}
if (`num_lv_A' > 0) {
local gof: display "Absolute GoF" _col(69) "=" _skip(5)
display as text "`gof'" _continue
display as result string(`matrix1'[1, 3], "%9.`digits'f")
}
else {
display
}
if ("`rawsum'" == "") {
local gof_rel: display _skip(0) "Tolerance: "
display as text "`gof_rel'" _continue
display as result string(`tol', "%9.`digits'e") _col(49) _continue
}
else {
local gof_rel: display _skip(0) _col(49)
display as text "`gof_rel'" _continue
}
if (`num_lv_A' > 0) {
local gof_rel: display "Relative GoF" _col(69) "=" _skip(5)
display as text "`gof_rel'" _continue
display as result string(`matrix1'[1, 4], "%9.`digits'f")
}
else {
display
}
if ("`rawsum'" == "") {
local avred: display _skip(0) "Initialization: "
display as text "`avred'" _continue
display as result "`init'" _col(49) _continue
}
else {
local avred: display _skip(0) _col(49)
display as text "`avred'" _continue
}
if (`num_lv_A' > 0) {
local avred: display "Average redundancy" _col(69) "=" _skip(5)
display as text "`avred'" _continue
display as result string(`matrix1'[1, 5], "%9.`digits'f")
}
else {
display
}
}
}
else {
local title: display _skip(0) "`header'"
display as text "`title'"
display
if ("`structural'" == "nostructural") {
local initialize: display _skip(0) "Initialization: "
display as text "`initialize'" _continue
display as result "`init'"
}
else {
if ("`rawsum'" == "") {
local wgt: display _skip(0) "Weighting scheme: "
display as text "`wgt'" _continue
display as result "`wscheme'"
local toler: display _skip(0) "Tolerance: "
display as text "`toler'" _continue
display as result string(`tol', "%9.`digits'e")
}
else {
local wgt: display _skip(0) "Weighting scheme: "
display as text "`wgt'" _continue
display as result "rawsum"
}
if ("`rawsum'" == "") {
local initialize: display _skip(0) "Initialization: "
display as text "`initialize'" _continue
display as result "`init'"
}
else {
local initialize: display _skip(0)
display as text "`initialize'"
}
}
}
}
else if ((`rebus_it' > 0) & (`fimix_it' == -999) & ("`gas'" == "")) {
local title: display _skip(0) "Response-based unit segmentation partial least squares (REBUS-PLS)"
display as text "`title'"
display
local wgt: display _skip(0) "Weighting scheme: "
display as text "`wgt'" _continue
display as result "`wscheme'"
local toler: display _skip(0) "Tolerance: "
display as text "`toler'" _continue
display as result string(`tol', "%9.`digits'e")
local initialize: display _skip(0) "Initialization: "
display as text "`initialize'" _continue
display as result "`init'"
local rebit: display _skip(0) "Number of REBUS-PLS iterations: "
display as text "`rebit'" _continue
display as result "`rebus_it'"
local rebgqi: display _skip(0) "Group Quality Index (GQI): "
display as text "`rebgqi'" _continue
display as result string(`rebus_gqi', "%9.`digits'f")
}
else if ((`rebus_it' == -999) & (`fimix_it' > 0) & ("`gas'" == "")) {
local title: display _skip(0) "Finite mixture partial least squares (FIMIX-PLS)"
display as text "`title'"
display
local wgt: display _skip(0) "Weighting scheme: "
display as text "`wgt'" _continue
display as result "`wscheme'"
local toler: display _skip(0) "Tolerance: "
display as text "`toler'" _continue
display as result string(`tol', "%9.`digits'e")
local initialize: display _skip(0) "Initialization: "
display as text "`initialize'" _continue
display as result "`init'"
local fimit: display _skip(0) "Number of FIMIX-PLS iterations: "
display as text "`fimit'" _continue
display as result "`fimix_it'"
local fimll: display _skip(0) "Log-likelihood value: "
display as text "`fimll'" _continue
display as result string(`fimix_ll', "%99.`digits'f")
}
if ("`gas'" != "") {
local title: display _skip(0) "Partial least squares genetic algorithm segmentation (PLS-GAS)"
display as text "`title'"
display
local wgt: display _skip(0) "Weighting scheme: "
display as text "`wgt'" _continue
display as result "`wscheme'"
local toler: display _skip(0) "Tolerance: "
display as text "`toler'" _continue
display as result string(`tol', "%9.`digits'e")
local initialize: display _skip(0) "Initialization: "
display as text "`initialize'" _continue
display as result "`init'"
}
end