The following program fits Models A and B of Example 11. It displays the matrix of total effects for each group and model. Rows and columns of the matrix are labeled with Amos's internal variable numbers.
Imports System.Diagnostics
Imports AmosEngineLib.AmosEngine.TMatrixID
Imports Microsoft.VisualBasic
Module MainModule
' RowNumbers Method Example
Sub Main()
Dim CNumbers() As Integer, RNumbers() As Integer, X(,) As Double
Dim Sem As New AmosEngineLib.AmosEngine
Sem.NeedEstimates(TotalEffects)
Sem.BeginGroup(AmosEngine.AmosDir & "Examples\English\UserGuide.xls", "Fels_fem")
Sem.GroupName("girls")
Sem.AStructure("academic = (g1) GPA + (g2) attract + (1) e1")
Sem.AStructure("attract = (g3) height + (g4) weight + (g5) rating + (g6) academic + (1) e2")
Sem.AStructure("e2 <--> e1")
Sem.BeginGroup(AmosEngine.AmosDir & "Examples\English\UserGuide.xls", "Fels_mal")
Sem.GroupName("boys")
Sem.AStructure("academic = (b1) GPA + (b2) attract + (1) e1")
Sem.AStructure("attract = (b3) height + (b4) weight + (b5) rating + (b6) academic + (1) e2")
Sem.AStructure("e2 <--> e1")
Sem.Model("Model_A")
Sem.Model("Model_B", "g1=b1", "g2=b2", "g3=b3", "g4=b4", "g5=b5", "g6=b6")
'Print total effects for each model and each group
Dim ModelNumber As Integer
Dim GroupNumber As Integer
For ModelNumber = 1 To 2
Sem.FitModel(ModelNumber)
For GroupNumber = 1 To 2
Sem.GetEstimates(TotalEffects, X, GroupNumber)
Sem.ColumnNumbers(TotalEffects, CNumbers, GroupNumber)
Sem.RowNumbers(TotalEffects, RNumbers, GroupNumber)
Debug.WriteLine(vbCrLf & "Group " & GroupNumber & ", Model " & ModelNumber)
PrintMatrix1(X, CNumbers, RNumbers)
Next
Next
Sem.Dispose()
End Sub
'Print a matrix in the debug window
Sub PrintMatrix1(ByVal TheMatrix(,) As Double, ByVal CNumbers() As Integer, ByVal RNumbers() As Integer)
Dim NRows1 As Integer, NColumns1 As Integer
Dim i As Integer, j As Integer
NRows1 = UBound(RNumbers)
NColumns1 = UBound(CNumbers)
Debug.Write(" ")
For j = 0 To NColumns1
Debug.Write(CNumbers(j).ToString.PadLeft(10))
Next
Debug.WriteLine("")
For i = 0 To NRows1
Debug.Write(RNumbers(i).ToString.PadLeft(8))
For j = 0 To NColumns1
Debug.Write(TheMatrix(i, j).ToString("#.00000").PadLeft(10))
Next
Debug.WriteLine("")
Next
End Sub
End Module