The following program fits Models A and B of Example 11. The matrix of total effects is displayed for each group and model.
Imports AmosEngineLib
Imports AmosEngineLib.AmosEngine.TMatrixID
Imports Microsoft.VisualBasic
Imports System.Diagnostics
Module MainModule
' ColumnNames Method Example
Sub Main()
Dim CNames() As String, RNames() As String, 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.ColumnNames(TotalEffects, CNames, GroupNumber)
Sem.RowNames(TotalEffects, RNames, GroupNumber)
Debug.WriteLine(vbCrLf & "Group " & GroupNumber & ", Model " & ModelNumber)
PrintMatrix(X, CNames, RNames)
Next
Next
Sem.Dispose()
End Sub
'Print a matrix in the debug window
Sub PrintMatrix(ByVal TheMatrix(,) As Double, ByVal CNames$(), ByVal RNames$())
Dim NRows1 As Integer, NColumns1 As Integer
Dim i As Integer, j As Integer
NRows1 = UBound(RNames)
NColumns1 = UBound(CNames)
Debug.Write(" ")
For j = 0 To NColumns1
Debug.Write(CNames(j).PadLeft(10))
Next
Debug.WriteLine("")
For i = 0 To NRows1
Debug.Write(RNames(i).PadRight(8))
For j = 0 To NColumns1
Debug.Write(TheMatrix(i, j).ToString(".00000").PadLeft(10))
Next
Debug.WriteLine("")
Next
End Sub
End Module