-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcMplusOutput.cls
3620 lines (3151 loc) · 197 KB
/
cMplusOutput.cls
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
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
END
Attribute VB_Name = "cMplusOutput"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
' Wrapper goes: (1) Multiple groups, (2) WITHIN-BETWEEN, (3) Mixtures
' Scale list
' - Scale short name
' - Scale alias
' Collection: List of observed matrices
' Collection: List of model matrices
' Covariance coverage matrix
' - Covariance coverage
' Array for observed variables + vector for means
' - Covariances (variances in diagonal)s
' - Correlations
' - Model implied covariances
' - Residual covariances
' - Model implied correlations
' - Residual correlations
' Model array
' - Non-directional array (theta and psi matrix)
' - Directional array (beta, lambda, gamma)
' Each element: effect, SE/SD, t, p, CI_005 CI_025 CI_050 CI_950 CI_975 CI_995
' Each with layers for (1) unstandardized, stydx, std, (2) groups / mixtures / levels
' Model array:
Dim out_text ' Contains the raw text from the output file
Dim pNumLines ' Number of lines in the output file
Dim pLinePos() ' The location in "out_text" of the begininng of each line
Dim var_cntr ' Number of variables
Dim var_list() ' List of variables, labels, scales, and sample-level information
Dim scale_list() ' List of scales and their aliases
Dim obs_matrix_list As New Collection ' A list of the matrices of observed variables
Dim obs_matrix_lookup() ' An array containing the lookup coordinates for different models. Dimension 1: (1) Group, (2) Level. Dimension 2: Model number.
Dim obs_matrix() ' An array containing data from the covariances of the observed variables (y,x,std,grp)
Dim obs_vector() ' A vector containing the means of each variable (y, std, grp)
Dim obs_n() ' An array containing the overall sample size of each group / level / mixture
Dim avg_csize() ' An array containing the average cluster size of each group / level
Dim cov_coverage() ' A matrix containing information about covariance coverage
Dim mod_matrix_list As New Collection ' A list of the matrices from the model
Dim mod_matrix_lookup() ' An array containing the lookup coordinates for different models. Dimension 1: (1) Group, (2) Level, (3) Mixture. Dimension 2: Model number
Dim mod_matrix_directional() ' An array containing directional results from the model (BETA / LAMBDA / GAMMA / KAPPA). Dimension 1: IV, 2: DV, 3: Standardization, 4: Group/Level/Mixture
Dim mod_matrix_nondirectional() ' An array containing non-directional results from the mode (PSI / THETA)
Dim mod_vector() ' A vector cotaining the means/intercepts of each variable
Dim mod_rsquare() ' A vector containing information about the R-Square of each variable
'1: Coefficient / Bayes Coefficient / Monte Carlo Average
'2: Standard error / Bayes SD / Monte Carlo SD
'3: t statistic
'4: P value / Bayes P-value
'5: CI: 0.01
'6: CI: 0.05
'7: CI: 0.10
'8: CI: 0.90
'9: CI: 0.95
'10: CI: 0.99
'11: Monte Carlo Population
'12: Monte Carlo SE Average
'13: Monte Carlo MSE
'14: Monte Carlo 95% Cover
'15: Monte Carlo % Sig Coef
'16: Multiple imputation (rate of missing)
Dim grouplist As New Collection ' A list of all of the groups for multiple group analyses
Dim levellist As New Collection ' A list of all of the clusters for multilevel analysis
Dim mixturelist As New Collection ' A list of all of the mixtures within mixture models
Dim standardlist As New Collection ' A list of the types of standardization used
'Dim SampleSize As New Collection ' Total sample size for each group / cluster / mixture
Dim stdyx_num ' The standardisation number of STDYX
Public IsSAMPSTAT As Boolean ' Whether sample statistics are available
Public IsCovCoverage As Boolean ' Whether information about covariance coverage is available
Public IsICC As Boolean ' Whether sample ICCs are available
Public IsSTDYX As Boolean ' Whether STDYX output is available
Public IsSTDY As Boolean ' Whether STY output is available
Public IsSTD As Boolean ' Whether STD output is available
Public IsOddsRatio As Boolean ' Whether odds ratio output is available
Public IsRSquare As Boolean ' Whether R-Square is available
Public IsCInterval As Boolean ' Whether confidence/credibility intervals are available
Public IsBasic As Boolean ' Whether the analysis is TYPE = BASIC
Public IsResidual As Boolean ' Whether residual output is available
Public IsModel As Boolean ' Whether model results are available
Public IsImputation As Boolean ' Whether the analysis is based on imputation
Public IsMonteCarlo As Boolean ' Whether the analysis is a Monte Carlo simulation
Public IsTECH4 As Boolean ' Does Technical 4 output exist?
Public nGroups As Integer ' Number of groups
Public nLevels As Integer ' Number of levels in the analysis (default is 1)
Public nMixtures As Integer ' Number of mixtures
Public nStandards As Integer ' Number of formats for standardised results
Public Estimator As String ' The estimator used by the analysis
Public nDV, nIV, nCoLV, nCaLV, nTotalV As Integer ' Number of DVs, IVs, Continuous Latents, Categorical Latents, Total Variables
Public ChiSq
Public DF
Public ChiSqP
Public CFI, TLI
Public RMSEA
Public SRMR, SRMR_W, SRMR_B
Public AIC
Public BIC
Public BICssa
Public BayesLower
Public BayesUpper
Public PPP
Public PPPP
Public DIC
Public PD
Dim SAMPSTAT_vList As New Collection ' An ordered list of variables contained within "Sample Statistics"
Dim VarList() ' Information about the variables
' Variable list
' 1 Variable short name
' 2 Variable label
' 3 Scale
' 4 Variable type (1 = continuous, 2 = binary / ordered categorical, 3 = nominal, 4 = count, 5 = observed IV, 6 = continuous latent, 7 = categorical latent, 8 = EFA/ESEM factor)
' 5 Observed (False) or latent (True)
' 6 Mean
' 7 Variance
' 8 Sample size
' 9 Skew
' 10 Kurtosis
' 11 Minimum
' 12 20%
' 13 40%
' 14 50% (median)
' 15 60%
' 16 80%
' 17 Maximum
' 18 % Minimum
' 19 % Maximum
' 20 % Zero (for COUNT variables)
' 21 Observed matrix numbered variable
' 22 ICC
' 23 DV order (if a dependent variable)
' 24 Antecedent order (if an antecedent in an ON command)
' 25 Composite (is this an observed variable that is correlated with a latent variable TRUE/FALSE)
Public Property Get pVarList(y, x)
pVarList = VarList(y, x)
End Property
Public Property Get pMod_Matrix(y, x, Optional Stand_Num = 1, Optional model_num = 1)
pMod_Matrix = mod_matrix_directional(y, x, Stand_Num, mod_Group(model_num), mod_Level(model_num), mod_Mixture(model_num))
End Property
Public Property Let ParseOutputFile(filename As String)
Dim text: text = ""
On Error GoTo errorhandler
Open filename For Input As #1
Do Until EOF(1)
Line Input #1, textline
text = text & textline & Chr(10)
Loop
Close #1
ParseOutput text
Exit Property
errorhandler:
MsgBox "Error opening Mplus output file."
End
End Property
Public Property Let ParseOutput(text As String)
VarList = Array()
' This method parses an Mplus output file and transforms it into usable data
Debug.Print "Parsing output..."
' Populate the private variable, out_text, and get rid of carriage returns (to make it compatible with Macs)
out_text = Replace(text, Chr(13), "")
' Set up the defaults
IsSAMPSTAT = False
IsSTDYX = False
IsSTDY = False
IsSTD = False
IsOddsRatio = False
IsRSquare = False
IsCInterval = False
IsResidual = False
IsModel = False
nLevels = 1
nGroups = 1
nMixtures = 1
stdyx_num = 0
ReDim mod_matrix_lookup(1 To 3, 1 To 1)
ParseLines ' Call parse the lines sub
AnalysisInfo ' Generate analysis information
' Based on the above information, produce list of matrices (sample statistics and models)
' 1) Create list of observed matrices
Debug.Print "Creating list of observed matrices"
ReDim obs_matrix_lookup(1 To 2, 1 To nGroups * nLevels)
If nLevels < 3 Then ' Sample statistics are usually not provided for THREELEVEL (using Bayesian estimation)
For a = 1 To nGroups
temp_name = ""
If nGroups > 1 Then temp_name = grouplist(a)
For b = 1 To nLevels
Debug.Print "Group: "; temp_name
temp_name2 = temp_name
If nLevels > 1 Then
Debug.Print "Level: "; levellist(b)
temp_name2 = temp_name2 & " " & levellist(b)
End If
obs_matrix_list.Add Trim(temp_name2)
obs_matrix_lookup(1, obs_matrix_list.Count) = a
obs_matrix_lookup(2, obs_matrix_list.Count) = b
Debug.Print a; b; obs_matrix_list(obs_matrix_list.Count)
Next
Next
End If
' 2) Create list of sample sizes
Debug.Print "Creating list of sample sizes"
ReDim obs_n(1 To nGroups, 1 To nLevels, 1 To nMixtures)
ReDim avg_csize(1 To nGroups, 1 To nLevels)
If nGroups = 1 And nLevels = 1 Then
obs_n(1, 1, 1) = Word(FindLine("Number of observations"), 4)
'SampleSize.Add Word(FindLine("Number of observations"), 4)
Debug.Print "Number of cases: " & Word(FindLine("Number of observations"), 4)
ElseIf nGroups = 1 And nLevels > 1 Then
obs_n(1, 1, 1) = Word(FindLine("Number of observations"), 4)
obs_n(1, 2, 1) = Word(FindLine("Number of clusters"), 4)
avg_csize(1, 2) = Word(FindLine("Average cluster size"), 4)
Debug.Print "Number of cases: " & obs_n(1, 1, 1)
Debug.Print "Number of clusters: " & obs_n(1, 2, 1)
Debug.Print "Average cluster size: " & avg_csize(1, 2)
ElseIf nGroups > 1 Then
temp_line = FindLine("Number of groups")
For a = 1 To nGroups
obs_n(a, 1, 1) = Word(temp_line + a + 1, 3)
'SampleSize.Add Word(temp_line + a + 1, 3)
Debug.Print "-Group " & a & ": " & grouplist.Item(grouplist.Count) & " (n = " & obs_n(a, 1, 1) & ")"
If nLevels > 1 Then
temp_line2 = FindLine("SUMMARY OF DATA")
temp_line2 = FindLine("Group " & grouplist(a), temp_line2)
obs_n(a, 2, 1) = Word(FindLine("Number of clusters", temp_line2), 4)
avg_csize(a, 2) = Word(FindLine("Average cluster size", temp_line2), 4)
End If
Next
End If
' 2.5) Find ICCs
If nLevels > 1 And FindLine("Estimated Intraclass Correlations") > 0 Then
Debug.Print "Finding sample ICCs"
IsICC = True
start_line = FindLine("SUMMARY OF DATA")
For a = 1 To nGroups
If nGroups > 1 Then start_line = FindLine("Group " & grouplist(a), start_line)
start_line2 = FindLine("Estimated Intraclass Correlations", start_line) + 5
Do While Num_Words_on_Line(start_line2) > 0
For b = 1 To Num_Words_on_Line(start_line2) / 2
v_num = VarNum(Word(start_line2, (b * 2) - 1))
VarList(v_num, 22) = ADD_STRINGVECTOR(VarList(v_num, 22), Word(start_line2, b * 2))
Next
start_line2 = start_line2 + 1
Loop
Next
End If
' 3) Create a list of models
' Add a single group if there's only unstandardised output
' If grouplist.Count = 0 And levellist.Count = 0 And mixturelist.Count = 0 And standardlist.Count = 1 Then mod_matrix_list.Add SET_STRINGVECTOR("", "", "", "")
Debug.Print nGroups, nLevels, nMixtures, nStandards
ReDim mod_matrix_lookup(1 To 3, 1 To nGroups * nLevels * nMixtures)
For a = 1 To nGroups
For b = 1 To nLevels
For C = 1 To nMixtures
grp_name = ""
lev_name = ""
mix_name = ""
If grouplist.Count >= a Then grp_name = grouplist(a)
If levellist.Count >= b Then lev_name = levellist(b)
If mixturelist.Count >= C Then mix_name = mixturelist(C)
mod_matrix_list.Add SET_STRINGVECTOR(grp_name, lev_name, mix_name) ', std_name)
mod_matrix_lookup(1, mod_matrix_list.Count) = a ' Set it to the group
mod_matrix_lookup(2, mod_matrix_list.Count) = b ' Set it to the level
mod_matrix_lookup(3, mod_matrix_list.Count) = C ' Set it to the mixture
Debug.Print "Adding model matrix: " & mod_matrix_list(mod_matrix_list.Count)
Next
Next
Next
AddSampstat
' Add covariance coverage
start_line = FindLine("COVARIANCE COVERAGE OF DATA")
If start_line > 0 Then
IsCovCoverage = True
'MsgBox "Variables: " & var_cntr & ", Groups: " & nGroups
ReDim cov_coverage(1 To ObservedVariable, 1 To ObservedVariable, 1 To nGroups)
For a = 1 To nGroups
Debug.Print "Covariance coverage "; a; " of "; nGroups
temp_line = "PROPORTION OF DATA PRESENT"
If nGroups > 1 Then temp_line = temp_line & " FOR " & grouplist(a)
start_line = FindLine(temp_line)
start_line2 = FindLine("Covariance Coverage", start_line)
Do While CONTAINS(line(start_line2), "Covariance Coverage")
start_line3 = start_line2 + 2
For y = 1 To Num_NonBlankLines(start_line3 + 1)
y_var = VarNum(Word(start_line3 + y, 1))
temp_text = ""
For x = 2 To Num_Words_on_Line(start_line3 + y)
x_var = VarNum(Word(start_line3 - 1, x - 1))
Debug.Print y_var, x_var, a, Word(start_line3 + y, x)
Debug.Print LBound(cov_coverage, 1), UBound(cov_coverage, 1)
Debug.Print LBound(cov_coverage, 2), UBound(cov_coverage, 2)
Debug.Print LBound(cov_coverage, 3), UBound(cov_coverage, 3)
'MsgBox y_var & " " & x_var & " " & a & " " & UBound(cov_coverage, 1) & " " & UBound(cov_coverage, 2) & " " & UBound(cov_coverage, 3)
cov_coverage(y_var, x_var, a) = Word(start_line3 + y, x)
cov_coverage(x_var, y_var, a) = cov_coverage(y_var, x_var, a)
Debug.Print "Complete 2"
temp_text = temp_text & " " & Word(start_line3 + y, x)
Next
end_line = start_line3 + y
Debug.Print "Found line of covariance coverages: " & temp_text
Next
start_line2 = Next_NonBlank_Line(end_line)
Loop
Next
End If
AddModelResults
' Find model fit statistics
If IsModel = True Then
temp_line = FindLine("Information Criteria")
If temp_line > 0 Then
AIC = Word(FindLine("Akaike (AIC)", temp_line), 3)
BIC = Word(FindLine("Bayesian (BIC)", temp_line), 3)
BICssa = Word(FindLine("Sample-Size Adjusted BIC", temp_line), 4)
End If
If Estimator = "BAYES" Then
temp_line = FindLine("Bayesian Posterior Predictive Checking using Chi-Square")
If temp_line > 0 Then
BayesLower = Word(FindLine("the Observed and the Replicated Chi-Square Values", temp_line, 2) + 2, 1)
BayesUpper = Word(FindLine("the Observed and the Replicated Chi-Square Values", temp_line, 2) + 2, 2)
PPP = Word(FindLine("Posterior Predictive P-Value", temp_line), 4)
If FindLine("Prior Posterior Predictive P-Value") > 0 Then PPPP = Word(FindLine("Prior Posterior Predictive P-Value", temp_line), 5)
DIC = Word(FindLine("Deviance (DIC)", temp_line), 3)
PD = Word(FindLine("Estimated Number of Parameters (pD)", temp_line), 6)
BIC = Word(FindLine("Bayesian (BIC)", temp_line), 3)
End If
Else
temp_line = FindLine("Chi-Square Test of Model Fit")
If temp_line > 0 Then
ChiSq = Word(FindLine("Value", temp_line), 2)
DF = Word(FindLine("Degrees of Freedom", temp_line), 4)
ChiSqP = Word(FindLine("P-Value", temp_line), 2)
If Right(ChiSq, 1) = "*" Then ChiSq = Left(ChiSq, Len(ChiSq) - 1)
End If
temp_line = FindLine("RMSEA (Root Mean Square Error Of Approximation)")
If temp_line > 0 Then RMSEA = Word(FindLine("Estimate", temp_line), 2)
temp_line = FindLine("CFI/TLI")
If temp_line > 0 Then CFI = Word(FindLine("CFI", temp_line + 1), 2)
If temp_line > 0 Then TLI = Word(FindLine("TLI", temp_line + 1), 2)
temp_line = FindLine("SRMR (Standardized Root Mean Square Residual)")
If temp_line > 0 Then
If nLevels > 1 Then
SRMR_W = Word(FindLine("Value for Within", temp_line), 4)
SRMR_B = Word(FindLine("Value for Between", temp_line), 4)
Else
SRMR = Word(FindLine("Value", temp_line), 2)
End If
End If
End If
End If
' Tag variables as composites or not
FindComposites
' Find TECH4 output
start_line = FindLine("TECHNICAL 4 OUTPUT")
If start_line > 0 Then
IsTECH4 = True
start_line = FindLine("ESTIMATES DERIVED FROM THE MODEL", start_line)
Do While start_line > 0
' Set defaults for group, level and mixture
grp_num = 1
lev_num = 1
mix_num = 1
' Find the group, level and mixture
temp_line = Trim(line(start_line))
temp_line = STRING_RIGHT(temp_line, "ESTIMATES DERIVED FROM THE MODEL")
If Len(temp_line) > 0 Then
' Find groups
If nGroups > 1 Then
For a = 1 To nGroups
If InStr(1, UCase(temp_line), UCase(grouplist(a))) > 0 Then
grp_num = a
Debug.Print "Found group "; a, grouplist(a)
End If
Next
End If
' Find levels
If nLevels > 1 Then
For a = 1 To nLevels
If InStr(1, UCase(temp_line), UCase(levellist(a))) > 0 Then
lev_num = a
Debug.Print "Found level "; a, levellist(a)
End If
Next
End If
' Find mixtures
If nMixtures > 1 Then
temp_line2 = STRING_RIGHT(temp_line, "PATTERN")
If temp_line2 = "" Then temp_line2 = STRING_RIGHT(temp_line, "CLASS")
For a = 1 To nLevels
If InStr(1, UCase(temp_line2), UCase(mixturelist(a))) > 0 Then
mix_num = a
Debug.Print "Found mixture "; a, mixturelist(a)
End If
Next
End If
End If
' Find estimated means
start_line2 = FindLine("ESTIMATED MEANS", start_line)
Do While CONTAINS(line(start_line2), "ESTIMATED MEANS")
For b = 1 To Num_Words_on_Line(start_line2 + 1)
Debug.Print "Adding estimated means " & b & " of " & Num_Words_on_Line(start_line2 + 1)
var_num = VarNum(Word(start_line2 + 1, b))
mod_vector(var_num, 1, grp_num, lev_num, mix_num) = ADD_STRINGVECTOR(mod_vector(var_num, 1, grp_num, lev_num, mix_num), Word(start_line2 + 3, b), "TECH4_Estimate")
Next
start_line2 = Next_NonBlank_Line(start_line2 + 4)
Loop
' Find SEs for estimated means
start_line2 = FindLine("S.E. FOR ESTIMATED MEANS", start_line)
If start_line2 > 0 Then
Do While CONTAINS(line(start_line2), "S.E. FOR ESTIMATED MEANS")
For b = 1 To Num_Words_on_Line(start_line2 + 1)
Debug.Print "Adding estimated SEs " & b & " of " & Num_Words_on_Line(start_line2 + 1)
var_num = VarNum(Word(start_line2 + 1, b))
mod_vector(var_num, 1, grp_num, lev_num, mix_num) = ADD_STRINGVECTOR(mod_vector(var_num, 1, grp_num, lev_num, mix_num), Word(start_line2 + 3, b), "TECH4_SE")
Next
start_line2 = Next_NonBlank_Line(start_line2 + 4)
Loop
End If
' Find ts for estimated means
start_line2 = FindLine("EST./S.E. FOR ESTIMATED MEANS", start_line)
If start_line2 > 0 Then
Do While CONTAINS(line(start_line2), "EST./S.E. FOR ESTIMATED MEANS")
For b = 1 To Num_Words_on_Line(start_line2 + 1)
Debug.Print "Adding estimated ts " & b & " of " & Num_Words_on_Line(start_line2 + 1)
var_num = VarNum(Word(start_line2 + 1, b))
mod_vector(var_num, 1, grp_num, lev_num, mix_num) = ADD_STRINGVECTOR(mod_vector(var_num, 1, grp_num, lev_num, mix_num), Word(start_line2 + 3, b), "TECH4_t")
Next
start_line2 = Next_NonBlank_Line(start_line2 + 4)
Loop
End If
' Find ps for estimated means
start_line2 = FindLine("P-VALUE FOR ESTIMATED MEANS", start_line)
If start_line2 > 0 Then
Do While CONTAINS(line(start_line2), "P-VALUE FOR ESTIMATED MEANS")
For b = 1 To Num_Words_on_Line(start_line2 + 1)
Debug.Print "Adding p-values for estimated means " & b & " of " & Num_Words_on_Line(start_line2 + 1)
var_num = VarNum(Word(start_line2 + 1, b))
mod_vector(var_num, 1, grp_num, lev_num, mix_num) = ADD_STRINGVECTOR(mod_vector(var_num, 1, grp_num, lev_num, mix_num), Word(start_line2 + 3, b), "TECH4_p")
Next
start_line2 = Next_NonBlank_Line(start_line2 + 4)
Loop
End If
' Add Covariances/Variances
Debug.Print "Adding TECH4 Covariances"
start_line2 = FindLine(" ESTIMATED COVARIANCE MATRIX", start_line)
Do While CONTAINS(line(start_line2), " ESTIMATED COVARIANCE MATRIX")
start_line3 = start_line2 + 2
For y = 1 To Num_NonBlankLines(start_line3 + 1)
temp_text = ""
For x = 2 To Num_Words_on_Line(start_line3 + y)
y_num = VarNum(Word(start_line3 + y, 1))
x_num = VarNum(Word(start_line3 - 1, x - 1))
mod_matrix_nondirectional(y_num, x_num, 1, grp_num, lev_num, mix_num) = ADD_STRINGVECTOR(mod_matrix_nondirectional(y_num, x_num, 1, grp_num, lev_num, mix_num), Word(start_line3 + y, x), "TECH4_Estimate")
mod_matrix_nondirectional(x_num, y_num, 1, grp_num, lev_num, mix_num) = mod_matrix_nondirectional(y_num, x_num, 1, grp_num, lev_num, mix_num)
temp_text = temp_text & " " & Word(start_line3 + y, x)
Next
end_line = start_line3 + y
Debug.Print "Found line of covariances: " & temp_text
Next
start_line2 = Next_NonBlank_Line(end_line)
Loop
' Adding SEs for covariances
Debug.Print "Adding TECH4 Covariances SEs"
start_line2 = FindLine("S.E. FOR ESTIMATED COVARIANCE MATRIX", start_line)
If start_line2 > 0 Then
Do While CONTAINS(line(start_line2), "S.E. FOR ESTIMATED COVARIANCE MATRIX")
start_line3 = start_line2 + 2
For y = 1 To Num_NonBlankLines(start_line3 + 1)
temp_text = ""
For x = 2 To Num_Words_on_Line(start_line3 + y)
y_num = VarNum(Word(start_line3 + y, 1))
x_num = VarNum(Word(start_line3 - 1, x - 1))
mod_matrix_nondirectional(y_num, x_num, 1, grp_num, lev_num, mix_num) = ADD_STRINGVECTOR(mod_matrix_nondirectional(y_num, x_num, 1, grp_num, lev_num, mix_num), Word(start_line3 + y, x), "TECH4_SE")
mod_matrix_nondirectional(x_num, y_num, 1, grp_num, lev_num, mix_num) = mod_matrix_nondirectional(y_num, x_num, 1, grp_num, lev_num, mix_num)
temp_text = temp_text & " " & Word(start_line3 + y, x)
Next
end_line = start_line3 + y
Debug.Print "Found line of SEs: " & temp_text
Next
start_line2 = Next_NonBlank_Line(end_line)
Loop
End If
' Adding t statistics for covariances
Debug.Print "Adding TECH4 Covariances ts"
start_line2 = FindLine("EST./S.E. FOR ESTIMATED COVARIANCE MATRIX", start_line)
If start_line2 > 0 Then
Do While CONTAINS(line(start_line2), "EST./S.E. FOR ESTIMATED COVARIANCE MATRIX")
start_line3 = start_line2 + 2
For y = 1 To Num_NonBlankLines(start_line3 + 1)
temp_text = ""
For x = 2 To Num_Words_on_Line(start_line3 + y)
y_num = VarNum(Word(start_line3 + y, 1))
x_num = VarNum(Word(start_line3 - 1, x - 1))
mod_matrix_nondirectional(y_num, x_num, 1, grp_num, lev_num, mix_num) = ADD_STRINGVECTOR(mod_matrix_nondirectional(y_num, x_num, 1, grp_num, lev_num, mix_num), Word(start_line3 + y, x), "TECH4_t")
mod_matrix_nondirectional(x_num, y_num, 1, grp_num, lev_num, mix_num) = mod_matrix_nondirectional(y_num, x_num, 1, grp_num, lev_num, mix_num)
temp_text = temp_text & " " & Word(start_line3 + y, x)
Next
end_line = start_line3 + y
Debug.Print "Found line of ts: " & temp_text
Next
start_line2 = Next_NonBlank_Line(end_line)
Loop
End If
' Adding p statistics for covariances
Debug.Print "Adding TECH4 Covariances ps"
start_line2 = FindLine("P-VALUE FOR ESTIMATED COVARIANCE MATRIX", start_line)
If start_line2 > 0 Then
Do While CONTAINS(line(start_line2), "P-VALUE FOR ESTIMATED COVARIANCE MATRIX")
start_line3 = start_line2 + 2
For y = 1 To Num_NonBlankLines(start_line3 + 1)
temp_text = ""
For x = 2 To Num_Words_on_Line(start_line3 + y)
y_num = VarNum(Word(start_line3 + y, 1))
x_num = VarNum(Word(start_line3 - 1, x - 1))
mod_matrix_nondirectional(y_num, x_num, 1, grp_num, lev_num, mix_num) = ADD_STRINGVECTOR(mod_matrix_nondirectional(y_num, x_num, 1, grp_num, lev_num, mix_num), Word(start_line3 + y, x), "TECH4_p")
mod_matrix_nondirectional(x_num, y_num, 1, grp_num, lev_num, mix_num) = mod_matrix_nondirectional(y_num, x_num, 1, grp_num, lev_num, mix_num)
temp_text = temp_text & " " & Word(start_line3 + y, x)
Next
end_line = start_line3 + y
Debug.Print "Found line of ps: " & temp_text
Next
start_line2 = Next_NonBlank_Line(end_line)
Loop
End If
' Add additional TECH4 output if STDYX has been requested
If stdyx_num > 0 Then
' Add Correlations
Debug.Print "Adding TECH4 Correlations"
start_line2 = FindLine(" ESTIMATED CORRELATION MATRIX", start_line)
Do While CONTAINS(line(start_line2), " ESTIMATED CORRELATION MATRIX")
start_line3 = start_line2 + 2
For y = 1 To Num_NonBlankLines(start_line3 + 1)
temp_text = ""
For x = 2 To Num_Words_on_Line(start_line3 + y)
y_num = VarNum(Word(start_line3 + y, 1))
x_num = VarNum(Word(start_line3 - 1, x - 1))
mod_matrix_nondirectional(y_num, x_num, stdyx_num, grp_num, lev_num, mix_num) = ADD_STRINGVECTOR(mod_matrix_nondirectional(y_num, x_num, stdyx_num, grp_num, lev_num, mix_num), Word(start_line3 + y, x), "TECH4_Estimate")
mod_matrix_nondirectional(x_num, y_num, stdyx_num, grp_num, lev_num, mix_num) = mod_matrix_nondirectional(y_num, x_num, stdyx_num, grp_num, lev_num, mix_num)
temp_text = temp_text & " " & Word(start_line3 + y, x)
Next
end_line = start_line3 + y
Debug.Print "Found line of covariances: " & temp_text
Next
start_line2 = Next_NonBlank_Line(end_line)
Loop
' Adding SEs for correlations
Debug.Print "Adding TECH4 Correlation SEs"
start_line2 = FindLine("S.E. FOR ESTIMATED CORRELATION MATRIX", start_line)
If start_line2 > 0 Then
Do While CONTAINS(line(start_line2), "S.E. FOR ESTIMATED CORRELATION MATRIX")
start_line3 = start_line2 + 2
For y = 1 To Num_NonBlankLines(start_line3 + 1)
temp_text = ""
For x = 2 To Num_Words_on_Line(start_line3 + y)
y_num = VarNum(Word(start_line3 + y, 1))
x_num = VarNum(Word(start_line3 - 1, x - 1))
mod_matrix_nondirectional(y_num, x_num, stdyx_num, grp_num, lev_num, mix_num) = ADD_STRINGVECTOR(mod_matrix_nondirectional(y_num, x_num, stdyx_num, grp_num, lev_num, mix_num), Word(start_line3 + y, x), "TECH4_SE")
mod_matrix_nondirectional(x_num, y_num, stdyx_num, grp_num, lev_num, mix_num) = mod_matrix_nondirectional(y_num, x_num, stdyx_num, grp_num, lev_num, mix_num)
temp_text = temp_text & " " & Word(start_line3 + y, x)
Next
end_line = start_line3 + y
Debug.Print "Found line of SEs: " & temp_text
Next
start_line2 = Next_NonBlank_Line(end_line)
Loop
End If
' Adding t statistics for correlations
Debug.Print "Adding TECH4 Correlations ts"
start_line2 = FindLine("EST./S.E. FOR ESTIMATED CORRELATION MATRIX", start_line)
If start_line2 > 0 Then
Do While CONTAINS(line(start_line2), "EST./S.E. FOR ESTIMATED CORRELATION MATRIX")
start_line3 = start_line2 + 2
For y = 1 To Num_NonBlankLines(start_line3 + 1)
temp_text = ""
For x = 2 To Num_Words_on_Line(start_line3 + y)
y_num = VarNum(Word(start_line3 + y, 1))
x_num = VarNum(Word(start_line3 - 1, x - 1))
mod_matrix_nondirectional(y_num, x_num, stdyx_num, grp_num, lev_num, mix_num) = ADD_STRINGVECTOR(mod_matrix_nondirectional(y_num, x_num, stdyx_num, grp_num, lev_num, mix_num), Word(start_line3 + y, x), "TECH4_t")
mod_matrix_nondirectional(x_num, y_num, stdyx_num, grp_num, lev_num, mix_num) = mod_matrix_nondirectional(y_num, x_num, stdyx_num, grp_num, lev_num, mix_num)
temp_text = temp_text & " " & Word(start_line3 + y, x)
Next
end_line = start_line3 + y
Debug.Print "Found line of ts: " & temp_text
Next
start_line2 = Next_NonBlank_Line(end_line)
Loop
End If
' Adding p statistics for correlations
Debug.Print "Adding TECH4 Correlation ps"
start_line2 = FindLine("P-VALUE FOR ESTIMATED CORRELATION MATRIX", start_line)
If start_line2 > 0 Then
Do While CONTAINS(line(start_line2), "P-VALUE FOR ESTIMATED CORRELATION MATRIX")
start_line3 = start_line2 + 2
For y = 1 To Num_NonBlankLines(start_line3 + 1)
temp_text = ""
For x = 2 To Num_Words_on_Line(start_line3 + y)
y_num = VarNum(Word(start_line3 + y, 1))
x_num = VarNum(Word(start_line3 - 1, x - 1))
mod_matrix_nondirectional(y_num, x_num, stdyx_num, grp_num, lev_num, mix_num) = ADD_STRINGVECTOR(mod_matrix_nondirectional(y_num, x_num, stdyx_num, grp_num, lev_num, mix_num), Word(start_line3 + y, x), "TECH4_p")
mod_matrix_nondirectional(x_num, y_num, stdyx_num, grp_num, lev_num, mix_num) = mod_matrix_nondirectional(y_num, x_num, stdyx_num, grp_num, lev_num, mix_num)
temp_text = temp_text & " " & Word(start_line3 + y, x)
Next
end_line = start_line3 + y
Debug.Print "Found line of ps: " & temp_text
Next
start_line2 = Next_NonBlank_Line(end_line)
Loop
End If
End If
start_line = FindLine("ESTIMATES DERIVED FROM THE MODEL", start_line + 1)
Loop
End If
MsgBox "Mplus output parsed successfully"
End Property
Sub ParseLines()
' Work out where each line starts
Debug.Print "Determining start of each line..."
pNumLines = NumLines()
ReDim pLinePos(1 To pNumLines)
pLinePos(1) = 1
a = 1
lnum = 2
Do
b = InStr(a, out_text, Chr(10))
' Connect the lines if a comment runs over multiple lines
If b <> 0 Then
'MsgBox Mid(out_text, a, b - a) & Chr(10) & b - a & Chr(10) & Mid(out_text, a, 3) & Chr(10) & Mid(out_text, b - 1, 1)
If Mid(out_text, a, 3) = " !" And Mid(out_text, b - 1, 1) = "+" Then
pNumLines = pNumLines - 1
Else
pLinePos(lnum) = b + 1
lnum = lnum + 1
'Debug.Print Mid(out_text, a, b - a)
End If
End If
a = b + 1
Loop Until b = 0
End Sub
Sub AnalysisInfo()
' Work out what type of analysis it is
temp_line = 1
Do
temp_line = FindLine("TYPE", temp_line + 1, False)
If UCase(Word(temp_line, 3)) = "IMPUTATION;" Then IsImputation = True
If UCase(Word(temp_line, 3)) = "MONTECARLO;" Then IsMonteCarlo = True
If UCase(Word(temp_line, 3)) = "BASIC;" Then IsBasic = True
Debug.Print temp_line
Loop While temp_line > 0
If FindLine("MONTECARLO:", 1, False) > 0 Then IsMonteCarlo = True
If FindLine("TYPE=MONTECARLO", 1, False) > 0 Then IsMonteCarlo = True
If FindLine("TYPE=IMPUTATION", 1, False) > 0 Then IsImputation = True
If FindLine("TYPE=BASIC", 1, False) > 0 Then IsBasic = True
' Count the number of variables
nDV = CInt(Word(FindLine("Number of dependent variables"), 5))
nIV = CInt(Word(FindLine("Number of independent variables"), 5))
nCoLV = CInt(Word(FindLine("Number of continuous latent variables"), 6))
nCaLV = CInt(Word(FindLine("Number of categorical latent variables"), 6))
nTotalV = nDV + nIV + nCoLV + nCaLV
ReDim VarList(1 To nTotalV, 1 To 25)
' Find the variables
Debug.Print "Finding variables..."
var_cntr = 1
Dim start_line: start_line = FindLine("SUMMARY OF ANALYSIS")
Dim start_line2
Dim alias_line: alias_line = FindLine("!LABELS:") + 1
For v_type = 1 To 8
If v_type = 1 Then v_tt = " Continuous"
If v_type = 2 Then v_tt = " Binary and ordered categorical (ordinal)"
If v_type = 3 Then v_tt = " Unordered categorical (nominal)"
If v_type = 4 Then v_tt = " Count"
If v_type = 5 Then v_tt = "Observed independent variables"
If v_type = 6 Then v_tt = "Continuous latent variables"
If v_type = 7 Then v_tt = "Categorical latent variables"
If v_type = 8 Then v_tt = " EFA factors" ' And ESEM
start_line2 = FindLine(v_tt, start_line + 1) + 1
If start_line2 > 1 Then
Do While Num_Words_on_Line(start_line2) > 0
b = Num_Words_on_Line(start_line2)
Debug.Print "Found " & b & " words"
For a = 1 To b
If Left(Word(start_line2, a), 1) <> "*" Then ' Do not count a variable if it begins with a "*". Needed for EFA and ESEM.
VarList(var_cntr, 1) = Word(start_line2, a)
VarList(var_cntr, 4) = v_type ' Variable type
If v_type = 6 Or v_type = 7 Or v_type = 8 Then ' Set as latent or not latent
VarList(var_cntr, 5) = True
Else
VarList(var_cntr, 5) = False
End If
Debug.Print "Found " & VarList(var_cntr, 1)
' Find labels
If alias_line > 1 Then
temp_line = FindLine("!" & VarList(var_cntr, 1) & ":", alias_line, False)
If temp_line > 0 Then
temp_al = line(temp_line)
temp_al = Right(temp_al, Len(temp_al) - InStr(1, temp_al, ":"))
VarList(var_cntr, 2) = temp_al
Debug.Print "Label: " & VarList(var_cntr, 2)
Else
VarList(var_cntr, 2) = ""
End If
End If
var_cntr = var_cntr + 1
End If
Next
start_line2 = start_line2 + 1
Loop
End If
Next
' Add scales to the variables
start_line = FindLine("!SCALES:") + 1
If start_line > 1 Then
Do While Num_Words_on_Line(start_line) > 0
temp_al = Trim(line(start_line))
scale_name = Mid(temp_al, 2, InStr(1, temp_al, ":") - 2)
temp_al = Right(temp_al, Len(temp_al) - InStr(1, temp_al, ":")) ': Debug.Print temp_al
temp_al = Split(temp_al, " ")
For a = LBound(temp_al) To UBound(temp_al)
temp_num = VarNum(temp_al(a))
'Debug.Print "Variable number: " & temp_num & " " & temp_al(a)
If temp_num > 0 Then
VarList(temp_num, 3) = scale_name
Debug.Print "Assigning " & scale_name & " to " & temp_al(a)
End If
Next
start_line = start_line + 1
Loop
End If
' Add the names of the multilevel clusters
Debug.Print "Searching for multilevel clusters..."
temp_line = FindLine(" Cluster variable")
If temp_line > 0 Then
temp_words = Num_Words_on_Line(temp_line)
If temp_words = 3 Then ' TWOLEVEL model
levellist.Add "WITHIN"
levellist.Add "BETWEEN"
nLevels = 2
Debug.Print "Levels: "; levellist(1) & " " & levellist(2)
ElseIf temp_words > 3 Then
levellist.Add "WITHIN"
For a = 0 To temp_words - 3
levellist.Add "BETWEEN " & Word(temp_line, temp_words - a)
nLevels = nLevels + 1
Debug.Print "Level:"; levellist(levellist.Count)
Next
End If
End If
' Find the groups
temp_line = FindLine("Number of groups")
nGroups = Word(temp_line, 4)
Debug.Print "Number of groups: " & nGroups
If nGroups > 1 Then
For a = 1 To nGroups
grouplist.Add Word(temp_line + a + 1, 2)
'SampleSize.Add Word(temp_line + a + 1, 3)
Debug.Print "-Group " & a & ": " & grouplist.Item(grouplist.Count)
Next
'Else
'SampleSize.Add Word(temp_line + 1, 4)
'Debug.Print "Sample size: " & SampleSize(1)
End If
' Find the mixtures
Debug.Print "Adding the mixture patterns"
If nCaLV = 1 Then
start_line = FindLine("Class Counts and Proportions") + 5
Do While Num_Words_on_Line(start_line) > 0
mixturelist.Add Word(start_line, 1)
start_line = start_line + 1
Loop
nMixtures = mixturelist.Count
ElseIf nCaLV > 1 Then
start_line = FindLine("Latent Class Variable Patterns") + 5
Do While Num_Words_on_Line(start_line) > 0
mix_patt = ""
For n_word = 1 To Num_Words_on_Line(start_line)
mix_patt = mix_patt & Word(start_line, n_word) & " "
Next
mixturelist.Add Trim(mix_patt)
start_line = start_line + 1
Loop
nMixtures = mixturelist.Count
End If
' Find the types of standardizations
start_line = FindLine("STANDARDIZED MODEL RESULTS")
nStandards = 1
standardlist.Add ""
If start_line > 0 Then
If FindLine("STDYX Standardization", start_line) Then
standardlist.Add "STDYX"
stdyx_num = standardlist.Count
End If
If FindLine("STDY Standardization", start_line) Then standardlist.Add "STDY"
If FindLine("STD Standardization", start_line) Then standardlist.Add "STD"
nStandards = standardlist.Count
End If
If FindLine("LOGISTIC REGRESSION ODDS RATIO RESULTS", start_line) Then
standardlist.Add "Odds Ratio"
nStandards = nStandards + 1
End If
' Add the other information about the variables from UNIVARIATE HIGHER-ORDER MOMENT DESCRIPTIVE STATISTICS
Debug.Print "Adding information about the univariate descriptive statistics..."
For a = 1 To nGroups
temp_line = "UNIVARIATE HIGHER-ORDER MOMENT DESCRIPTIVE STATISTICS"
If nGroups > 1 Then temp_line = temp_line & " FOR " & grouplist(a)
start_line = FindLine(temp_line) + 5
If start_line > 5 Then
Do While Num_Words_on_Line(start_line) > 0
var_n = VarNum(Word(start_line, 1))
If var_n > 0 Then
Debug.Print "Loop", a, "of ", nGroups, "groups"
VarList(var_n, 6) = ADD_STRINGVECTOR(VarList(var_n, 6), Word(start_line, 2)) ' Mean
VarList(var_n, 7) = ADD_STRINGVECTOR(VarList(var_n, 7), Word(start_line + 1, 2)) ' Variance
VarList(var_n, 8) = ADD_STRINGVECTOR(VarList(var_n, 8), Word(start_line + 1, 1)) ' Sample size
VarList(var_n, 9) = ADD_STRINGVECTOR(VarList(var_n, 9), Word(start_line, 3)) ' Skew
VarList(var_n, 10) = ADD_STRINGVECTOR(VarList(var_n, 10), Word(start_line + 1, 3)) ' Kurtosis
VarList(var_n, 11) = ADD_STRINGVECTOR(VarList(var_n, 11), Word(start_line, 4)) ' Minimum
VarList(var_n, 12) = ADD_STRINGVECTOR(VarList(var_n, 12), Word(start_line, 6)) ' 20%
VarList(var_n, 13) = ADD_STRINGVECTOR(VarList(var_n, 13), Word(start_line, 7)) ' 40%
VarList(var_n, 14) = ADD_STRINGVECTOR(VarList(var_n, 14), Word(start_line, 8)) ' Median
VarList(var_n, 15) = ADD_STRINGVECTOR(VarList(var_n, 15), Word(start_line + 1, 6)) ' 60%
VarList(var_n, 16) = ADD_STRINGVECTOR(VarList(var_n, 16), Word(start_line + 1, 7)) ' 80%
VarList(var_n, 17) = ADD_STRINGVECTOR(VarList(var_n, 17), Word(start_line + 1, 4)) ' Maximum
VarList(var_n, 18) = ADD_STRINGVECTOR(VarList(var_n, 18), Word(start_line, 5)) ' % minimum
VarList(var_n, 19) = ADD_STRINGVECTOR(VarList(var_n, 19), Word(start_line + 1, 5)) ' % maximum
Debug.Print "Finished loop"
End If
start_line = start_line + 2
Loop
End If
Next
' Add counts for categorical variables
Debug.Print "Adding counts for categorical variables"
For a = 1 To nGroups
temp_line = "UNIVARIATE PROPORTIONS AND COUNTS FOR CATEGORICAL VARIABLES"
If nGroups > 1 Then temp_line = temp_line & " FOR " & grouplist(a)
start_line = FindLine(temp_line) + 2
If start_line > 2 Then
Do While Num_Words_on_Line(start_line) > 0
If Num_Words_on_Line(start_line) = 1 Then
v_name = Word(start_line, 1)
Else
v_num = VarNum(v_name)
If v_num > 0 Then
VarList(v_num, 8) = ADD_STRINGVECTOR(VarList(v_num, 8), Word(start_line, 4))
End If
End If
start_line = start_line + 1
Loop
End If
Next
' Add proportions for COUNT variables
Debug.Print "Adding proportions for COUNT variables"
For a = 1 To nGroups
temp_line = "COUNT PROPORTION OF ZERO, MINIMUM AND MAXIMUM VALUES"
If nGroups > 1 Then temp_line = temp_line & " FOR " & grouplist(a)
start_line = FindLine(temp_line) + 2
If start_line > 2 Then
Do While Num_Words_on_Line(start_line) > 0
v_num = VarNum(Word(start_line, 1))
If v_num > 0 Then
VarList(v_num, 20) = ADD_STRINGVECTOR(VarList(v_num, 20), Word(start_line, 2))
VarList(v_num, 18) = ADD_STRINGVECTOR(VarList(v_num, 18), Word(start_line, 3))
VarList(v_num, 19) = ADD_STRINGVECTOR(VarList(v_num, 19), Word(start_line, 4))
End If
start_line = start_line + 1
Loop
End If
Next
' Find the estimator
temp_line = FindLine("SUMMARY OF ANALYSIS")
Estimator = Word(FindLine("Estimator", temp_line), 2)
End Sub
Sub AddSampstat()
On Error GoTo error_message
' Add sample statistics
' Are there any sample statistics?
start_line = FindLine("SAMPLE STATISTICS")
' Check to see if it's an exact match
If line(start_line) <> "SAMPLE STATISTICS" Then start_line = 0
If start_line = 0 Then start_line = FindLine("RESULTS FOR BASIC ANALYSIS")
If start_line > 0 Then
Debug.Print "Found sample statistics (SAMPSTAT)"
IsSAMPSTAT = True
' Count the number of variables
start_line2 = FindLine("Covariances", start_line) + 3
If start_line2 = 3 Then start_line2 = FindLine("CORRELATION MATRIX", start_line) + 3
var_cntr = 0
For a = start_line2 To Next_Blank_Line(start_line2) - 1
Debug.Print "Line ", a, "to line", Next_Blank_Line(start_line2) - 1
temp_var = VarNum(Word(a, 1))
Debug.Print temp_var & ": " & Word(a, 1)
'If temp_var > 0 Then VarList(temp_var, 21) = var_cntr + 1 ' Numbering the variable's position in the matrix. Deleted this.
var_cntr = var_cntr + 1
Next
' Resize the observed matrix array based on the number of variables and the number of groups
ReDim obs_matrix(1 To var_cntr, 1 To var_cntr, 1 To 2, 1 To nGroups, 1 To nLevels)
ReDim obs_vector(1 To var_cntr, 1 To nGroups, 1 To nLevels)
'MsgBox "Dimensions are " & var_cntr & " * " & var_cntr & " * " & nGroups & " groups * " & nLevels & " levels."
' Loop through each of the observed matrices and add them to the arrays
For a = 1 To obs_matrix_list.Count
temp_line = "SAMPLE STATISTICS"