The following plugin adds to Amos Graphics the ability to compute an additional fit measure -- the standardized root mean square residual (RMR). After you run this plugin, Amos Graphics will display the standardized root mean square residual for each analysis that it performs.
The PreFitOptions subroutine tells the Amos Engine that sample correlations and implied correlations are needed for calculation of the standardized RMR.
The PostFitResults subroutine calculates and displays the standardized RMR.
Imports Microsoft.VisualBasic
Imports Amos
Imports AmosEngineLib.AmosEngine.TMatrixID
<System.ComponentModel.Composition.Export(GetType(IPlugin))>
Public Class CustomCode
Implements IPlugin
Public Function Mainsub() As Integer Implements IPlugin.Mainsub
AddHandler pd.PreFitOptions, AddressOf PreFitOptions
AddHandler pd.PostFitResults, AddressOf PostFitResults
MsgBox("The plugin for calculating standardized RMR is now installed.",, "Standardized RMR")
End Function
Private Sub PreFitOptions(ByVal Sem As AmosEngineLib.AmosEngine)
Sem.NeedEstimates(SampleCorrelations)
Sem.NeedEstimates(ImpliedCorrelations)
End Sub
Private Sub PostFitResults(ByVal Sem As AmosEngineLib.AmosEngine, ByVal ModelName As String, ByVal status As Integer)
Dim N As Integer
Dim i As Integer
Dim j As Integer
Dim DTemp As Double
Dim Sample(,) As Double
Dim Implied(,) As Double
Sem.GetEstimates(SampleCorrelations, Sample)
Sem.GetEstimates(ImpliedCorrelations, Implied)
N = UBound(Sample, 1) + 1
DTemp = 0
For i = 1 To N - 1
For j = 0 To i - 1
DTemp = DTemp + (Sample(i, j) - Implied(i, j)) ^ 2
Next
Next
DTemp = System.Math.Sqrt(DTemp / (N * (N - 1) / 2))
'Dtemp is the standardized RMR
'Display it
Dim message As String
message = "Model: " & ModelName & vbCrLf
If status = 0 Then
message &= "Standardized RMR = " & DTemp.ToString("#.0000")
Else
message &= ("The model was not successfully fitted.")
End If
MsgBox(message,,"Standardized RMR")
End Sub
Public Function Name() As String Implements IPlugin.Name
End Function
Public Function Description() As String Implements IPlugin.Description
End Function
End Class